pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
convert text to varchar
4+ messages / 3 participants
[nested] [flat]

* convert text to varchar
@ 1999-05-03 15:33  JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
  0 siblings, 1 reply; 4+ messages in thread

From: JT Kirkpatrick @ 1999-05-03 15:33 UTC (permalink / raw)
  To: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>

hi!  i have a text field (table ap3, field name apnote) that i would like 
to insert into a varchar field (same field name, table name ap).  any idea 
why this doesn't work?  insert into ap (apnote) select varchar('apnote') 
from ap3; -- it fails with or without the single quotes.

TIA, jt



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

* RE: [SQL] convert text to varchar
@ 1999-05-03 15:34  Michael J Davis <michael.j.davis@tvguide.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael J Davis @ 1999-05-03 15:34 UTC (permalink / raw)
  To: 'JT Kirkpatrick' <jt-kirkpatrick@mpsllc.com>; 'pgsql-sql@hub.org' <pgsql-sql@hub.org>

try:
	insert into ap (apnote) select apnote::varchar from ap3;

> -----Original Message-----
> From:	JT Kirkpatrick [SMTP:jt-kirkpatrick@mpsllc.com]
> Sent:	Monday, May 03, 1999 9:33 AM
> To:	'pgsql-sql@hub.org'
> Subject:	[SQL] convert text to varchar
> 
> hi!  i have a text field (table ap3, field name apnote) that i would like 
> to insert into a varchar field (same field name, table name ap).  any idea
> 
> why this doesn't work?  insert into ap (apnote) select varchar('apnote') 
> from ap3; -- it fails with or without the single quotes.
> 
> TIA, jt



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

* Re: [SQL] convert text to varchar
@ 1999-05-03 16:02  Herouth Maoz <herouth@oumail.openu.ac.il>
  parent: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Herouth Maoz @ 1999-05-03 16:02 UTC (permalink / raw)
  To: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>; 'pgsql-sql@hub.org' <pgsql-sql@hub.org>

At 18:33 +0300 on 03/05/1999, JT Kirkpatrick wrote:


> hi!  i have a text field (table ap3, field name apnote) that i would like
> to insert into a varchar field (same field name, table name ap).  any idea
> why this doesn't work?  insert into ap (apnote) select varchar('apnote')
> from ap3; -- it fails with or without the single quotes.

Should be simply

INSERT INTO ap (apnote)
SELECT ap3.apnote
FROM ap3;

You really shouldn't have single quotes, and the conversion to text is
supposed to be automatic.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





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

* RE: [SQL] convert text to varchar
@ 1999-05-03 17:38  JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
  0 siblings, 0 replies; 4+ messages in thread

From: JT Kirkpatrick @ 1999-05-03 17:38 UTC (permalink / raw)
  To: 'Herouth Maoz' <herouth@oumail.openu.ac.il>; +Cc: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>

it tells me that the types aren't the same if i do this.  well, now that i 
typed that i tried it again, and it worked. . .  the first time i tried it, 
(the two tables have the same field names and types with the exception of 
this one field), i typed [insert into ap select * from ap3;] -- and it said 
that the types were not the same.  but just now i typed [insert into ap (. 
. .all field names listed individually. . .) select {all field names listed 
individually in the same order} from ap3], and it worked.  must be some 
limitation in the "select *" use. . .

thanks very much!  oh by the way, i haven't seen a camel in at least 12 
years either! (except on that perl book -- or is that a llama?).  i briefly 
looked at that site you recommended -- i think i could spend a while their 
later.

-----Original Message-----
From:	Herouth Maoz [SMTP:herouth@oumail.openu.ac.il]
Sent:	Monday, May 03, 1999 12:02 PM
To:	JT Kirkpatrick; 'pgsql-sql@hub.org'
Subject:	Re: [SQL] convert text to varchar

At 18:33 +0300 on 03/05/1999, JT Kirkpatrick wrote:


> hi!  i have a text field (table ap3, field name apnote) that i would like
> to insert into a varchar field (same field name, table name ap).  any 
idea
> why this doesn't work?  insert into ap (apnote) select varchar('apnote')
> from ap3; -- it fails with or without the single quotes.

Should be simply

INSERT INTO ap (apnote)
SELECT ap3.apnote
FROM ap3;

You really shouldn't have single quotes, and the conversion to text is
supposed to be automatic.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma



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


end of thread, other threads:[~1999-05-03 17:38 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-05-03 15:33 convert text to varchar JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
1999-05-03 16:02 ` Herouth Maoz <herouth@oumail.openu.ac.il>
1999-05-03 15:34 RE: [SQL] convert text to varchar Michael J Davis <michael.j.davis@tvguide.com>
1999-05-03 17:38 RE: [SQL] convert text to varchar JT Kirkpatrick <jt-kirkpatrick@mpsllc.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