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
Demonstrate your knowledge of PL/SQL programming by writing and thoroughly testing triggers and stored procedures associated with an e-commerce application that provides security l

what is the use of declare keyword

Why Use Cursor Variables ? Primarily, you use the cursor variables to pass the query result sets between the PL/SQL stored subprograms and different clients. Neither PL/SQL nor

Advantages of Exceptions Using the exceptions for the error handling has many benefits. Without an exception handling, every time you issue a command, you should ensure for th

Keyword & Parameter Description: boolean_expression: This is an expression which yields the Boolean value that is TRUE, FALSE, & NULL. character_expression: This

Identifiers You use identifiers to name the PL/SQL program items and units that include constants, variables, cursors, exceptions, cursor variables, subprograms, and packages.

Effects of NULL for union - SQL The treatment of NULL in invocations of EXCEPT is as for UNION. This is different from its treatment in those of NOT IN and quantified compari

At times, customers make mistakes in submitting their orders and call to cancel the order. Brewbean’s wants to create a trigger that automatically updates the stock level of all pr

EXECUTE Privilege To call an invoker-rights routine straightforwardly, the users should have the EXECUTE privilege on that routine. By yielding the privilege, you permit a user

Variable Declaration - SQL SQL's support for variables is very similar to Tutorial D's, except that the syntax for creating persistent  variables-base tables-is quite differen