473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Serial type currval

I am wondering if it's possible to retrieve the current value of a
serial type field without using the name of the corresponding sequence?
I know that currval function takes the sequence name as a parameter, but
I would like to use the name of the serial field instead. Is this
possible?
Thanks.

Oleg

*************************************

This e-mail may contain privileged or confidential material intended for the named recipient only.
If you are not the named recipient, delete this message and all attachments.
Unauthorized reviewing, copying, printing, disclosing, or otherwise using information in this e-mail is prohibited.
We reserve the right to monitor e-mail sent through our network.

*************************************

Nov 11 '05 #1
2 3691
On Friday 12 September 2003 17:09, Oleg Lebedev wrote:
I am wondering if it's possible to retrieve the current value of a
serial type field without using the name of the corresponding sequence?
I know that currval function takes the sequence name as a parameter, but
I would like to use the name of the serial field instead. Is this
possible?
Thanks.


Well as it happens, a table "foo" with a serial field "bar" will have a
sequence called "foo_bar_seq" - so you can figure it out from the field name.
I don't know if this is *guaranteed* to always be that way, but it's been
that way for a while, and I can't see the developers changing it in a hurry.

Be careful if the name gets too long and gets trimmed.
--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #2
On Friday 12 September 2003 17:09, Oleg Lebedev wrote:
I am wondering if it's possible to retrieve the current value of a
serial type field without using the name of the corresponding sequence?
I know that currval function takes the sequence name as a parameter, but
I would like to use the name of the serial field instead. Is this
possible?
Thanks.


Well as it happens, a table "foo" with a serial field "bar" will have a
sequence called "foo_bar_seq" - so you can figure it out from the field name.
I don't know if this is *guaranteed* to always be that way, but it's been
that way for a while, and I can't see the developers changing it in a hurry.

Be careful if the name gets too long and gets trimmed.
--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: t_pet422 | last post by:
Hi, I've got a table in PostgreSql 7.3.2 that has a serial column as a primary key. I want to insert data into the table (inserting values for everything EXCEPT the serial column) and at the...
2
by: mgarriss | last post by:
Given this table: CREATE TABLE test ( id SERIAL, example TEXT ); An implicit sequence is created as show in this message: NOTICE: CREATE TABLE will create implicit sequence 'test_id_seq'...
0
by: Oleg Lebedev | last post by:
I am wondering if it's possible to retrieve the current value of a serial type field without using the name of the corresponding sequence? I know that currval function takes the sequence name as a...
3
by: Suchandra Thapa | last post by:
I was wondering if there was a reliable method to get the last id inserted into a serial column in a table. I believe previous recommendations given were to use a sequence, have your app get the...
9
by: Brandon Craig Rhodes | last post by:
I have a large table (named "changes") which is perfectly willing to support index lookups when its primary key (named "change") is compared to a constant integer: # explain select * from...
4
by: Milos Prudek | last post by:
I have a serial autoincrement column called "idmember" in my main table (members). This serial column is a key to a second table. A row in "members" table corresponds to many rows in the second...
12
by: Prabu Subroto | last post by:
Dear my friends... I am using postgres 7.4 and SuSE 9.1. I want to use auto_increment as on MySQL. I look up the documentation on www.postgres.com and I found "serial" . But I don't know...
15
by: Robby Russell | last post by:
I am trying to track down a method of determining what a sequence name is for a SERIAL is in postgresql. For example, CREATE TABLE foo (id SERIAL PRIMARY KEY NOT NULL, bar TEXT); \d foo...
2
by: Paul Sijben | last post by:
To automate/ease configuration in my app I am trying to find out to which serial port a certain bluetooth device is connected. With pybluez I can find out which bluetooth devices I have, but it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.