1

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?

2
  • if you want to pass json to function as argument, just do it?.. Commented Jun 14, 2016 at 11:45
  • @vao tsun how do i accomplish that and insert data into respective columns of the table? an example would be great to give me a push in the right direction. Commented Jun 15, 2016 at 5:52

1 Answer 1

1

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}');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.