Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Interfaces Odbc > Re: wrong value...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 2374 of 2418
Post > Topic >>

Re: wrong value returned?

by FredP@[EMAIL PROTECTED] ("Fred Parkinson") Jun 11, 2008 at 09:28 AM

This doesn't explain the error, but solves the problem for me: use a query
=
like
SELECT Max(registration_id) AS MaxID FROM registrations;

Another solution, if you are using a sequenced serial value, is to use the
=
'last_value' function on the sequencing table:
select registration_registration__seq.last_value  from
registration_registr=
ation__seq;


>>> <mike.gagnon@[EMAIL PROTECTED]
> 06/11/2008 7:04 AM >>>
Hi,

I've setup a query in my program to get the biggest value used in my
"custo=
mers" table.  There is a serial column called customer_id.  I use the
follo=
wing query within my program and it returns, lets say, 3.  If I run the
sam=
e query from the psql console window (over and over and at the same point
w=
here I've stepped to in my program), it will consistently return 2 whereas
=
the program will consistently return 3 (always one more).

Here is the query to get the last ID used:
SELECT customer_id from customers order by customer_id DESC limit 1;

I do one fetch and have my result programmatically which is always 1 more
t=
han the value returned by the psql console window method.  What gives?

Many thanks,
Mike

--=20
Sent via pgsql-odbc mailing list (pgsql-odbc@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc=20



--=20
Sent via pgsql-odbc mailing list (pgsql-odbc@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
 




 2 Posts in Topic:
wrong value returned?
mike.gagnon@[EMAIL PROTEC  2008-06-11 10:04:22 
Re: wrong value returned?
FredP@[EMAIL PROTECTED]   2008-06-11 09:28:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 10:14:53 CDT 2008.