Reputation: 1689
I have just started learning postgresql, i want to send a c# object as a parameter for the function(storedprocedure) of postgresql.
i.e. assume that i have a class named userdetails with fields like username,password,DOB etc,
how can i directly send this object to the function and retrieve each field from the object before inserting into the respective columns of the desired table?
Upvotes: 1
Views: 1067
Reputation: 51559
this is example of function taking json as argument:
create or replace function works_with_json(_j IN json) returns boolean as
$$
declare
begin
raise info '%', 'a = "'||(_j->>'a')||'"';
raise info '%', 'b = "'||(_j->>'b')||'"';
return _j->>'c';
end;
$$ language plpgsql;
select works_with_json ('{"a":"Some string","b":9, "c": true}');
Upvotes: 1