New topic: 

Insert into with generator in PostgreSQL

<http://forums.realsoftware.com/viewtopic.php?t=46495>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        Grant          Post subject: Insert into with generator in 
PostgreSQLPosted: Wed Jan 09, 2013 1:26 am                         
Joined: Sun Jan 22, 2006 2:37 am
Posts: 323                Hi,

I have a generator in PostgreSQL that I call each time I need a new rowid for 
my table.

However in this case I want to do an insert in the table with select that will 
generate multiple records to be inserted in the one query, so I need the 
generator to fire for each one of those records so they all have unique ids. 

My generator is called by:

SELECT nextval('mytable_rowid')

So in the query I was trying to use as the find criteria:

SELECT
 (SELECT nextval('mytable_rowid')),
 region,
FROM
 mytable
WHERE
 invoice IS NULL

But I just get the same row id for each of the 20 or so found records. Is there 
a way of doing this so I get a unique id for each record thats going to be 
inserted from the generator?

Grant   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to