Re: [GENERAL] INSERT RETURNING with values other than inserted ones.

2013-06-11 Thread David Johnston
Aleksandr Furmanov wrote > Thanks, > However I am not just replicating data from 'a' to 'b', I provided > simplified example, in reality table 'b' keeps data which are going to be > merged into 'a', some rows will be updated, some added. There is some > other work has to be done on 'b' before mergi

Re: [GENERAL] INSERT RETURNING with values other than inserted ones.

2013-06-10 Thread Aleksandr
Thanks, However I am not just replicating data from 'a' to 'b', I provided simplified example, in reality table 'b' keeps data which are going to be merged into 'a', some rows will be updated, some added. There is some other work has to be done on 'b' before merging into 'a' and that work relies

Re: [GENERAL] INSERT RETURNING with values other than inserted ones.

2013-06-10 Thread Richard Dunks
If you're just replicating the data from table A into table B, why does it need its own ID number? Wouldn't the table A ID suffice? I'd recommend using the following: CREATE TABLE b AS ( SELECT * FROM a ); This way, you only define the columns and insert the data once, then let Postgres do the

[GENERAL] INSERT RETURNING with values other than inserted ones.

2013-06-10 Thread Aleksandr Furmanov
Hello, I want to insert new values into target table 'a' from source table 'b', and then update table 'b' with ids from table 'a', somewhat like: CREATE TABLE a(id SERIAL, name TEXT); INSERT INTO a (name) VALUES('Jason'); INSERT INTO a (name) VALUES('Peter'); CREATE TABLE b(row_id serial, id INT

Re: [GENERAL] insert ... returning in plpgsql

2012-10-02 Thread Willy-Bas Loos
cool, thanks On Tue, Oct 2, 2012 at 3:13 PM, Cédric Villemain wrote: > ** > > Le mardi 2 octobre 2012 15:01:08, Willy-Bas Loos a écrit : > > > Hi, > > > (postgres 9.1) > > > I was doing something like this in a plpgsql function, but i got a Syntax > > > Error. > > > > > > t_var:=(insert into tabl

Re: [GENERAL] insert ... returning in plpgsql

2012-10-02 Thread Cédric Villemain
Le mardi 2 octobre 2012 15:01:08, Willy-Bas Loos a écrit : > Hi, > (postgres 9.1) > I was doing something like this in a plpgsql function, but i got a Syntax > Error. > > t_var:=(insert into table1(field2) values ('x') returning field1); > > Is there no support for using RETURNING in insert, upda

Re: [GENERAL] insert ... returning in plpgsql

2012-10-02 Thread Leif Biberg Kristensen
Tirsdag 2. oktober 2012 15.01.08 skrev Willy-Bas Loos : > Hi, > (postgres 9.1) > I was doing something like this in a plpgsql function, but i got a Syntax > Error. > > t_var:=(insert into table1(field2) values ('x') returning field1); > > Is there no support for using RETURNING in insert, update

[GENERAL] insert ... returning in plpgsql

2012-10-02 Thread Willy-Bas Loos
Hi, (postgres 9.1) I was doing something like this in a plpgsql function, but i got a Syntax Error. t_var:=(insert into table1(field2) values ('x') returning field1); Is there no support for using RETURNING in insert, update, delete queries to fill a variable in plpgsql? Here's some code. Retur

Re: [GENERAL] [GENERAL] INSERT. RETURNING for copying records

2012-09-10 Thread Michael Sacket
On Sep 7, 2012, at 2:19 PM, David Johnston wrote: > > From: pgsql-general-ow...@postgresql.org > [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Michael Sacket > Sent: Friday, September 07, 2012 2:09 PM > To: PG-General Mailing List > Subject: [GENERAL] INSERT… RET

[GENERAL] Re: [GENERAL] INSERT… RETURNING for copying records

2012-09-08 Thread Misa Simic
You can make function what returns integer and has input parametars as other columns of the table: INSERT INTO testing (category, name, fk_parent) (input parameters) returning rid Then SELECT rid as OriginalId, make_copy(other columns) as new_rid From testing Kind Regards, Misa On Friday, Septe

Re: [GENERAL] RE: [GENERAL] INSERT. RETURNING for copying records

2012-09-08 Thread David Johnston
t; Best Regards, > Dinesh > manojadinesh.blogspot.com > > > On Sat, Sep 8, 2012 at 12:49 AM, David Johnston wrote: > > > From: pgsql-general-ow...@postgresql.org > [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Michael Sacket > Sent: Friday, September 07, 2012 2:

Re: [GENERAL] RE: [GENERAL] INSERT. RETURNING for copying records

2012-09-07 Thread dinesh kumar
al-ow...@postgresql.org] *On Behalf Of *Michael Sacket > *Sent:* Friday, September 07, 2012 2:09 PM > *To:* PG-General Mailing List > *Subject:* [GENERAL] INSERT… RETURNING for copying records > > ** ** > > Good Afternoon, > > ** ** > > I'm attempting to

[GENERAL] RE: [GENERAL] INSERT. RETURNING for copying records

2012-09-07 Thread David Johnston
From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Michael Sacket Sent: Friday, September 07, 2012 2:09 PM To: PG-General Mailing List Subject: [GENERAL] INSERT. RETURNING for copying records Good Afternoon, I'm attempting to wr

[GENERAL] INSERT… RETURNING for copying records

2012-09-07 Thread Michael Sacket
Good Afternoon, I'm attempting to write a function that will duplicate a few records, but the catch is I need to have a mapping of the original pk to the new pk. I know I can use the RETURNING clause to get the new ids... but how to map that to the original ones is escaping me. < Setup > CRE

Re: [GENERAL] INSERT RETURNING and partitioning

2010-07-21 Thread Alban Hertroys
On 21 Jul 2010, at 11:35, pdov...@tiscali.it wrote: >> Yes, Jan's right. You're effectively overriding the return values >> with NULL. >> >> Although I think I know why you're doing it, because you want to >> redirect the value to the child table so that it doesn't get inserted >> into the pare

Re: [GENERAL] INSERT RETURNING and partitioning

2010-07-21 Thread pdov...@tiscali.it
Hi Tom Messaggio originale Da: thombr...@gmail.com Data: 21/07/2010 10.38 A: "Jan Otto" Cc: "pdov...@tiscali.it", "pgsql- gene...@postgresql.org" Ogg: Re: [GENERAL] INSERT RETURNING and partitioning On 21 July 2010 09:17, Jan Otto wrote: > hi, >

Re: [GENERAL] INSERT RETURNING and partitioning

2010-07-21 Thread pdov...@tiscali.it
Hi Jan, Messaggio originale Da: as...@me.com Data: 21/07/2010 10.17 A: "pdov...@tiscali.it" Cc: "pgsql-general@postgresql.org" Ogg: Re: [GENERAL] INSERT RETURNING and partitioning hi, On Jul 21, 2010, at 10:02, "pdov...@tiscali.it" wrote: > Hi, &g

Re: [GENERAL] INSERT RETURNING and partitioning

2010-07-21 Thread Thom Brown
On 21 July 2010 09:17, Jan Otto wrote: > hi, > > On Jul 21, 2010, at 10:02, "pdov...@tiscali.it" wrote: > >> Hi, >> I'm testing the system with these two insert commands: >> >> 1) this command returns an empty result set: >> insert into support.master (a) VALUES (2) RETURNING seq; >> >> 2) this c

Re: [GENERAL] INSERT RETURNING and partitioning

2010-07-21 Thread Jan Otto
hi, On Jul 21, 2010, at 10:02, "pdov...@tiscali.it" wrote: Hi, I'm testing the system with these two insert commands: 1) this command returns an empty result set: insert into support.master (a) VALUES (2) RETURNING seq; 2) this command returns correctly the seq (serial) value into result

Re: [GENERAL] INSERT RETURNING and partitioning

2010-07-21 Thread pdov...@tiscali.it
Hi, I'm testing the system with these two insert commands: 1) this command returns an empty result set: insert into support.master (a) VALUES (2) RETURNING seq; 2) this command returns correctly the seq (serial) value into result set: insert into support.partitionB (a) VALUES (2) RETURNING seq;

Re: [GENERAL] INSERT RETURNING and partitioning

2010-07-20 Thread Thom Brown
On 20 July 2010 14:42, pdov...@tiscali.it wrote: > Hi all, > I've noticed that an insert command with returning clause returns an > empty result set if done on a master table. Instead the same insert > with returning on partitioned tables works correctly. > > Do you know if it's a normal action? I

[GENERAL] INSERT RETURNING and partitioning

2010-07-20 Thread pdov...@tiscali.it
Hi all, I've noticed that an insert command with returning clause returns an empty result set if done on a master table. Instead the same insert with returning on partitioned tables works correctly. Do you know if it's a normal action? I'm doing something wrong? The partitioning works correctly

Re: [GENERAL] INSERT... RETURNING with a function

2009-09-26 Thread Iain Barnett
On 26 Sep 2009, at 19:57, Tom Lane wrote: I think you want INSERT ... RETURNING ... INTO some-plpgsql-variable; regards, tom lane On 26 Sep 2009, at 19:56, Adrian Klaver wrote: See: http://www.postgresql.org/docs/8.4/interactive/plpgsql- statements.html#PLPGSQL-S

Re: [GENERAL] INSERT... RETURNING with a function

2009-09-26 Thread Tom Lane
Iain Barnett writes: > I've written a straightforward insert function, but using the > RETURNING keyword for the first time. If I try running the test case > I get the error: > ERROR: query has no destination for result data > CONTEXT: PL/pgSQL function "nonauth_users_insert_new_udf" line 7

Re: [GENERAL] INSERT... RETURNING with a function

2009-09-26 Thread Adrian Klaver
On Saturday 26 September 2009 11:04:42 am Iain Barnett wrote: > I've written a straightforward insert function, but using the > RETURNING keyword for the first time. If I try running the test case > I get the error: > > ERROR: query has no destination for result data > CONTEXT: PL/pgSQL function

[GENERAL] INSERT... RETURNING with a function

2009-09-26 Thread Iain Barnett
I've written a straightforward insert function, but using the RETURNING keyword for the first time. If I try running the test case I get the error: ERROR: query has no destination for result data CONTEXT: PL/pgSQL function "nonauth_users_insert_new_udf" line 7 at SQL statement I'm not s

Re: [GENERAL] INSERT RETURNING rule for joined view

2009-06-01 Thread Merlin Moncure
On Mon, Jun 1, 2009 at 2:35 PM, Tom Lane wrote: > Sava Chankov writes: >> Is there a way to make RETURNING return all view columns? > > Something like > > CREATE RULE _insert AS ON INSERT TO j DO INSTEAD( >  INSERT INTO a (id,name) VALUES (NEW.id, NEW.name); >  INSERT INTO b (id,surname) VALUES (

Re: [GENERAL] INSERT RETURNING rule for joined view

2009-06-01 Thread Tom Lane
Sava Chankov writes: > Is there a way to make RETURNING return all view columns? Something like CREATE RULE _insert AS ON INSERT TO j DO INSTEAD( INSERT INTO a (id,name) VALUES (NEW.id, NEW.name); INSERT INTO b (id,surname) VALUES (NEW.id,NEW.surname) RETURNING id, (SELECT name FROM a WH

[GENERAL] INSERT RETURNING rule for joined view

2009-06-01 Thread Sava Chankov
I have a view that joins several tables and want to create unconditional INSERT RETURNING rule for it. I succeeded by specifying the RETURNING clause for the first INSERT in the rule, casting NULL for columns that are not present in that table to the correct type: CREATE TABLE a (id SERIAL PRIMARY

Re: [GENERAL] INSERT .... RETURNING

2008-11-07 Thread Dennis Brakhane
On Thu, Nov 6, 2008 at 8:49 AM, Rafal Pietrak <[EMAIL PROTECTED]> wrote: > One comment I'd like to make as total lamer on the subject, is that the > assumption on SELECT (that it's not firing triggers), could potentially > be resolved by a *global* or "database" configuration option - once > select

Re: [GENERAL] INSERT .... RETURNING

2008-11-05 Thread Rafal Pietrak
On Wed, 2008-11-05 at 14:38 -0500, Merlin Moncure wrote: [] > > > >> It's more complicated than it looks (triggers). > > > > Could you give me pointers where I could get some more information on [] > matter, the system has several not-easily-removed assumptions that a > SELECT command won

Re: [GENERAL] INSERT .... RETURNING

2008-11-05 Thread Merlin Moncure
On Wed, Nov 5, 2008 at 11:20 AM, Rafal Pietrak <[EMAIL PROTECTED]> wrote: > Hi, > > On Wed, 2008-11-05 at 10:34 -0500, Merlin Moncure wrote: >> On Wed, Nov 5, 2008 at 2:41 AM, Rafal Pietrak <[EMAIL PROTECTED]> wrote: >> > Hi Everybody, > [...] >> > I've just upgraded to v8.3.4 ... since eventually

Re: [GENERAL] INSERT .... RETURNING

2008-11-05 Thread Rafal Pietrak
Hi, On Wed, 2008-11-05 at 10:34 -0500, Merlin Moncure wrote: > On Wed, Nov 5, 2008 at 2:41 AM, Rafal Pietrak <[EMAIL PROTECTED]> wrote: > > Hi Everybody, [...] > > I've just upgraded to v8.3.4 ... since eventually it does have > > INSERT ... RETURNING extention to the SQL standard. > > > > The doc

Re: [GENERAL] INSERT .... RETURNING

2008-11-05 Thread Merlin Moncure
On Wed, Nov 5, 2008 at 2:41 AM, Rafal Pietrak <[EMAIL PROTECTED]> wrote: > Hi Everybody, > > Forgive my sarcasm below, but I just *adore* postgres for years, now. I > hope it's all natural with this level of emotions to be deeply hurt when > the object of attraction is (to quote HHTTG by Douglas Ad

[GENERAL] INSERT .... RETURNING

2008-11-05 Thread Rafal Pietrak
Hi Everybody, Forgive my sarcasm below, but I just *adore* postgres for years, now. I hope it's all natural with this level of emotions to be deeply hurt when the object of attraction is (to quote HHTTG by Douglas Adams): " almost, but not quite entirely unlike tea". I've just upgraded to v8

Re: [GENERAL] Insert returning Npgsql

2008-01-06 Thread Hiroshi Saito
Hi. It can be referred to from the page by which we were renewed. http://npgsql.projects.postgresql.org/ I want it to be useful for you. P.S) [EMAIL PROTECTED] is the place of best discussion. Regards, Hiroshi Saito - Original Message - From: "Cesar Alvarez" <[EMAIL PROTECTED]> Go

[GENERAL] Insert returning Npgsql

2008-01-05 Thread Cesar Alvarez
Good day every one . Im trying to make and insert returning with the connector Npgsql, where can i read more about the syntax of the insert string? or how to configure the Npgsql.command class. Regards Cesar Alvarez. begin:vcard fn:Cesar Alvarez n:;Cesar Alvarez title:Web Development Asesor a

Re: [GENERAL] INSERT RETURNING

2007-10-13 Thread CaT
On Sun, Oct 14, 2007 at 12:01:45AM -0600, Cesar Alvarez wrote: > Hello > im working in a proyect in ORACLE 10g and one of the things i like is > using the INSERT RETURNING with the parameters, im not sure that i read > about postgres 8.2 suporting this feature... if its true where can i > read m

[GENERAL] INSERT RETURNING

2007-10-13 Thread Cesar Alvarez
Hello im working in a proyect in ORACLE 10g and one of the things i like is using the INSERT RETURNING with the parameters, im not sure that i read about postgres 8.2 suporting this feature... if its true where can i read more about it. regards Cesar Alvarez. begin:vcard fn:Cesar Alvarez n:;Ce

Re: [GENERAL] INSERT ... RETURNING in v8.2

2007-06-17 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Tom Allison escribió: >> insert into table(string) values(('one'),('two'),('three')) returning >> idx; >> >> I realize that this is an extension to standard SQL but it sure would >> save me a lot. > You are wrong -- you can do it, but it is not an

Re: [GENERAL] INSERT ... RETURNING in v8.2

2007-06-17 Thread Alvaro Herrera
Tom Allison escribió: > Holy Crud! > you mean to tell me I can replace: > > insert into table(string) values(('one'),('two'),('three')); > select idx from table where string in ('one','two','three'); > > with > > insert into table(string) values(('one'),('two'),('three')) returning > idx; >

Re: [GENERAL] INSERT ... RETURNING in v8.2

2007-06-16 Thread PFC
Holy Crud! you mean to tell me I can replace: insert into table(string) values(('one'),('two'),('three')); select idx from table where string in ('one','two','three'); Yes. A smart ORM library should, when you create a new database object from form values, use INSERT RETURNING to

Re: [GENERAL] INSERT ... RETURNING in v8.2

2007-06-16 Thread Tom Allison
On Jun 12, 2007, at 11:40 AM, Vincenzo Romano wrote: On Tuesday 12 June 2007 16:35:05 Martijn van Oosterhout wrote: On Tue, Jun 12, 2007 at 04:18:32PM +0200, Vincenzo Romano wrote: Well, at least on v8.2.4 I cannot return count(*), that is the number of lines actually inserted into the table

Re: [GENERAL] INSERT ... RETURNING in v8.2

2007-06-16 Thread Tom Allison
On Jun 12, 2007, at 10:18 AM, Vincenzo Romano wrote: Hi all. I'm trying to use this wonderful feature (thanks to anyone who suggested/committed/implemented it). According to the documentation: (http://www.postgresql.org/docs/8.2/interactive/sql-insert.html) "The optional RETURNING clause cau

Re: [GENERAL] INSERT ... RETURNING in v8.2

2007-06-12 Thread Vincenzo Romano
On Tuesday 12 June 2007 18:26:35 Tom Lane wrote: > Vincenzo Romano <[EMAIL PROTECTED]> writes: > > Second, I'm not using nested statements, but rather a plain > > INSERT ... RETURNING COUNT(*) INTO var (it's inside a PL/PgSQL > > function body). It should not need any GROUP BY as the query is > > p

Re: [GENERAL] INSERT ... RETURNING in v8.2

2007-06-12 Thread Tom Lane
Vincenzo Romano <[EMAIL PROTECTED]> writes: > Second, I'm not using nested statements, but rather a plain > INSERT ... RETURNING COUNT(*) INTO var (it's inside a PL/PgSQL > function body). It should not need any GROUP BY as the query is > plain. > Maybe the solution is somewhere in between what yo

Re: [GENERAL] INSERT ... RETURNING in v8.2

2007-06-12 Thread Tom Lane
Vincenzo Romano <[EMAIL PROTECTED]> writes: > Well, at least on v8.2.4 I cannot return count(*), that is the > number of lines actually inserted into the table. Nor I can return > any aggregate function of them. > Am I doing anything wrong or is there some missing sentence in the > documentation?

Re: [GENERAL] INSERT ... RETURNING in v8.2

2007-06-12 Thread Vincenzo Romano
On Tuesday 12 June 2007 16:35:05 Martijn van Oosterhout wrote: > On Tue, Jun 12, 2007 at 04:18:32PM +0200, Vincenzo Romano wrote: > > Well, at least on v8.2.4 I cannot return count(*), that is the > > number of lines actually inserted into the table. Nor I can > > return any aggregate function of t

Re: [GENERAL] INSERT ... RETURNING in v8.2

2007-06-12 Thread Martijn van Oosterhout
On Tue, Jun 12, 2007 at 04:18:32PM +0200, Vincenzo Romano wrote: > Well, at least on v8.2.4 I cannot return count(*), that is the > number of lines actually inserted into the table. Nor I can return > any aggregate function of them. I don't think anybody considered the possibility of using an aggr

[GENERAL] INSERT ... RETURNING in v8.2

2007-06-12 Thread Vincenzo Romano
Hi all. I'm trying to use this wonderful feature (thanks to anyone who suggested/committed/implemented it). According to the documentation: (http://www.postgresql.org/docs/8.2/interactive/sql-insert.html) "The optional RETURNING clause causes INSERT to compute and return value(s) based on each ro

[GENERAL] INSERT..RETURNING on a partitioned table

2007-04-11 Thread Leon Mergen
Hello, I'm attempting to convert a big table into smaller tables; I currently do a lot of INSERT .. RETURNING calls on the big table, which works perfectly. To convert the table into smaller tables, I have set up a test case of 3 tables, based on a 'CHECK ( hashtext(field) % 2 ) = -1' (or 0 or 1

[GENERAL] INSERT..RETURNING on a partitioned table

2007-04-11 Thread Leon Mergen
Hello, I'm attempting to convert a big table into smaller tables; I currently do a lot of INSERT .. RETURNING calls on the big table, which works perfectly. To convert the table into smaller tables, I have set up a test case of 3 tables, based on a 'CHECK ( hashtext(field) % 2 ) = -1' (or 0 or 1

[GENERAL] INSERT..RETURNING on partitioned table

2007-04-11 Thread Leon Mergen
Hello, I'm attempting to convert a big table into smaller tables; I currently do a lot of INSERT .. RETURNING calls on the big table, which works perfectly. To convert the table into smaller tables, I have set up a test case of 3 tables, based on a 'CHECK ( hashtext(field) % 2 ) = -1' (or 0 or 1

Re: [GENERAL] INSERT ... RETURNING as Oracle

2001-03-06 Thread Jean-Christophe Boggio
Just wanted to add that PHP has a GETLASTOID function that will work (after an insert) even if you don't use sequences/serials. -- Jean-Christophe Boggio [EMAIL PROTECTED] Independant Consultant and Developer Delphi, Linux, Perl, PostgreSQL ---(end of broadcast)---

RE: [GENERAL] INSERT ... RETURNING as Oracle

2001-03-04 Thread Michael Ansley
Title: RE: [GENERAL] INSERT ... RETURNING as Oracle And using MAX is also horrifically slow once you start having any significant volumes of data. Why not write a function to add the info, which selects from a sequence, inserts the new row using the sequence number, and then returns the

Re: [GENERAL] INSERT ... RETURNING as Oracle

2001-03-04 Thread Oliver Elphick
"Sipos Andras" wrote: >create table basket ( > id serial NOT NULL PRIMARY KEY, > timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP >); > >How can I make a one step insert into the table and get values of 'ID' ? >I am trying to find a similar solution as in the oracle's INSE

Re: [GENERAL] INSERT ... RETURNING as Oracle

2001-03-04 Thread Peter Eisentraut
Sipos Andras writes: > create table basket ( > id serial NOT NULL PRIMARY KEY, > timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP > ); > > How can I make a one step insert into the table and get values of 'ID' ? > I am trying to find a similar solution as in the oracle's INSERT ...

[GENERAL] INSERT ... RETURNING as Oracle

2001-03-04 Thread Sipos Andras
Hi, Sample table: create table basket ( id serial NOT NULL PRIMARY KEY, timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ); How can I make a one step insert into the table and get values of 'ID' ? I am trying to find a similar solution as in the oracle's INSERT ... RETURNING. If