current function in SQL insert statement
Posted in 1999
Topics: General Discussion
Hi, thanks for taking the time to look at my
question.
Anyone know if there's any way to insert a row in
Informix with a field having the value of the
current datetime +/- an offset (interval) of time?
I've successfuly inserted using the CURRENT
keyword, example:
insert into foo values (bar, current, dude);but attempting any math on CURRENT gave me an
error. I've also successfully updated a row while
performing mathematical calculations on CURRENT,
example:
update foo set bar = current + interval (1:20)hours to minutes;
but this doesn't seem to work in an insert
statement. I could insert a row and then update
it, but that would be pretty inefficient.
Thanks alot.
-Matt
Sent via Deja.com http://www.deja.com/
Before you buy.
In article <7t13m5$m3$1@nnrp1.deja.com>,
Fat Matt <eyeofthestorm2@hotmail.com> wrote:
> Hi, thanks for taking the time to look at my
> question.
>
> Anyone know if there's any way to insert a row in
> Informix with a field having the value of the
> current datetime +/- an offset (interval) of time?
>
> I've successfuly inserted using the CURRENT
> keyword, example:
> insert into foo values (bar, current, dude);> but attempting any math on CURRENT gave me an
> error. I've also successfully updated a row while
> performing mathematical calculations on CURRENT,
> example:
> update foo set bar = current + interval (1:20)> hours to minutes;
> but this doesn't seem to work in an insert
Yes, in values part of insert statement you can't
use expressions. Only some limited number of functions
like CURRENT, USER, etc. that are not really functions.
You can use either
insert into foo execute procedure ins_foo();
write procedure ins_foo() returning whatever you need or
insert into foo
select "bar",
current + interval (1:20) hour to minute,
"dude"
from systables
where tabid = 1;
HTH
Vardan
> statement. I could insert a row and then update
> it, but that would be pretty inefficient.
> Thanks alot.
> -Matt
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
--
--
Vardan Aroustamian
vaar@geocities.com
Sent via Deja.com http://www.deja.com/
Before you buy.