Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    1

    Unanswered: commit in function

    Hi, Everyone,

    I am new to postgresql.

    i have created 3 functions and am executing all the 3 functions using one single function. right now after finishing the execution of all the 3 functions only i can see the data inserted into the tables. How do i insert data after each function is executed? i want to commit the insertion before it starts executing the next function. How to do it in PostgreSQL?

    thanks in advance

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    You cannot commit inside a function.

    Quote from the manual:
    http://www.postgresql.org/docs/current/static/xfunc-sql.html
    Quote Originally Posted by The fine manual
    You cannot use transaction control commands, e.g. COMMIT, SAVEPOINT, and some utility commands, e.g. VACUUM, in SQL functions.
    And for PL/pgSQL:
    http://www.postgresql.org/docs/current/static/plpgsql-structure.html
    Quote Originally Posted by The fine manual
    Functions and trigger procedures are always executed within a transaction established by an outer query they cannot start or commit that transaction

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •