[SQL] newbie question

2006-03-03 Thread ivan marchesini
Dear users..
I have fastly created a table in a postgresql database..
some columns where edited by hand (columns A, B, C), and some others
(columns D, E, F) have been calculated as a result of mathematical
equation (where the factors are the A, B, C columns)
now I simply need to change some values in the A, B, C columns and I
would like to obtain the correct values in the D, E, F column...
I know that this is a tipical problem of a spreadsheet but how can I
solve it with a DBMS??
there a way to impose some constrain, also after the table is already
filled with values?? 
I need only some suggestions to start.. then I can go on by myself!!
thank you very much
Ivan



-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756






---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [SQL] newbie question

2006-03-03 Thread ivan marchesini
Thanks to all...
another question...
is it possible to copy a table to a view and then back the view to a
table???
thank you very much...
ivan




Il giorno ven, 03/03/2006 alle 11.51 +0100, Andreas Kretschmer ha
scritto:
> ivan marchesini <[EMAIL PROTECTED]> schrieb:
> 
> > Dear users..
> > I have fastly created a table in a postgresql database..
> > some columns where edited by hand (columns A, B, C), and some others
> > (columns D, E, F) have been calculated as a result of mathematical
> > equation (where the factors are the A, B, C columns)
> 
> You should create a table with (a,b,c) and a view. Below a example.
> 
> test=# create table foo (a int, b int, c int);
> CREATE TABLE
> 
> test=# create view foo_view as (select a,b,c,a*b as ab, a*c as ac, b*c as bc 
> from foo);
> CREATE VIEW
> 
> 
> > now I simply need to change some values in the A, B, C columns and I
> > would like to obtain the correct values in the D, E, F column...
> > I know that this is a tipical problem of a spreadsheet but how can I
> > solve it with a DBMS??
> 
> test=# insert into foo values (2,3,4);
> INSERT 0 1
> test=# select * from foo_view ;
>  a | b | c | ab | ac | bc
> ---+---+---+++
>  2 | 3 | 4 |  6 |  8 | 12
> (1 row)
> 
> test=# update foo set a=3;
> UPDATE 1
> test=# select * from foo_view ;
>  a | b | c | ab | ac | bc
> ---+---+---+++
>  3 | 3 | 4 |  9 | 12 | 12
> (1 row)
> 
> 
> HTH, Andreas
-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756






---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


[SQL] COPY tablename FROM and null values

2006-03-22 Thread ivan marchesini
Dear users,
I'm working on a Postgres 7.4 server

I have a .txt file, containing some tabular data, where data are
delimited by TABs.
there are 3 columns:

column1 int4, column2 float8, column3 float8

the problem is that column3 contains also null values (i.e. sometimes is
empty)

so when I try to use COPY tablename FROM 'filename.txt' I obtain an
error

I have tried also using " WITH NULL AS ' ' " but without good results...

can someone explain me how to solve this problem???

thank you very much

Ivan
 



-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]




---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


[SQL] how to solve this problem

2006-04-13 Thread ivan marchesini
Dear users,
I have this problem 

I have a table where there are 20 columns named
vinc1, vinc2, vinc3, vinc4, etc

the values contained into each column are simply 1 or 0  (each column is
dichotomic)
1 means presence
0 means absence

I would obtain a column (new_column) containg the name of the columns,
comma separated, where the value is = 1

for example:

vinc1   vinc2   vinc3   vinc4   new_column
1   0   1   0   vinc1,vinc3
0   0   0   1   vinc4
0   1   1   1   vinc2,vinc3,vinc4

can someone help me to find the best way to obtain this result???
thank you very much

Ivan







-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]




---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [SQL] how to solve this problem

2006-04-13 Thread ivan marchesini
Sorry, I'm not able to understand how I can use this solution!!!
can you better explain me your suggestion???

Thanks very much


