-
Notifications
You must be signed in to change notification settings - Fork 0
/
createtransaction.sql
41 lines (40 loc) · 1.1 KB
/
createtransaction.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
CREATE OR REPLACE FUNCTION network.createtransaction(taskid numeric, uname text, ucomment text, uapplication text)
RETURNS numeric
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
transid numeric(12,0);
BEGIN
INSERT INTO ige_transaction(trans_id,
task_id,
source_id,
username,
date_start,
date_end,
application_code,
trans_desc,
trans_name,
trans_status)
VALUES (nextval('ige_transaction_id_seq')::numeric(12,0),
$1,
null, --BATCH_SOURCE_ID,
$2,
now(),
null,
$4,
null,
null,
'OPEN')
RETURNING trans_id INTO transid;
UPDATE ige_transaction
SET trans_name = transid::text,
trans_desc = $3 --BATCH_TRANS_DESC
WHERE trans_id = transid;
RETURN transid;
EXCEPTION
WHEN OTHERS THEN
RAISE NOTICE '%', SQLERRM;
RETURN -1;
END;
$BODY$;
ALTER FUNCTION network.createtransaction(numeric,text, text,text) OWNER TO network;