CopyPastor

Detecting plagiarism made easy.

Score: 1.7366996751568182; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2018-11-13
by Hemant Kumar

Original Post

Original - Posted on 2013-07-09
by Mike Christensen



            
Present in both answers; Present only in the new answer; Present only in the old answer;

PostgreSQL [doesn't support stored procedures][1], per se, but you can get the same result using a function. For example:
CREATE FUNCTION MyInsert(_sno integer, _eid integer, _sd date, _ed date, _sid integer, _status boolean) RETURNS void AS $BODY$ BEGIN INSERT INTO app_for_leave(sno, eid, sd, ed, sid, status) VALUES(_sno, _eid, _sd, _ed, _sid, _status); END; $BODY$ LANGUAGE 'plpgsql' VOLATILE COST 100;
You can then call it like so:
select * from MyInsert(1,101,'2013-04-04','2013-04-04',2,'f' );
The main limitations on Pg's stored functions - as compared to true stored procedures - are:
1. inability to return multiple result sets 2. no support for autonomous transactions (BEGIN, COMMIT and ROLLBACK within a function) 3. no support for the SQL-standard CALL syntax, though the ODBC and JDBC drivers will translate calls for you.
[Example][2]

[1]: https://wiki.postgresql.org/wiki/FAQ#Does_PostgreSQL_have_stored_procedures.3F [2]: http://sqlfiddle.com/#!12/89188/2
PostgreSQL [didn't support stored procedures][1] until PG11. Prior to that, you could get the same result using a function. For example:
CREATE FUNCTION MyInsert(_sno integer, _eid integer, _sd date, _ed date, _sid integer, _status boolean) RETURNS void AS $BODY$ BEGIN INSERT INTO app_for_leave(sno, eid, sd, ed, sid, status) VALUES(_sno, _eid, _sd, _ed, _sid, _status); END; $BODY$ LANGUAGE 'plpgsql' VOLATILE COST 100;
You can then call it like so:
select * from MyInsert(1,101,'2013-04-04','2013-04-04',2,'f' );
The main limitations on Pg's stored functions - as compared to true stored procedures - are:
1. inability to return multiple result sets 2. no support for autonomous transactions (BEGIN, COMMIT and ROLLBACK within a function) 3. no support for the SQL-standard CALL syntax, though the ODBC and JDBC drivers will translate calls for you.
[Example][2]
Starting from PG11, the `CREATE PROCEDURE` syntax is [introduced][3] which provides support for transactions.
CREATE PROCEDURE MyInsert(_sno integer, _eid integer, _sd date, _ed date, _sid integer, _status boolean) LANGUAGE SQL AS $BODY$ INSERT INTO app_for_leave(sno, eid, sd, ed, sid, status) VALUES(_sno, _eid, _sd, _ed, _sid, _status); $BODY$;
Which could be called with:
CALL MyInsert(1,101,'2013-04-04','2013-04-04',2,'f' );

[1]: https://wiki.postgresql.org/wiki/FAQ#Does_PostgreSQL_have_stored_procedures.3F [2]: http://sqlfiddle.com/#!12/89188/2 [3]: http://www.postgresqltutorial.com/postgresql-create-procedure/

        
Present in both answers; Present only in the new answer; Present only in the old answer;