Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Update serial column

618 views
Skip to first unread message

loc

unread,
Sep 4, 2009, 2:44:43 PM9/4/09
to

Informix SE 7.25.UC6R1
Informix C4GL 7.32.UC4


I know that you can not do an update on a serial column and if you try
you get an error, but why don't you get an error with the following syntax?

define l_a_table record like a_table.*

initialize l_a_table.* to null

update a_table set * = l_a_table.*
where a_table.link = l_a_table.link


In this example a_table.link is a serial column does the update statement
ignore the serial column when using the syntax 'set *'? I'm just
wondering if it is safe to do it this way or if I should list
all the columns except the serial in the update.

Ian Michael Gumby

unread,
Sep 4, 2009, 3:20:31 PM9/4/09
to c32...@gmail.com, inform...@iiug.org
Well....

Never tried to update a serial column but ...
You can insert in to a serial column as long as the value you are inserting isn't in use.
Going from memory, if you insert using a value of 0, the database will use the next available serial number.

So, I would imagine if you can insert in to the row, you should be able to update the row including the serial field as long as the new value isn't already in use. IE if your table has a record with a serial value of 5, if you try to update another record using 5 in the serial field, you'd get an error.

HTH
> _______________________________________________
> Informix-list mailing list
> Inform...@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list


Get back to school stuff for them and cashback for you. Try Bing now.

Jonathan Leffler

unread,
Sep 5, 2009, 4:44:13 AM9/5/09
to

Because the I4GL compiler (which must be what is being used - the
'l_a_table.*' notation gives that away) carefully modifies the
statement and removes the serial column from the list. You could see
this if you compile the source with the '-keep' option to the c4gl
script, and then inspect the file.ec or file.c file that is left
behind.

-=JL=-

Jonathan Leffler

unread,
Sep 5, 2009, 4:46:21 AM9/5/09
to
On Sep 4, 12:20 pm, Ian Michael Gumby <im_gu...@hotmail.com> wrote:
> Never tried to update a serial column but ...
> You can insert in to a serial column as long as the value you are inserting isn't in use.
> Going from memory, if you insert using a value of 0, the database will use the next available serial number.

Correct so far.

> So, I would imagine if you can insert in to the row, you should be able to update the row including the serial field as long as the new value isn't already in use. IE if your table has a record with a serial value of 5, if you try to update another record using 5 in the serial field, you'd get an error.


You cannot update a SERIAL (or SERIAL8, or BIGSERIAL) column. Period.
IDS does not allow you to do so; neither does SE (which only has
SERIAL and not the other two types).

-=JL=-

0 new messages