Update serial column
Posted in 2009
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
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.
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
> From: c320sky@gmail.com
> Subject: Update serial column
> Date: Fri, 4 Sep 2009 18:44:43 +0000
> To: informix-list@iiug.org
>
>
> 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.
> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1
On Sep 4, 11:44 am, loc <c320...@gmail.com> wrote:
> 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.
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=-
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=-