automatic value conversion - Mailing list pgsql-general

From Sebastian Boehm
Subject automatic value conversion
Date
Msg-id C35DBBFA-7318-48B1-9FF6-0EF328ED9EDD@seb.exse.net
Whole thread Raw
Responses Re: automatic value conversion
List 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 by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Lifecycle of PostgreSQL releases
Next
From: Tom Lane
Date:
Subject: Re: automatic value conversion