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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

following successful execution, so their values should only be examined after an error has been detected<br />

by a call to FORM_SUCCESS or FORM_FAILURE.<br />

FORMS_DDL restrictions<br />

The statement you pass to FORMS_DDL may not contain bind variable references in the string, but the<br />

values of bind variables can be concatenated into the string before passing the result to FORMS_DDL.<br />

For example, this statement is not valid:<br />

<strong><strong>Form</strong>s</strong>_DDL (’Begin Update_Employee (:emp.empno); End;’);<br />

However, this statement is valid, and would have the desired effect:<br />

<strong><strong>Form</strong>s</strong>_DDL (’Begin Update_Employee (’||TO_CHAR(:emp.empno)<br />

||’);End;’);<br />

However, you could also call a stored procedure directly, using <strong>Oracle</strong>8’s shared SQL area over multiple<br />

executions with different values for emp.empno:<br />

Update_Employee (:emp.empno);<br />

SQL statements and PL/SQL blocks executed using FORMS_DDL cannot return results to <strong>Form</strong> <strong>Builder</strong><br />

directly. (See Example 4.)<br />

In addition, some DDL operations cannot be performed using FORMS_DDL, such as dropping a table or<br />

database link, if <strong>Form</strong> <strong>Builder</strong> is holding a cursor open against the object being operated upon.<br />

FORMS_DDL examples<br />

Example 1<br />

/*<br />

** Built-in: FORMS_DDL<br />

** Example: The expression can be a string literal.<br />

*/<br />

BEGIN<br />

<strong><strong>Form</strong>s</strong>_DDL(’create table temp(n NUMBER)’);<br />

IF NOT <strong>Form</strong>_Success THEN<br />

Message (’Table Creation Failed’);<br />

ELSE<br />

Message (’Table Created’);<br />

END IF;<br />

END;<br />

Example 2<br />

/*<br />

** Built-in: FORMS_DDL<br />

** Example: The string can be an expression or variable.<br />

** Create a table with n Number columns.<br />

** TEMP(COL1, COL2, ..., COLn).<br />

*/<br />

PROCEDURE Create_N_Column_Number_Table (n NUMBER) IS<br />

my_stmt VARCHAR2(2000);<br />

BEGIN<br />

my_stmt := ’create table tmp(COL1 NUMBER’;<br />

FOR I in 2..N LOOP<br />

my_stmt := my_stmt||’,COL’||TO_CHAR(i)||’ NUMBER’;<br />

END LOOP;<br />

my_stmt := my_stmt||’)’;<br />

/*<br />

** Now, create the table...<br />

151

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

Saved successfully!

Ooh no, something went wrong!