PostgreSQL currval()

2001-04-25 Thread K Old

Hello all,

I'm trying to do the following insert statement and can't seem to get it to 
work:

INSERT INTO domains (dname, user, pass) VALUES('currval('cust_seq')', bob, 
something);

I am getting the error that says it that cust_seq.currval is not defined.  I 
do have cust_seq defined as a Sequence and am wondering how to reference a 
sequence variable in an insert statement.

Any ideas?

Thanks,
Kevin
_
Get your FREE download of MSN Explorer at http://explorer.msn.com




Re: PostgreSQL currval()

2001-04-25 Thread Jeff Waugh

From doc/postgres/sql-createsequence.htm:

After a sequence is created, you may use the function nextval(seqname) to
get a new number from the sequence. The function
currval('seqname') may be used to determine the number returned by the last
call to nextval(seqname) for the specified sequence in the
current session.

Your error sounds like nextval has not been called yet in the current
session.

HTH,
-Jeff

- Original Message -
From: K Old [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, April 25, 2001 11:30 AM
Subject: PostgreSQL currval()


 Hello all,

 I'm trying to do the following insert statement and can't seem to get it
to
 work:

 INSERT INTO domains (dname, user, pass) VALUES('currval('cust_seq')', bob,
 something);

 I am getting the error that says it that cust_seq.currval is not defined.
I
 do have cust_seq defined as a Sequence and am wondering how to reference a
 sequence variable in an insert statement.

 Any ideas?

 Thanks,
 Kevin