Skip site navigation (1) Skip section navigation (2)

Re: Type conversion

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ice Planet <ice(at)adiemus(dot)sk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Type conversion
Date: 2000-06-20 19:48:45
Message-ID: 1728.961530525@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-sql
Ice Planet <ice(at)adiemus(dot)sk> writes:
> B: insert into t2 values (select int2(int4(b)) from t1 where a = 1)

Works for me when spelled correctly:

regression=# insert into t2 (select int2(int4(b)) from t1 where a = 1);
INSERT 314647 1

If you make a suitable conversion function then you can omit the
explicit conversion:

regression=# create function int2(int8) returns int2 as
regression-# 'begin return int2(int4($1)); end;' language 'plpgsql';
CREATE
regression=# insert into t2 (select b from t1 where a = 1);
INSERT 314649 1

			regards, tom lane

In response to

Responses

pgsql-sql by date

Next:From: Ed LoehrDate: 2000-06-20 20:05:34
Subject: Re: Type conversion
Previous:From: Ice PlanetDate: 2000-06-20 19:24:48
Subject: Type conversion

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group