Hi,

I'm trying to create a varchar(float8) to cast float to varchar but I
can't create it.
I can create bpchar(foat8) and text(float8) and it works well but
varchar(float8).

EXAPLE:

create table test(f float, n name);
CREATE
insert into test values(1.23, current_user);
INSERT 192042 1
select cast(f as text) from test;
text
-------------------------
2000-01-01 01:00:01.23+01   <----this is wrong then I create
text(float8)
(1 row)

select cast(f as char) from test;
ERROR:  No such function 'bpchar' with the specified attributes
select cast(f as varchar) from test;
ERROR:  No such function 'varchar' with the specified attributes
create function text(float8) returns text as
'begin
        return $1;
end;' language 'plpgsql';
CREATE
create function bpchar(float8) returns bpchar as
'begin
        return $1;
end;' language 'plpgsql';
CREATE
create function varchar(float8) returns varchar as
'begin
        return $1;
end;' language 'plpgsql';
ERROR:  parser: parse error at or near "varchar"  <---there's a parser
error.
select cast(f as text) from test;
text
----
1.23    <------and now it works
(1 row)

select cast(f as char) from test;
bpchar
------
  1.23
(1 row)

----I see there are some varchar built-in functions but I can't use them
also...

\df varchar
result |function       |arguments     |description
-------+---------------+--------------+---------------------
bool   |varchareq      |varchar varcha|equal
bool   |varcharge      |varchar varcha|greater-than-or-equal
bool   |varchargt      |varchar varcha|greater-than
bool   |varcharle      |varchar varcha|less-than-or-equal
bool   |varcharlt      |varchar varcha|less-than
bool   |varcharne      |varchar varcha|not equal
int4   |varcharcmp     |varchar varcha|less-equal-greater
int4   |varcharlen     |varchar       |character length
int4   |varcharoctetlen|varchar       |octet length
varchar|varchar        |name          |convert
varchar|varchar        |varchar int4  |
(11 rows)

select varchar(n) from test;
ERROR:  parser: parse error at or near "n"


--Any ideas ?

-Jose'-



Hi,
I'm trying to create a varchar(float8) to cast float to varchar
but I can't create it.
I can create bpchar(foat8) and text(float8) and it works well but
varchar(float8).
EXAPLE:
create table test(f float, n name);
CREATE
insert into test values(1.23, current_user);
INSERT 192042 1
select cast(f as text) from test;
text
-------------------------
2000-01-01 01:00:01.23+01   <----this is wrong then
I create text(float8)
(1 row)
select cast(f as char) from test;
ERROR:  No such function 'bpchar' with the specified attributes
select cast(f as varchar) from test;
ERROR:  No such function 'varchar' with the specified attributes
create function text(float8) returns text as
'begin
        return $1;
end;' language 'plpgsql';
CREATE
create function bpchar(float8) returns bpchar as
'begin
        return $1;
end;' language 'plpgsql';
CREATE
create function varchar(float8) returns varchar as
'begin
        return $1;
end;' language 'plpgsql';
ERROR:  parser: parse error at or near "varchar"  <---there's
a parser error.
select cast(f as text) from test;
text
----
1.23    <------and now it works
(1 row)
select cast(f as char) from test;
bpchar
------
  1.23
(1 row)
----I see there are some varchar built-in functions but I can't
use them also...
\df varchar
result |function       |arguments    
|description
-------+---------------+--------------+---------------------
bool   |varchareq      |varchar
varcha|equal
bool   |varcharge      |varchar
varcha|greater-than-or-equal
bool   |varchargt      |varchar
varcha|greater-than
bool   |varcharle      |varchar
varcha|less-than-or-equal
bool   |varcharlt      |varchar
varcha|less-than
bool   |varcharne      |varchar
varcha|not equal
int4   |varcharcmp     |varchar varcha|less-equal-greater
int4   |varcharlen     |varchar      
|character length
int4   |varcharoctetlen|varchar      
|octet length
varchar|varchar        |name         
|convert
varchar|varchar        |varchar
int4  |
(11 rows)
select varchar(n) from test;
ERROR:  parser: parse error at or near "n"
 
--Any ideas ?
-Jose'-
Wed, 17 Feb 1999 13:00:50 +0100
"jose' soares" <sferac@bo.nettuno.it>
varchar function
> I'm trying to create a varchar(float8) to cast float to varchar but I
> can't create it.
> --Any ideas ?

>From the current development tree (I'm pretty sure; may not have
committed everything yet):

postgres=> select varchar('123'::float8);
ERROR:  parser: parse error at or near "'"
postgres=> select varchar(float8 '123');
ERROR:  parser: parse error at or near "float8"
postgres=> select (float8 '123')::varchar;
?column?
--------
     123
(1 row)

It seems that there are some problems with calls to functions named
varchar().

                         - Tom

Thu, 18 Feb 1999 03:16:57 +0000
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Re: [HACKERS] varchar function