|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
'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. |
|
#2
|
|||
|
|||
|
A serial column has a sequence "attached" to it.
SELECT lastval() or SELECT currval('sequence_name') should do what you want. |
|
#3
|
|||
|
|||
|
'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. |
|
#4
|
||||
|
||||
|
If you are trying to retrieve the identity value generated in an insert query to reuse you might want to look at insert ... returning
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
![]() |
| Viewing: Dev Shed Forums > Databases > PostgreSQL Help > 'CALL IDENTITY()' in postgres? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|