Q: Does SQR support use of ORACLE PL/SQL blocks and stored functions and procedures?

A: PL/SQL blocks have been supported since version 2.26 within BEGIN-SQL paragraphs. The syntax for PL/SQL statements within SQR is identical to that which is used in both PRO*C and the ORACLE Call Interfaces with the following exception: SQR requires any statment within the PL/SQL block that is normally terminated with a semi-colon (;) to end with two semi-colons (;;). SQR will not attempt to validate PL/SQL syntax. If the PL/SQL block contains errors, ORACLE will respond with the appropriate error message. SQR versions 2.4 and beyond have the capability to run stored procedures in ORACLE version 7. If the following function exists in the database:

   -------------------------- PL/SQL code starts here -----------------------
	create function get_dept_no (dept_name in varchar)
	          return number
	          is
                                 dept_num number;
	          begin
		         select deptno
		         into dept_num
		         from dept
		         where dname = dept_name;
		         return(dept_num);
		         exception
			       when no_data_found then return(0);
	          end;
   -------------------------- PL/SQL code ends here -------------------------

It can be accessed from SQR by running it in a BEGIN-SQL paragraph:

   --------------------------- SQR code starts here -------------------------
	          ...
	          move 'ACCOUNTING' to $dept_name
	          begin-sql
		         begin
			        #dept_number := get_dept_no($dept_name);;
	                     end;;
	          end-sql
                      if #dept_number = 0
		         show 'Department not found'
	          else
		         do upd_emp_sal
	          end-if
	          ...
   --------------------------- SQR code ends here --------------------------