I have created a function to insert/update record in a table. Data is passed to function as arguments. Facing problem in handling Integer/float/double fields. For example, i have declared Empno field as Int(as per target table structure). So i thought when a null value comes i convert into '0' using cast function. But its not even accepting NULL values since its declared as Int. should i change the declaration to varchar and then convert ? What should i do ? Please help
Error i'm getting is operator does not exist: text integer 42883
Sample CODE:
create function test (text[])
declare
companycode varchar(4);
empno varchar(10);
begin
L_1 := $1[1];
L_2 :=cast(NULLIF($1[2],0) as int);
update and insert statement ...
end;