Search Postgresql Archives

Re: Using oid as pkey

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"D. Dante Lorenso" wrote:

>Using a brain-dead sample table that looks like this:
>
>	CREATE table some_table (
>		col0 SERIAL,
>		col1 VARCHAR,
>		col2 VARCHAR
>	);
>
>I want to do something like this:
>
>	INSERT INTO some_table (col1, col2)
>	VALUES ('val1', 'val2');
>
>I want the value of col0 returned to the application and I don't want to 
>know the name of the sequence involved in the SERIAL column.  I just 
>want the value inserted into the column by using just it's column name.

Using 8.2 or above:
INSERT INTO some_table (col1, col2) VALUES ('val1', 'val2') RETURNING col0;

Rainer

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

               http://archives.postgresql.org/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux