File: README.execute_block

package info (click to toggle)
firebird3.0 3.0.13.ds7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 42,632 kB
  • sloc: ansic: 374,403; cpp: 319,973; sql: 14,691; pascal: 14,532; yacc: 7,557; fortran: 5,645; sh: 5,336; makefile: 1,041; perl: 194; sed: 83; awk: 76; xml: 19; csh: 15
file content (55 lines) | stat: -rw-r--r-- 1,487 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
SQL Language Extension: EXECUTE BLOCK

Function:
	Allow execute PL-SQL block as if it is stored procedure. 
	Supports input and output parameters

Autor:
	Vlad Khorsun <hvlad at users.sourceforge.net>

Syntax:
	EXECUTE BLOCK [ (param datatype = ?, param datatype = ?, ...) ]
		[ RETURNS (param datatype, param datatype, ...) }
	AS
	[DECLARE VARIABLE var datatype; ...]
	BEGIN
	...
	END

Client-side:
	The call isc_dsql_sql_info with parameter isc_info_sql_stmt_type returns
	- isc_info_sql_stmt_select, if block has output parameters. 
	Semantics of a call is similar to SELECT query - client has open cursor, 
can fetch data from it, and must close it after use.

	- isc_info_sql_stmt_exec_procedure, if block has no output parameters.
	Semantics of a call is similar to EXECUTE query - client has no cursor,
execution runs until first SUSPEND or end of block

	The client should preprocess only head of the SQL statement or use '?' 
instead of ':' as parameter indicator because in a body of the block may be links 
to local variables and \ or parameters with a colon ahead.

Example:
	User SQL is
		EXECUTE BLOCK (X INTEGER = :X) RETURNS (Y VARCHAR)
		AS
		DECLARE V INTEGER;
		BEGIN
		  INSERT INTO T(...) VALUES (... :X ...);

		  SELECT ... FROM T INTO :Y;
		  SUSPEND;
		END
	
	Preprocessed SQL is
		EXECUTE BLOCK (X INTEGER = ?) RETURNS (Y VARCHAR)
		AS
		DECLARE V INTEGER;
		BEGIN
		  INSERT INTO T(...) VALUES (... :X ...);

		  SELECT ... FROM T INTO :Y;
		  SUSPEND;
		END