| From: | Roger Wernersson <rw(at)mindark(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Sequence value |
| Date: | 2000-12-15 09:41:55 |
| Message-ID: | 3A39E763.62EBB6EE@mindark.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
You could try
INSERT INTO koe (id, name) SELECT nextval('koe_pkey_id'), 'uusi';
or something like that.
/Roger
Esa Pikkarainen wrote:
>
> So, I want to insert new record and get immediately its sequence
> value (serial column) (or OID). I Use iHTML web interface.
> Now I have found out that I can give two queries in iHTML like this:
>
> SQL ="SELECT nextval('koe_pkey_id') as val;
> INSERT INTO koe (id, name) values (val, 'uusi');"
>
> Now there are some problems. The previous example causes an error:
> ERROR: Attribute 'val' not found
> Is there a method how to transmit a value from one query to another?
>
> If I try the examples of FAQ:
> SQL ="$newSerialID = nextval('koe_pkey_id');
> INSERT INTO koe (id, name) values ($newSerialID, 'uusi');"
> Or
> SQL ="INSERT INTO koe (name) values ('uusi');"
> $newSerialID = curr('koe_pkey_id');
>
> I get: ERROR: parser: parse error at or near "$"
>
> And lately (this may be an iHTML problem) if I try:
> SQL ="INSERT INTO koe (name) values ('uusi');
> SELECT currval('koe_pkey_id') as val;"
> It causes no error, but I cannot retrieve the value because the
> queries seem not return any recordsets (nothig can be fetched).
>
> Any hints are valuable!
> Thanks
> Esa Pikkarainen
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alessio Bragadini | 2000-12-15 09:49:12 | Re: Sequence value |
| Previous Message | Joost Kraaijeveld | 2000-12-15 08:08:01 | RE: Working under NT |