db_exec_plsql (public)
db_exec_plsql [ -dbn dbn ] statement_name sql [ -bind bind ]
Defined in packages/acs-tcl/tcl/01-database-procs.tcl
Oracle: Executes a PL/SQL statement, and returns the variable of bind variable
:1
.PostgreSQL: Performs a pl/pgsql function or procedure call. The caller must perform a select query that returns the value of the function.
Examples:
# Oracle: db_exec_plsql delete_note { begin note.del(:note_id); end; } # PostgreSQL: db_exec_plsql delete_note { select note__delete(:note_id); }If you need the return value, then do something like this:
# Oracle: set new_note_id [db_exec_plsql create_note { begin :1 := note.new( owner_id => :user_id, title => :title, body => :body, creation_user => :user_id, creation_ip => :peeraddr, context_id => :package_id ); end; }] # PostgreSQL: set new_note_id [db_exec_plsql create_note { select note__new( null, :user_id, :title, :body, 'note', now(), :user_id, :peeraddr, :package_id ); }]You can call several pl/SQL statements at once, like this:
# Oracle: db_exec_plsql delete_note { begin note.del(:note_id); note.del(:another_note_id); note.del(:yet_another_note_id); end; } # PostgreSQL: db_exec_plsql delete_note { select note__delete(:note_id); select note__delete(:another_note_id); select note__delete(:yet_another_note_id); }If you are using xql files then put the body of the query in ayourfilename-oracle.xql
oryourfilename-postgresql.xql
file, as appropriate. E.g. the first example transformed to use xql files looks like this:
yourfilename.tcl
:
db_exec_plsql delete_note {}
yourfilename-oracle.xql
:
<fullquery name="delete_note"> <querytext> begin note.del(:note_id); end; </querytext> </fullquery>
yourfilename-postgresql.xql
:
<fullquery name="delete_note"> <querytext> select note__delete(:note_id); </querytext> </fullquery>
- Switches:
- -dbn (optional)
- The database name to use. If empty_string, uses the default database.
- -bind (optional)
- Parameters:
- statement_name (required)
- sql (required)
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- db_bind_var_substitution