Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE FUNCTION card_ecm_doc_roles(in_json text)
- RETURNS integer AS
- $BODY$
- #import json
- x=json.loads(in_json)
- if not x.get('data'): raise Exception('Error 1')
- if not x.get('doc_cardid'): raise Exception('Error 2')
- if not x.get('roleid'): raise Exception('Error 3')
- for userid in x ['data']:
- sql="""insert into ecm.doc_bpm_roles (
- doc_cardid,
- roleid,
- userid
- ) values (
- $1,
- $2,
- $3
- ) returning id"""
- pr=plpy.prepare(sql,["integer","integer","integer"])
- result = plpy.execute(pr,[doc_cardid,roleid,userid])
- return 0
- $BODY$
- LANGUAGE plpythonu VOLATILE
- COST 100;
- ALTER FUNCTION ecm.card_ecm_doc_roles(text)
- OWNER TO "user";
Advertisement
Add Comment
Please, Sign In to add comment