How to return argument data type from sql function

Поиск
Список
Период
Сортировка
От Andrus
Тема How to return argument data type from sql function
Дата
Msg-id 86fe1ce7-3d6f-b723-b0fc-0eb796100588@hot.ee
обсуждение исходный текст
Ответы Re: How to return argument data type from sql function  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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.

В списке pgsql-general по дате отправления:

Предыдущее
От: Erik Wienhold
Дата:
Сообщение: Re: Exponentiation confusion
Следующее
От: gzh
Дата:
Сообщение: Re:Re: Re: Does psqlodbc_11_01_0000-x64 support special characters?