I have to create a table with some user defined types and insert data.
I tried this way.
- create type type1 as (i int);
- create function mycast(int) returns type1 as 'select $1;' language 'sql';
- create cast (int as type1) with function mycast(int) as implicit;
- create table table_type(t type1);
- insert into table_type values(1::type1);
Now the values are getting inserted but wrapped in parenthesis, like this
select * from table_type;
t
--------
(1)
(1 rows)
I believe there might be an error in my function. Can someone help. I wanted basically a function that returns the same output as my input (without any () ).
Thanks.