I have the following table called as test_type
which contains two columns namely cola
and colb
.
Table: test_type
create table test_type
(
cola int,
colb varchar(50)
);
Now I want to create a type with same columns.
Type: type1
create type type1 as
(
cola int,
colb varchar(50)
);
Here I have created function in which I am passing type name type1
to insert the data to the
table test_type
.
--Creating Function
create or replace function fun_test ( p_Type type1 )
returns void
as
$$
begin
insert into test_type(cola,colb)
select cola,colb from p_type
EXCEPT
select cola,colb from test_type;
end
$$
language plpgsql;
---Calling Function
SELECT fun_test(1,'Xyz');
Error Details:
ERROR: function fun_test(integer, unknown) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 8