PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 26th, 2008, 04:29 PM
saikk saikk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 17 saikk Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 59 m 6 sec
Reputation Power: 0
'CALL IDENTITY()' in postgres?

"CALL IDENTITY();" is an sql statement that is used to retrieve
the last value inserted into any IDENTITY column in HSQL.

I read that SERIAL in postgres is the same as IDENTITY in hsql.

Is there any sql statement in postgres that performs the same way as "CALL IDENTITY();" in hsql?

Thanks a bunch.

Reply With Quote
  #2  
Old March 26th, 2008, 05:47 PM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 971 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 44 m 25 sec
Reputation Power: 57
A serial column has a sequence "attached" to it.
SELECT lastval() or SELECT currval('sequence_name') should do what you want.

Reply With Quote
  #3  
Old March 26th, 2008, 06:37 PM
saikk saikk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 17 saikk Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 59 m 6 sec
Reputation Power: 0
'CALL IDENTITY()' in postgres?

But, if no values have been generated by the sequence yet in the current session, currval yields an error!

So, instead, can I use pg_get_serial_sequence(table_name, column_name) ?

Thanks.

Reply With Quote
  #4  
Old March 27th, 2008, 03:51 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,711 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 6 Days 4 h 53 m 59 sec
Reputation Power: 259
If you are trying to retrieve the identity value generated in an insert query to reuse you might want to look at insert ... returning

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > 'CALL IDENTITY()' in postgres?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway