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
Fetching with a Cursor The FETCH statements retrieve the rows in the result set one at a time. After each and every fetch, the cursor advance to the next row in the result set

a. Write an anonymous block that contains a PL/SQL function. Given an order number orderNo, the function will calculate the total number of the parts in the order. Then the anonym

Using a Join on 2 tables, select all columns and all rows from the tables without the use of a Cartesian product. Query: SELECT * FROM EMPLOYEE1 JOIN CONTRACT ON EMPLOYEE

Use of Table Expressions - Expressing Constraint Conditions With the exception of key constraints, the examples in the theory book all explicitly reference at least one relvar

Controlling Cursor Variables You use 3 statements to control the cursor variable: OPEN-FOR, FETCH, & CLOSE. At First, you OPEN a cursor variable FOR a multi-row query. Then, y

Parameter Aliasing   To optimize the subprogram call, the PL/SQL compiler can decide between the two techniques of the parameter passing. With the by-value techniques, the v

Role of Abstraction in pl/sql: The abstraction is a high-level description or model of a real-world entity. The Abstractions keep our daily lives convenient. They help us ca

i NEED TO CREATE 3 guiS IN pl/sql sERVER PAGE FORM

Multiset types - SQL An SQL multiset is what in mathematics is also known as a bag-something like a set except that the same element can appear more than once. The body of an

Grouping and Ungrouping in SQL Example specifying EXAM_MARK in place of COURSE in the main FROM clause. Example: Obtaining C_ER2 from EXAM_MARK SELECT CourseId, CAST