PostgreSQL OID Column on INSERT
Hershel Fisch
hershrev at realtorsgroup.us
Tue Sep 28 17:23:27 EDT 2004
On Tuesday, September 28, 2004, at 05:23 PM, Frank D. Engel, Jr. wrote:
> Thank you, looks good.
>
> After playing with it, though, do the INSERT first, then check currval
> to determine what number was assigned automatically.
You must do an INSERT first in order for it to get the number for that
connection , other wise which id would it pick .
Hershel
>
> That should work!
>
> On Sep 28, 2004, at 4:01 PM, Hershel Fisch wrote:
>
>>
>> On Tuesday, September 28, 2004, at 03:38 PM, Frank D. Engel, Jr.
>> wrote:
>>
>>> A while back I stumbled on a prior thread with this same question,
>>> but I never did see a resolution to the root question.
>>>
>>> When PostgreSQL performs an INSERT, it returns a unique OID number
>>> for the inserted row. Is there any way to retrieve the OID value
>>> returned by the INSERT statement from RevDB?
>>>
>>> In my case, the other values, even in combination, are not
>>> guaranteed unique -- except one, which is autogenerated by the
>>> database (a SERIAL number), so there is no other way for me to be
>>> certain of grabbing the exact record I just inserted, something I
>>> need to be able to do.
>> In order to have a unique u need to create the table like this,
>> "CREATE TABLE table1 ( pk SERIAL, fld1 TYPE (???))" , the pk column
>> will produce a unique serial number. now if you use
>> (currval('tableName_fldName_seq')) it will give you your current
>> serial number or your connection.
>>
>> put revDataFromQuery(,,connectionId,"SELECT currval
>> ('table1_fld1_pk_seq')")
>>
>> revdb_execute(connectionId,"INSERT INTO table1 (or into any table)
>> (fk,fld1,fld2,) VALUES (currval
>> ('tableName_fieldName_seq'),'fld1','fld2')")
>>
>> Hershel Fisch
>>>
>>> Thank you!
>>>
>>> -----------------------------------------------------------
>>> Frank D. Engel, Jr. <fde101 at fjrhome.net>
>>>
>>> $ ln -s /usr/share/kjvbible /usr/manual
>>> $ true | cat /usr/manual | grep "John 3:16"
>>> John 3:16 For God so loved the world, that he gave his only begotten
>>> Son, that whosoever believeth in him should not perish, but have
>>> everlasting life.
>>> $
>>>
>>>
>>> ___________________________________________________________
>>> $0 Web Hosting with up to 120MB web space, 1000 MB Transfer
>>> 10 Personalized POP and Web E-mail Accounts, and much more.
>>> Signup at www.doteasy.com
>>>
>>> _______________________________________________
>>> use-revolution mailing list
>>> use-revolution at lists.runrev.com
>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>>
> -----------------------------------------------------------
> Frank D. Engel, Jr. <fde101 at fjrhome.net>
>
> $ ln -s /usr/share/kjvbible /usr/manual
> $ true | cat /usr/manual | grep "John 3:16"
> John 3:16 For God so loved the world, that he gave his only begotten
> Son, that whosoever believeth in him should not perish, but have
> everlasting life.
> $
>
>
>
> ___________________________________________________________
> $0 Web Hosting with up to 120MB web space, 1000 MB Transfer
> 10 Personalized POP and Web E-mail Accounts, and much more.
> Signup at www.doteasy.com
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list