11.01.2013 Views

Oracle Forms Developer – Form Builder Reference, Volume 1

Oracle Forms Developer – Form Builder Reference, Volume 1

Oracle Forms Developer – Form Builder Reference, Volume 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SYSTEM.LAST_QUERY system variable<br />

Syntax<br />

SYSTEM.LAST_QUERY<br />

Description<br />

SYSTEM.LAST_QUERY represents the query SELECT statement that <strong>Form</strong> <strong>Builder</strong> most recently used<br />

to populate a block during the current Runform session. The value is always a character string.<br />

SYSTEM.LAST_QUERY examples<br />

Example 1<br />

Assume that you want to generate a report in Report <strong>Builder</strong> that retrieves information identical to a<br />

query you perform in <strong>Form</strong> <strong>Builder</strong>. The following examples show how to use<br />

SYSTEM.LAST_QUERY to extract the WHERE/ORDER BY clause from the last query so you can<br />

pass the results to Report <strong>Builder</strong> using the RUN_PRODUCT built-in.<br />

FUNCTION Last_Where_Clause<br />

RETURN VARCHAR2<br />

IS<br />

tmp_lstqry VARCHAR2(10000) := :System.Last_Query;<br />

tmp_curblk VARCHAR2(40);<br />

tmp_index NUMBER;<br />

tmp_where VARCHAR2(2000);<br />

BEGIN<br />

/*<br />

** See if we can find the word ’WHERE’ in<br />

** the text of the Last Query<br />

*/<br />

tmp_index:= INSTR(tmp_lstqry,’WHERE’);<br />

/*<br />

** If we found it (at a positive index into<br />

** the string), we extract the remainder of<br />

** the text that follows the word ’WHERE’ as<br />

** the Where clause. This might include ORDER BY<br />

** clause, too.<br />

*/<br />

IF tmp_index > 0 THEN<br />

tmp_where := SUBSTR(tmp_lstqry, tmp_index + 6);<br />

END IF;<br />

RETURN (tmp_where);<br />

EXCEPTION<br />

WHEN OTHERS THEN<br />

RETURN NULL;<br />

END;<br />

Example 2<br />

PROCEDURE Run_Report_For_Last_Query<br />

IS<br />

pl ParamList;<br />

wc VARCHAR2(2000); -- The Where Clause to Pass<br />

BEGIN<br />

/*<br />

393

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!