Il giorno gio, 13/04/2006 alle 06.51 -0700, Richard Broersma Jr ha
scritto:
> Just a thought,
> 
> Could you achieve that same result using the binary representation of an 
> integer?
> 
> Regards,
> 
> Richard
> 
> --- ivan marchesini <[EMAIL PROTECTED]> wrote:
> 
> > Dear users,
> > I have this problem 
> > 
> > I have a table where there are 20 columns named
> > vinc1, vinc2, vinc3, vinc4, etc
> > 
> > the values contained into each column are simply 1 or 0  (each column is
> > dichotomic)
> > 1 means presence
> > 0 means absence
> > 
> > I would obtain a column (new_column) containg the name of the columns,
> > comma separated, where the value is = 1
> > 
> > for example:
> > 
> > vinc1   vinc2   vinc3   vinc4   new_column
> > 1   0   1   0   vinc1,vinc3
> > 0   0   0   1   vinc4
> > 0   1   1   1   vinc2,vinc3,vinc4
> > 
> > can someone help me to find the best way to obtain this result???
> > thank you very much
> > 
> > Ivan
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > Ivan Marchesini
> > Department of Civil and Environmental Engineering
> > University of Perugia
> > Via G. Duranti 93/a 
> > 06125
> > Perugia (Italy)
> > e-mail: [EMAIL PROTECTED]
> > [EMAIL PROTECTED]
> > tel: +39(0)755853760
> > fax: +39(0)755853756
> > jabber: [EMAIL PROTECTED]
> > 
> > 
> > 
> > 
> > ---(end of broadcast)---
> > TIP 1: if posting/reading through Usenet, please send an appropriate
> >subscribe-nomail command to [EMAIL PROTECTED] so that your
> >message can get through to the mailing list cleanly
> > 
> 
> 
-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]




---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [SQL] how to solve this problem

2006-04-14 Thread ivan marchesini
Thank you very much!!!
your suggestion seems really usefull!! I will try it very soon!!!
ivan


Il giorno gio, 13/04/2006 alle 11.34 -0700, Steve Crawford ha scritto:
> > I have a table where there are 20 columns named
> > vinc1, vinc2, vinc3, vinc4, etc
> > 
> > the values contained into each column are simply 1 or 0  (each column is
> > dichotomic)
> > 1 means presence
> > 0 means absence
> > 
> > I would obtain a column (new_column) containg the name of the columns,
> > comma separated, where the value is = 1
> > 
> > for example:
> > 
> > vinc1   vinc2   vinc3   vinc4   new_column
> > 1   0   1   0   vinc1,vinc3
> > 0   0   0   1   vinc4
> > 0   1   1   1   vinc2,vinc3,vinc4
> > 
> > can someone help me to find the best way to obtain this result???
> > thank you very much
> 
> Here's a brute-force method. Maybe someone else has a more elegant way. 
> More info on the nature of your data and what you are trying to obtain 
> from it would help in finding such elegance.
> 
> select
>substr(
>case when vinc1 = 1 then ',vinc1' else '' ||
>case when vinc2 = 1 then ',vinc2' else '' ||
>...
>case when vinc20 = 1 then ',vinc20' else ''
>,2) as new_column ...
> 
> As to the binary representation mentioned elsewhere, the idea is that 
> you can view vinc1-vinc20 as bits in a binary number equal to vinc1 + 
> 2*vinc2 + 4*vinc3 + 8*vinc4...2^19*vinc20. Whether or not this is useful 
> depends on what you are trying to do.
> 
> Cheers,
> Steve
> 
-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]




---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


[SQL] simple problem???

2006-07-20 Thread ivan marchesini
Dear users
It's a simple problem I think (and I hope  :-)

I have a table like this:
A|B|C
1|2|20
1|3|10
1|4|21
2|3|12
2|4|22
3|4|23

where the first two column are a combination without repetition (with
k=2) of the numbers 1,2,3,4
for each pair I have a value in the column C.

I would want a select that can extract these records:

1|3|10
2|3|12
3|4|23


i.e. the select must look into the A field first and: 
-select all records where A=1, 
-find, into this selection, the record where there's the minimum value
of the field C 
-print all the fields for this record.

then

-select all records where A=2
-find, into this selection, the record where there's the minimum value
of the field C 
-print all the fields of this record.

and so on...

using 
SELECT a,MIN(c) FROM table GROUP BY a

is a partial solution because I can't see the value of B
and I obtain:

1|10
2|12
3|23

How can I do for plotting also the value of B???

Thank you very much

Ivan





-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]




---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


[SQL] 2 tables or two db?

2009-06-18 Thread ivan marchesini
Dear postgres users,

Suppose I have two tables of data.

suppose the two table are really similar in dimensions 

suppose they will receive the same number and type of queries.

in tems of performance (velocity of answer) it is better to place the
two tables in the same db or into two different db?

may be it is a stupid question, but

