in postgres
- as an SQL command
executeruns a prepared statement - from within a procedure
executeruns a dynamic command.
can prepared statements be called from within a procedure?
per Frank below, part of code to insert a user into an arbitrary schema:
execute 'insert into '||v_schema||'.usr( login, email, name, role, pwd )
values( $1, $2, $3, $4, md5($5) )
returning usr_id'
into v_usr_id
using p_login, p_email, p_name, v_role, p_pwd;
notes:
- INTO clause before USING clause
- no parens around USING “args”
Use EXECUTE in combination with USING (available since version 8.4):