nextval::text

Started by John Smithabout 23 years ago4 messagesgeneral
Jump to latest
#1John Smith
john_smith_45678@yahoo.com

I was just wondering why in the generated schema nextval is cast to text rather than int?

John

CREATE TABLE x (
id integer DEFAULT nextval('"x_id_seq"'::text) NOT NULL,
name character varying(30) NOT NULL
);

---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: John Smith (#1)
Re: nextval::text

On Tue, Mar 04, 2003 at 10:54:34PM -0800, John Smith wrote:

I was just wondering why in the generated schema nextval is cast to text rather than int?

I think you're misreading. It's the string being passed to nextval that is
being cast to text, not the return value.

John

CREATE TABLE x (
id integer DEFAULT nextval('"x_id_seq"'::text) NOT NULL,
name character varying(30) NOT NULL
);

---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more

--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

Support bacteria! They're the only culture some people have.

#3Dennis Gearon
gearond@cvc.net
In reply to: John Smith (#1)
Re: nextval::text

Because that's the name of the sequence, not the value coming out of the sequence.

3/4/2003 10:54:34 PM, John Smith <john_smith_45678@yahoo.com> wrote:

Show quoted text

Date: Tue, 4 Mar 2003 22:54:34 -0800 (PST)

From: John Smith <john_smith_45678@yahoo.com>
Subject:[GENERAL] nextval::text
To: pgsql-general@postgresql.org

I was just wondering why in the generated schema nextval is cast to text
rather than int?

John

CREATE TABLE x (
id integer DEFAULT nextval('"x_id_seq"'::text) NOT NULL,
name character varying(30) NOT NULL
);

Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more

#4Bruce Momjian
bruce@momjian.us
In reply to: Dennis Gearon (#3)
Re: nextval::text

Of course, a bigger question is why the ::text cast is needed at all.

---------------------------------------------------------------------------

Dennis Gearon wrote:

Because that's the name of the sequence, not the value coming out of the sequence.

3/4/2003 10:54:34 PM, John Smith <john_smith_45678@yahoo.com> wrote:

Date: Tue, 4 Mar 2003 22:54:34 -0800 (PST)

From: John Smith <john_smith_45678@yahoo.com>
Subject:[GENERAL] nextval::text
To: pgsql-general@postgresql.org

I was just wondering why in the generated schema nextval is cast to text
rather than int?

John

CREATE TABLE x (
id integer DEFAULT nextval('"x_id_seq"'::text) NOT NULL,
name character varying(30) NOT NULL
);

Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073