many many thanks...

 Ivan






-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] .psql_history": No such file

2009-06-26 Thread ivan marchesini
Dear users,

I have installed a postgres db using a datadir different
from /var/lib/pgsql/.psql_history.

then:
   su postgres
   psql postgres

All went fine but when I exit from psql from a db I obtain:
___
could not save history to file "/var/lib/pgsql/.psql_history": No such 
file or directory
___

how can I fix this problem? where can I say psql that it must
write .psql_history into the datadir?

many thanks...
ivan





-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] .psql_history": No such file

2009-06-29 Thread ivan marchesini
Thanks to all...
in effect it is a very little problem if you consider that probably I
will call psql from normal accounts...

:-)

thanks


Il giorno dom, 28/06/2009 alle 01.04 +0930, Shane Ambler ha scritto:
> Guillaume Lelarge wrote:
> > Hi Ivan,
> > 
> > Le vendredi 26 juin 2009 à 17:53:15, ivan marchesini a écrit :
> >> [...]
> >> I have installed a postgres db using a datadir different
> >> from /var/lib/pgsql/.psql_history.
> >>
> >> then:
> >>su postgres
> >>psql postgres
> >>
> >> All went fine but when I exit from psql from a db I obtain:
> >> ___
> >> could not save history to file "/var/lib/pgsql/.psql_history": No such
> >> file or directory
> >> ___
> >>
> >> how can I fix this problem? where can I say psql that it must
> >> write .psql_history into the datadir?
> >>
> > 
> > psql tries to write there because the home directory of the postgres user 
> > is 
> > /var/lib/postgres. Probably better to use HISTFILE to change it (\set 
> > HISTFILE 
> > '/path/to/histfile').
> > 
> > Regards.
> > 
> > 
> You do know that you don't need to su postgres to start psql?
> 
> Only the server needs to be run with the postgres user account. If you 
> run psql from your normal user account the history file will be saved 
> into your home folder not the postgresql install/data file dir.
> 
> 
> -- 
> 
> Shane Ambler
> pgSQL (at) Sheeky (dot) Biz
> 
> 


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] could not connect to server

2006-10-13 Thread ivan marchesini
Dear Users,
I have this problem:
I'm running postgres 7.3 on a linux system...
I have started postmaster with -i option, but when I try to connect to
the server  from another computer I obtain:

psql: could not connect to server: Nessuna rotta verso l'host
Is the server running on host "IP." and accepting
TCP/IP connections on port 5432?

when I try to connect from the same computer running the postgres server
(using TCP/IP )
psql cave_prova -h IP -p 5432 -U aurora

the server answer correctly... and I can connect...
so I think the TCP/IP socket is working well!!!

can you suggest me some ideas for solving this problem???
thank you
Ivan


-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]




---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [SQL] could not connect to server

2006-10-13 Thread ivan marchesini
Dear Andreas,
this is my pg_hba.conf file:
__
# TYPE  DATABASEUSERIP-ADDRESSIP-MASK
METHOD

# IPv4-style local connections:
hostallall   127.0.0.1   255.255.255.255 trust
hostallall   "my_netaddres".0   255.255.255.0 trust
#hostall   

# IPv6-style local connections:
#hostall all ::1
:::::::trust

# Using sockets credentials for improved security. Not available
everywhere,
# but works on Linux, *BSD (and probably some others)

local  allall ident   sameuser
__


I hope is correct...
what do you think??

thank you!!









On ven, 2006-10-13 at 09:27 +0200, A. Kretschmer wrote:
> am  Fri, dem 13.10.2006, um  8:52:19 +0200 mailte ivan marchesini folgendes:
> > Dear Users,
> > I have this problem:
> > I'm running postgres 7.3 on a linux system...
> 
> Uhm, a very old version...
> 
> 
> 
> > I have started postmaster with -i option, but when I try to connect to
> > the server  from another computer I obtain:
> > 
> > psql: could not connect to server: Nessuna rotta verso l'host
> > Is the server running on host "IP." and accepting
> > TCP/IP connections on port 5432?
> > 
> > when I try to connect from the same computer running the postgres server
> > (using TCP/IP )
> > psql cave_prova -h IP -p 5432 -U aurora
> > 
> > the server answer correctly... and I can connect...
> > so I think the TCP/IP socket is working well!!!
> > 
> > can you suggest me some ideas for solving this problem???
> > thank you
> > Ivan
> 
> Take a look in you ph_hba.conf - file and edit this properly. You need
> an entry for the other host.
> 
> http://www.postgresql.org/docs/current/static/client-authentication.html
> 
> 
> 
> HTH, Andreas
-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]




