From: | Andrus <kobruleht2(at)hot(dot)ee> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | How to return argument data type from sql function |
Date: | 2022-10-13 20:16:09 |
Message-ID: | 86fe1ce7-3d6f-b723-b0fc-0eb796100588@hot.ee |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
PostgreSQL 12.2+ function is defined as
create FUNCTION torus(eevarus text) returns text immutable AS $f$
select translate( $1, U&'\00f8\00e9', U&'\0451\0439' );
$f$ LANGUAGE SQL ;
This function is called as CHAR(n) or text columns like
create temp table test (
charcol char(10),
textcol text );
insert into test values ('test', 'test');
select torus(charcol), torus(textcol), charcol
torus(charcol) returns text column and loses original column width. How
to force torus() to return argument type:
if char(n) column is passed as argument, torus() should also return
char(n) data type.
I tried to use bpchar instead on text
create or replace FUNCTION torusbpchar(eevarus bpchar) returns
bpchar immutable AS $f$
select translate( $1, U&'\00f8\00e9', U&'\0451\0439' );
$f$ LANGUAGE SQL ;
torusbpchar(charcol) still returns text data type.
npgsql DataReader is used to get data.
Andrus.
From | Date | Subject | |
---|---|---|---|
Next Message | gzh | 2022-10-14 05:43:52 | Re:Re: Re: Does psqlodbc_11_01_0000-x64 support special characters? |
Previous Message | Erik Wienhold | 2022-10-13 20:07:33 | Re: Exponentiation confusion |