Re: [GENERAL] INSERT with SELECT not working in pgAdmin

2010-09-21 Thread Stefan Wild
Hey Stefan, The sounds like you have a field id in you c_transactions without default value (which usually should be nextval('some_sequence'::regclass). Do you create a sequence for c_transactions.id ? Hi Dmitriy, yes it's right, the id column does not have a default value and it

Re: [GENERAL] INSERT with SELECT not working in pgAdmin

2010-09-21 Thread Stefan Wild
Ok I found the solution. I have to use the UPDATE command and not the INSERT: UPDATE c_transactions SET timestamp = entrytimestamp and than: UPDATE c_transactions SET timestamp = exittimestamp WHERE exittimestamp IS NOT NULL -- Sent via pgsql-general mailing list

Re: [GENERAL] INSERT with SELECT not working in pgAdmin

2010-09-21 Thread Dmitriy Igrishin
Hey Stefan, For surrogate keys there is no reason to calculate values manually. You should use sequences instead. Please, see http://www.postgresql.org/docs/8.3/static/sql-createsequence.html You may also use a SERIAL data type which creates a sequence for you automatically upon its creation.

[GENERAL] INSERT with SELECT not working in pgAdmin

2010-09-20 Thread Stefan Wild
Hi guys, I'm trying to merge two tables to one with INSERT and SELECT commands: INSERT into c_transactions (timestamp) SELECT entrytimestamp from c_transactions INSERT into c_transactions (timestamp) SELECT exittimestamp from c_transactions But getting this error on execution (in pgAdmin):

Re: [GENERAL] INSERT with SELECT not working in pgAdmin

2010-09-20 Thread Dmitriy Igrishin
Hey Stefan, The sounds like you have a field id in you c_transactions without default value (which usually should be nextval('some_sequence'::regclass). Do you create a sequence for c_transactions.id ? -- Regards, Dmitriy