Re: Multiple SQL statements & return value
- From: "Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom>
- Date: Thu, 16 Mar 2006 20:08:06 -0000
"Lewis" <Lewis@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CCA3114C-85DA-4065-9217-0F190FC29B08@xxxxxxxxxxxxxxxx
Hello,
I have a somLast_nums table that keeps the last customer number used.
I have this statement which increments the customer number.
It returns the number of rows affected (1).
I need it to return the new customer number. Any ideas? Thanks
UPDATE SomLast_num
SET CUST_NUM = CUST_NUM + 1
WHERE (CurrentRec = 1)
Well you are either going to have to do SELECT into a Recordset or use a
temporary/permanent Stored procedure and return an Output Parameter (that
option is not possible with Access).
So
UPDATE SomLast_num SET CUST_NUM = CUST_NUM + 1 WHERE CurrentRec = 1
SELECT CUST_NUM FROM SomLast_num WHERE CurrentRec = 1
If you are using an adhoc query with a Command object and 1 Output
parameter, somthing like
SELECT ? = (SELECT CUST_NUM FROM SomLast_num WHERE CurrentRec = 1)
should work. The ? will be filled in with the return value and no RecordSet
need be constructed.
Stephen Howe
.
- Prev by Date: Re: SQL 2005 Connection
- Next by Date: Re: Bookmarks with .net
- Previous by thread: SQL 2005 Connection
- Next by thread: Re: Multiple SQL statements & return value
- Index(es):
Relevant Pages
|
|