Dynamic sql - pl sql, PL-SQL Programming

Dynamic SQL:

The Most PL/SQL programs do a predictable, specific job. For illustration, a stored procedure may accept an employee number and salary increase, and then update the sal column in the emp table. In these circumstances, the full text of the UPDATE statement is acknowledged at the compile time. These statements do not change from execution to execution. Therefore, they are known as static SQL statements.

Though, some programs should build and process a variety of the SQL statements at the run time. For illustration, a general-purpose report writer should build various SELECT statements for the various reports it generates. In this situation, the full text of the statement is unknown until the run time. These statements can, and almost certainly will, change from execution to execution. Therefore, they are known as the dynamic SQL statements.

The Dynamic SQL statements are stored in the character strings build by your program at the run time. These strings should contain the text of the valid SQL statement or the PL/SQL block. They can also contain the placeholders for bind arguments. The placeholder is an undeclared identifier, so its name, to which you should prefix a colon, that does not matter. For illustration, the PL/SQL makes no difference between the following strings:

'DELETE FROM emp WHERE sal > :my_sal AND comm < :my_comm'

'DELETE FROM emp WHERE sal > :s AND comm < :c'

To process the most dynamic SQL statements, you can use the EXECUTE IMMEDIATE statement. Though, to process the multi-row query (SELECT statement), you should use the OPEN-FOR, FETCH, and CLOSE statements.

 

Posted Date: 10/6/2012 8:26:16 AM | Location : United States







Related Discussions:- Dynamic sql - pl sql, Assignment Help, Ask Question on Dynamic sql - pl sql, Get Answer, Expert's Help, Dynamic sql - pl sql Discussions

Write discussion on Dynamic sql - pl sql
Your posts are moderated
Related Questions
Subprograms The PL/SQL has two types of subprograms known as the procedures and functions that can take parameters and be invoked. As the following example represents, a subp

COMMIT Statement The COMMIT statement explicitly makes everlasting changes to the database during the present transaction. The Changes made to the database are not considered e

SELECT INTO Statement   The SELECT INTO statement retrieve data from one or more database tables, and then assigns the selected values to the variables or fields. Syntax:

Transaction Control The Oracle is transaction oriented; that is, Oracle uses the transactions to make sure the data integrity. The transaction is a sequence of SQL data manip

The Package Body The package specification is implemented by the package body. That is, the package body has the definition of every cursor and the subprogram declared in the p

Updating a Variable Assignment of an attribute value in a variable of a structured type Synatx: SET SN.C = 'S2'; As in Example the entire statement is equivalent to a

Parameter and Keyword Description: package_name: This construct identifies the package. AUTHID Clause: This determine whether all the packaged subprograms impleme

Scoping Within the similar scope, all the declared identifiers should be unique. So, even if their datatypes differ, the variables and parameters cannot share the similar name.

Object Type: The object type is a user-defined composite datatype which encapsulates a data structure along with the functions and procedures required to manipulate the data

UNION without CORRESPONDING - SQL The use of UNION without CORRESPONDING. Example is merely by omitting CORRESPONDING, but only because the operands have identical SELECT clau