Absrtact: The development of dynamic SQL program is summarized, and some development techniques are given according to the author's actual development experience.
Key words: Dynamic Sql,pl/sql, high performance
1. static sqlsql and dyn
If you use Oracle8i or a later version, you can simply use executeimmediatesql_str in the process. SQL _str is a patchwork SQL statement,
If you are using Oracle 8i or a later version, it is simple to use execute immediate SQL _str in the process. SQL _str is a patchwork
Oracle dynamic SQL statements are easy to use, but the assembly process is too annoying. Especially when the date field is involved in the Assembly Statement, the to_char must be added during the Assembly to convert it to a character first.
Oracle dynamic
I believe everyone knows about the Oracle stored procedure. The following describes how to use dynamic SQL in the Oracle stored procedure. I hope this will help you.
There are two ways to use dynamic SQL for
the rownum condition, that is, the first 5 data in the physical location, and then sorts the data according to the order by field, rather than the first sort, and then the number of specific records we expect.There are typically three different types of dynamic SQL methods that are executed:
Use the Execute IMMEDIATE statement.In addition to not being able to handle multiline query statement
If you are using Oracle 8i or a later version, it is simple. execute immediate SQL _str is used in the process. SQL _str is a patchwork SQL statement, but this dynamic statement contains parameters, or when the Select result is into the variable, you have to pay attention to
When using ODP.. Net for Oracle programming, sometimes the SQL statements are very complex and need to be dynamically constructed query statements. There are two ways to construct dynamic SQL statements and execute the returned result set.
1. Construct SQL statements at th
Dynamic SQL syntax
Only when running can Oracle check whether its format is correct
The INTO and USING clauses are optional.
If the SQL statement is a query statement, we can use the INTO clause.
The INTO statement is used to receive the record value selected by the SELECT statement. It can be a variable sequence or a
Oracle dynamic SQL can be written in two ways: dbms_ SQL or execute immediate. The latter is recommended. The test procedure is as follows:
1. DDL and DML/*** DDL ***/BeginExecute immediate 'drop table temp_1 ';Execute immediate 'create table temp_1 (name varchar2 (8 ))';End;/*** DML ***/DeclareV_1 varchar2 (8 );V_2
Oracle Database Programming: dynamic SQL: it is a string at compile time, and it is only found to be an SQL statement at run time. When SQL statements cannot be used directly, dynamic SQL
Tags: sdn col Procedure declare a NAT varchar field BSP Local dynamic SQL First we should understand what dynamic SQL is, the SQL that we use in the Oracle database Development PL BLOCK Divided into: Static
;
-- Remember to close the opened cursor. Unless you return a cursor as the output parameter or function value of the stored procedureClose v_cur;O_n_ret: = 0;Exception when others thenRaise;End;/
Create or replace procedure P_VARCHAR2_LST_DYMANTIC (I _name varchar2, -- input parameter, the string contained in the name to be queriedO_t_varchar out t_varchar, -- output parameter, which is a defined variable-length varchar2 array.O_n_ret out number -- output parameter. If it ends normally, 0 is ou
Summary
The 4th method of dynamic SQL uses Sqlda (the SQL Descriptor area) and Oracle to Exchange data to perform SQL statements that do not know the number and type of select table entries or virtual input host variables until the program is run.
Module Oracle's data
How Does Oracle view the execution plan of an SQL statement based on the dynamic performance view?
How Does Oracle view the execution plan of an SQL statement based on the dynamic performance view?
1. Authorize a user to view
Dynamic SQL syntaxOnly at run time can Oracle check whether its format is correct. The INTO and USING clauses are optional. If the SQL statement is a query statement, we can use the INTO clause INTO statement to receive the record value selected by the SELECT statement. It can be a variable sequence or a record-type va
Oracle dynamic SQL
The syntax for executing dynamic SQL statements is:
Excute immediate dynamic SQL statement using binding parameter list returning into output parameter list
Test T
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.