pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Selecting Current value from a sequence
9+ messages / 5 participants
[nested] [flat]

* Selecting Current value from a sequence
@ 2001-01-19 17:59 Najm Hashmi <najm@mondo-live.com>
  2001-01-18 18:05 ` Re: Selecting Current value from a sequence Josh Berkus <josh@agliodbs.com>
  2001-01-18 18:18 ` Re: Selecting Current value from a sequence George Moga <george@cicnet.ro>
  2001-01-18 18:23 ` Re: Selecting Current value from a sequence Bruce Momjian <pgman@candle.pha.pa.us>
  2001-01-18 18:37 ` Re: Selecting Current value from a sequence clayton cottingham <drfrog@smartt.com>
  0 siblings, 4 replies; 9+ messages in thread

From: Najm Hashmi @ 2001-01-19 17:59 UTC (permalink / raw)
  To: pgsql-sql

Hi all,
 It is a very simple but I am not able to recall  how to do it.... I
just need to find out the  current value of a seq. It is very simple
select statement but I can't recall it... Help me please before I get
myself get fired -:).
Regards, Najm




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Selecting Current value from a sequence
  2001-01-19 17:59 Selecting Current value from a sequence Najm Hashmi <najm@mondo-live.com>
@ 2001-01-18 18:05 ` Josh Berkus <josh@agliodbs.com>
  2001-01-18 18:50   ` Re: Selecting Current value from a sequence Bruce Momjian <pgman@candle.pha.pa.us>
  3 siblings, 1 reply; 9+ messages in thread

From: Josh Berkus @ 2001-01-18 18:05 UTC (permalink / raw)
  To: pgsql-sql

Najm

	CURRVAL('sequence_name')

	For this and other sequence and serial functions, please see the online
version of Bruce's book.

	BTW, O'Reilly's "SQL in at Nutshell" also catalogs all PGSQL functions
from ver. 6.5.

					-Josh Berkus
-- 
______AGLIO DATABASE SOLUTIONS___________________________
                                        Josh Berkus
   Complete information technology      josh@agliodbs.com
    and data management solutions       (415) 436-9166
   for law firms, small businesses       fax  436-0137
    and non-profit organizations.       pager 338-4078
                        		San Francisco



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Selecting Current value from a sequence
  2001-01-19 17:59 Selecting Current value from a sequence Najm Hashmi <najm@mondo-live.com>
  2001-01-18 18:05 ` Re: Selecting Current value from a sequence Josh Berkus <josh@agliodbs.com>
@ 2001-01-18 18:50   ` Bruce Momjian <pgman@candle.pha.pa.us>
  2001-01-18 19:11     ` Re: Selecting Current value from a sequence Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Bruce Momjian @ 2001-01-18 18:50 UTC (permalink / raw)
  To: josh@agliodbs.com; +Cc: pgsql-sql

> Najm
> 
> 	CURRVAL('sequence_name')
> 
> 	For this and other sequence and serial functions, please see the online
> version of Bruce's book.
> 
> 	BTW, O'Reilly's "SQL in at Nutshell" also catalogs all PGSQL functions
> from ver. 6.5.

It does, or only the standard SQL functions?  Do they have
PostgreSQL-specific stuff.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Selecting Current value from a sequence
  2001-01-19 17:59 Selecting Current value from a sequence Najm Hashmi <najm@mondo-live.com>
  2001-01-18 18:05 ` Re: Selecting Current value from a sequence Josh Berkus <josh@agliodbs.com>
  2001-01-18 18:50   ` Re: Selecting Current value from a sequence Bruce Momjian <pgman@candle.pha.pa.us>
@ 2001-01-18 19:11     ` Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Josh Berkus @ 2001-01-18 19:11 UTC (permalink / raw)
  To: pgsql-sql

Bruce,

> >       BTW, O'Reilly's "SQL in at Nutshell" also catalogs all PGSQL functions
> > from ver. 6.5.
> 
> It does, or only the standard SQL functions?  Do they have
> PostgreSQL-specific stuff.

Both.  The book is set up to cover 1) the SQL99 standard, and 2)
Specific variants for SQL Server, MySQL, Oracle and PostgreSQL.

Unfortunately, the book was somewhat delayed in publication ( + 4 months
past list) so that it is a little out of date.  Pgsql 6.5 is covered
without any notation on what will change/be added in 7.x.  Still, since
I don't even *have* your book yet, it's better than nothing! :-)

					-Josh Berkus

-- 
______AGLIO DATABASE SOLUTIONS___________________________
                                        Josh Berkus
   Complete information technology      josh@agliodbs.com
    and data management solutions       (415) 436-9166
   for law firms, small businesses       fax  436-0137
    and non-profit organizations.       pager 338-4078
                        		San Francisco



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Selecting Current value from a sequence
  2001-01-19 17:59 Selecting Current value from a sequence Najm Hashmi <najm@mondo-live.com>
@ 2001-01-18 18:18 ` George Moga <george@cicnet.ro>
  2001-01-19 19:29   ` Re: Selecting Current value from a sequence Najm Hashmi <najm@mondo-live.com>
  3 siblings, 1 reply; 9+ messages in thread

