automatic value conversion

Поиск
Список
Период
Сортировка
От Sebastian Boehm
Тема automatic value conversion
Дата
Msg-id C35DBBFA-7318-48B1-9FF6-0EF328ED9EDD@seb.exse.net
обсуждение исходный текст
Ответы Re: automatic value conversion  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi,

currently I do this:

INSERT INTO table1 (row1) VALUES ( function_in('argument1','myvalue'))
and
select function_out('argument1',row1) from table1; (which gives
'myvalue' again)

funtion_out(text,int) returns text
funtion_in(text,text) returns int

the table looks like this:

create table table1
(
    row1 integer;
)



instead of the select and insert statements above I want to do this:


INSERT INTO table1 (row1) VALUES ( 'myvalue' )
and
select row1 from table1; (which gives 'myvalue' again, but in reality
some integer is stored in the database)


the functions function_in and function_out should be called
automatically on select or insert / update.

How can I change the table definition to use function_in and
function_out transparently for me (as if the table had a text colum)

(remember function_in and function_out convert von int to text and
have an addional fixed text argument)


Thank you very much for your Help !!


Sebastian

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Lifecycle of PostgreSQL releases
Следующее
От: Tom Lane
Дата:
Сообщение: Re: automatic value conversion