---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


[SQL] drop a check

2006-11-13 Thread ivan marchesini
Dear all...
I have created a check constraint without giving it a name..
now I have a check named "$25" in my table that I need to drop or
modify!!!
How can I do???
with names is simple

alter table tablename drop constraint constraintname;

but without name??   :-)

many thanks...

Ivan




-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]




---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [SQL] drop a check

2006-11-13 Thread ivan marchesini
Dear Volkan,
thank you for your answer...
I have tried to verify the table
information_schema.constraint_column_usage, but, and I was really
surprised, I have found nothing inside it.. 
it seems there are not checks!!!
I have also seen the manual page you suggested but I can't understand
why I don't have checks in this table... 

but I'm sure I have checks in my table.. because they works!
does this problem can be related to the fact that I have created the
checks only after that I have created the table...
I have used this syntacs:
alter table tablename add check (..)

however it sounds strange!
thanks!!!
Ivan




On lun, 2006-11-13 at 19:41 +0200, Volkan YAZICI wrote:
> On Nov 13 05:32, ivan marchesini wrote:
> > I have created a check constraint without giving it a name..
> > now I have a check named "$25" in my table that I need to drop or
> > modify!!!
> > How can I do???
> > with names is simple
> > 
> > alter table tablename drop constraint constraintname;
> > 
> > but without name??   :-)
> 
> CREATE TABLE cons_test (
> u   integer CHECK (u > 10)
> );
> 
> SELECT constraint_name
>   FROM information_schema.constraint_column_usage
>  WHERE table_name = 'cons_test' AND
>column_name = 'u';
> 
> See infoschema-constraint-column-usage.html in the manual for further
> assistance.
> 
> 
> Regards.
> 
-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]




---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [SQL] drop a check

2006-11-13 Thread ivan marchesini
.
or it depend on the fact I'm using postgres 7.4.13
many thanks...

Ivan





On lun, 2006-11-13 at 19:41 +0200, Volkan YAZICI wrote:
> On Nov 13 05:32, ivan marchesini wrote:
> > I have created a check constraint without giving it a name..
> > now I have a check named "$25" in my table that I need to drop or
> > modify!!!
> > How can I do???
> > with names is simple
> > 
> > alter table tablename drop constraint constraintname;
> > 
> > but without name??   :-)
> 
> CREATE TABLE cons_test (
> u   integer CHECK (u > 10)
> );
> 
> SELECT constraint_name
>   FROM information_schema.constraint_column_usage
>  WHERE table_name = 'cons_test' AND
>column_name = 'u';
> 
> See infoschema-constraint-column-usage.html in the manual for further
> assistance.
> 
> 
> Regards.
> 
-- 
Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]




---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


[SQL] join a lot of columns of two tables

2006-12-14 Thread ivan marchesini
Dear Postgres Users,
I have 2 tables...
each one has a column called ID (primary keys of each table)
the values into each ID column are exactly the same.

each table has a lot of other columns (around 50 for each table)

I would like to create a table containing the ID (only one column
obviously) and all the other columns of both tables...

a simple equi join for each column is simple but how can I join
completely the two table on the bases of the column ID???