From: George Moga @ 2001-01-18 18:18 UTC (permalink / raw)
  To: Najm Hashmi <najm@mondo-live.com>; pgsql-sql

Najm Hashmi wrote:

> Hi all,
>  It is a very simple but I am not able to recall  how to do it.... I
> just need to find out the  current value of a seq. It is very simple
> select statement but I can't recall it... Help me please before I get
> myself get fired -:).
>

Try:

SELECT last_value FROM sequence_name;


> Regards, Najm

For me works (PostgreSQL 7.0.3, Mandrake Linux 7.2).

George Moga,
    Data Systems Srl
    Slobozia, ROMANIA





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Selecting Current value from a sequence
  2001-01-19 17:59 Selecting Current value from a sequence Najm Hashmi <najm@mondo-live.com>
  2001-01-18 18:18 ` Re: Selecting Current value from a sequence George Moga <george@cicnet.ro>
@ 2001-01-19 19:29   ` Najm Hashmi <najm@mondo-live.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Najm Hashmi @ 2001-01-19 19:29 UTC (permalink / raw)
  To: George Moga <george@cicnet.ro>; +Cc: pgsql-sql

Thank you all for  your help.
Najm




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Selecting Current value from a sequence
  2001-01-19 17:59 Selecting Current value from a sequence Najm Hashmi <najm@mondo-live.com>
@ 2001-01-18 18:23 ` Bruce Momjian <pgman@candle.pha.pa.us>
  3 siblings, 0 replies; 9+ messages in thread

From: Bruce Momjian @ 2001-01-18 18:23 UTC (permalink / raw)
  To: Najm Hashmi <najm@mondo-live.com>; +Cc: pgsql-sql

See my book on sequences:

	http://www.postgresql.org/docs/awbook.html

currval() is probably what you need.

> Hi all,
>  It is a very simple but I am not able to recall  how to do it.... I
> just need to find out the  current value of a seq. It is very simple
> select statement but I can't recall it... Help me please before I get
> myself get fired -:).
> Regards, Najm
> 
> 


-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Selecting Current value from a sequence
  2001-01-19 17:59 Selecting Current value from a sequence Najm Hashmi <najm@mondo-live.com>
@ 2001-01-18 18:37 ` clayton cottingham <drfrog@smartt.com>
  2001-01-18 19:29   ` Re: Selecting Current value from a sequence Josh Berkus <josh@agliodbs.com>
  3 siblings, 1 reply; 9+ messages in thread

From: clayton cottingham @ 2001-01-18 18:37 UTC (permalink / raw)
  To: Najm Hashmi <najm@mondo-live.com>; +Cc: pgsql-sql

Najm Hashmi wrote:
> 
> Hi all,
>  It is a very simple but I am not able to recall  how to do it.... I
> just need to find out the  current value of a seq. It is very simple
> select statement but I can't recall it... Help me please before I get
> myself get fired -:).
> Regards, Najm


select nextval('nameofseq');



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Selecting Current value from a sequence
  2001-01-19 17:59 Selecting Current value from a sequence Najm Hashmi <najm@mondo-live.com>
  2001-01-18 18:37 ` Re: Selecting Current value from a sequence clayton cottingham <drfrog@smartt.com>
@ 2001-01-18 19:29   ` Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Josh Berkus @ 2001-01-18 19:29 UTC (permalink / raw)
  To: clayton cottingham <drfrog@smartt.com>; +Cc: Najm Hashmi <najm@mondo-live.com>; pgsql-sql

Clayton,

> > Hi all,
> >  It is a very simple but I am not able to recall  how to do it.... I
> > just need to find out the  current value of a seq. It is very simple
> > select statement but I can't recall it... Help me please before I get
> > myself get fired -:).
> > Regards, Najm
> 
> select nextval('nameofseq');

Sorry, no.  You want SELECT CURRVAL('sequence_name').  NEXTVAL select
the NEXT value, and increments the sequence in the process.

-Josh Berkus

-- 
______AGLIO DATABASE SOLUTIONS___________________________
                                        Josh Berkus
   Complete information technology      josh@agliodbs.com
    and data management solutions       (415) 436-9166
   for law firms, small businesses       fax  436-0137
    and non-profit organizations.       pager 338-4078
                        		San Francisco



^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2001-01-19 19:29 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-19 17:59 Selecting Current value from a sequence Najm Hashmi <najm@mondo-live.com>
2001-01-18 18:05 ` Josh Berkus <josh@agliodbs.com>
2001-01-18 18:50   ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-01-18 19:11     ` Josh Berkus <josh@agliodbs.com>
2001-01-18 18:18 ` George Moga <george@cicnet.ro>
2001-01-19 19:29   ` Najm Hashmi <najm@mondo-live.com>
2001-01-18 18:23 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-01-18 18:37 ` clayton cottingham <drfrog@smartt.com>
2001-01-18 19:29   ` Josh Berkus <josh@agliodbs.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox