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
Write a cursor to open an employee database and fetch the employee record whose age is greater than 45

Character Types The Character types allow you to store alphanumeric data, represent words and text, and manipulate the character strings. CHAR You use the CHAR dataty

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

%FOUND Subsequent to a cursor or cursor variable is opened but before the first fetch, the %FOUND yields NULL. Afterward, it yields TRUE when the last fetch returned a row, or

Forward Declarations The PL/SQL needs that you declare an identifier before using it. And hence, you should declare a subprogram before calling it. For illustration, the decla

Using SET TRANSACTION You use the SET TRANSACTION statement to begin the read-only or read-write transaction, start an isolation level, or assign your present transaction to a

RETURN Statement The RETURN statement instantly completes the execution of a subprogram and returns control to the caller. The Execution then resumes with the statement below t

How Bulk Binds Improve Performance The assigning of values to the PL/SQL variables in SQL statements is known as binding. The binding of the whole collection at once is know

Parameter and Keyword Description: type_name: This identifies a user-defined type specifier that is used in the subsequent declarations of the objects. AUTHID Clause:

Data Types in SQL SQL's concept does not differ significantly from that defined in the theory book, apart from that business concerning NULL. However, the theory book equates