probably it is a simple question but I don't know how to solve this very
simple problem quikly...  :-(
thanks

Ivan


-- 
Ti prego di cercare di non inviarmi files .doc, .xls, .ppt, .dwg.
Preferisco formati liberi.
Please try to avoid to send me  .doc, .xls, .ppt, .dwg files.
I prefer free formats.
http://it.wikipedia.org/wiki/Formato_aperto
http://en.wikipedia.org/wiki/Open_format

Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax: +39(0)755853756
jabber: [EMAIL PROTECTED]



---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


[SQL] insert a sequence

2007-05-10 Thread ivan marchesini
Dear postgres Users,
I have a simple question I think.
I have a table that contains some columns
one of these columns (the columns ID) contains distinct integer
values ...
I need to insert into this table some other records but I only need that
values were inserted into the ID column and that they were
progressive... (a sequence starting from 100 and ending to 300, step=1) 
the other columns must remains null
can I do this with a sequence and then an "insert into"?

many thanks 




-- 
Ti prego di cercare di non inviarmi files .doc, .xls, .ppt, .dwg.
Preferisco formati liberi.
Please try to avoid to send me  .doc, .xls, .ppt, .dwg files.
I prefer free formats.
http://it.wikipedia.org/wiki/Formato_aperto
http://en.wikipedia.org/wiki/Open_format

Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax (university): +39(0)755853756
fax (home): +39(0)5782830887
jabber: [EMAIL PROTECTED]


---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


[SQL] date problems

2007-08-30 Thread ivan marchesini
Dear PG users,
I have an access db and I'm trying to pass all to postgres
I have used mdbtools to export the schema and all went quite well.
then I exported the single tables... to csv..

a lot of table have some timestamp fields containing data as DD/MM/,
and I'm no able to copy this table into postgres... because it needs
/MM/DD...
I used \copy...

Which is the best solution for this problem...

many thanks

Ivan






-- 
Ti prego di cercare di non inviarmi files .doc, .xls, .ppt, .dwg.
Preferisco formati liberi.
Please try to avoid to send me  .doc, .xls, .ppt, .dwg files.
I prefer free formats.
http://it.wikipedia.org/wiki/Formato_aperto
http://en.wikipedia.org/wiki/Open_format

Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax (university): +39(0)755853756
fax (home): +39(0)5782830887
jabber: [EMAIL PROTECTED]


---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


[SQL] foreign key problem

2007-09-24 Thread ivan marchesini
Dear users,
I'm trying to create constraints into a db they give me from access...
I'm using pgadmin to create a new foreign key for the relationship
between two table..

I have a table called "generalita" wich contains a column called
"cod_carg":
___
select cod_carg from generalita group by cod_carg;
 cod_carg
--

 2
 0
 1
(4 righe)
___


I have another table, called "diz_carg" that contain, into a column
called "cod_carg" (that is a primary key), the domain values for the
"cod_carg" column of "generalita":
__
select cod_carg from diz_carg group by cod_carg;
 cod_carg
--
 1
 0
 2
(3 righe)
__



so when I try to create the foreign key I obtain:
ALTER TABLE generalita ADD CONSTRAINT fkey_diz_cod_carg FOREIGN KEY
(cod_carg) REFERENCES diz_carg (cod_carg) ON UPDATE NO ACTION ON DELETE
NO ACTION;


ERROR:  insert or update on table "generalita" violates foreign key
constraint "fkey_diz_cod_carg"
DETAIL:  Key (cod_carg)=(  ) is not present in table "diz_carg".



can I allow null values for "generalita.cod_carg" although it is a
foreign key for "diz_carg.cod_carg"?

I apologize if it is a stupid question   :-(

many thanks to all




-- 
Ti prego di cercare di non inviarmi files .doc, .xls, .ppt, .dwg.
Preferisco formati liberi.
Please try to avoid to send me  .doc, .xls, .ppt, .dwg files.
I prefer free formats.
http://it.wikipedia.org/wiki/Formato_aperto
http://en.wikipedia.org/wiki/Open_format

Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax (university): +39(0)755853756
fax (home): +39(0)5782830887
jabber: [EMAIL PROTECTED]


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


[SQL] store pdf files

2008-12-09 Thread ivan marchesini
Hi to all...
I need to create a db that contain link to some pdf files..
At the moment these are simple links (to the files that are stored into
the file system) storing paths into a column of a dbf table...

I need to manage this data considering that the db I'm going to create
will be moved in some months to another server... 
so I think that the link to the files positions into the file system
isn't a valid solution...

can you suggest me a better way to manage this pdf data?? 
Each pdf is quite small (<100k)

should I use BLOB?

many thanks

Ivan






-- 
Ti prego di cercare di non inviarmi files .dwg, .doc, .xls, .ppt.
Preferisco formati liberi.
Please try to avoid to send me .dwg, .doc, .xls, .ppt files.
I prefer free formats.
http://it.wikipedia.org/wiki/Formato_aperto
http://en.wikipedia.org/wiki/Open_format

Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a 
06125
Perugia (Italy)
Socio fondatore GFOSS "Geospatial Free and Open Source Software" 
http://www.gfoss.it
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
tel: +39(0)755853760
fax (university): +39(0)755853756
fax (home): +39(0)5782830887
jabber: [EMAIL PROTECTED]


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql