2017. 2. 13. 12:01ㆍMeteor
https://docs.oracle.com/cd/B12037_01/appdev.101/b10807/11_dynam.htm#i13130
http://highheat.tistory.com/588
Using the EXECUTE IMMEDIATE Statement
The EXECUTE
IMMEDIATE
statement prepares (parses) and immediately executes a dynamic SQL statement or an anonymous PL/SQL block.
The main argument to EXECUTE IMMEDIATE
is the string containing the SQL statement to execute. You can build up the string using concatenation, or use a predefined string.
Except for multi-row queries, the dynamic string can contain any SQL statement (without the final semicolon) or any PL/SQL block (with the final semicolon). The string can also contain placeholders, arbitrary names preceded by a colon, for bind arguments. In this case, you specify which PL/SQL variables correspond to the placeholders with the INTO
, USING
, and RETURNING INTO
clauses.
You can only use placeholders in places where you can substitute variables in the SQL statement, such as conditional tests in WHERE
clauses. You cannot use placeholders for the names of schema objects. For the right way, see "Passing Schema Object Names As Parameters".
Used only for single-row queries, the INTO
clause specifies the variables or record into which column values are retrieved. For each value retrieved by the query, there must be a corresponding, type-compatible variable or field in the INTO
clause.
Used only for DML statements that have a RETURNING
clause (without a BULK
COLLECT
clause), the RETURNING
INTO
clause specifies the variables into which column values are returned. For each value returned by the DML statement, there must be a corresponding, type-compatible variable in the RETURNING
INTO
clause.
You can place all bind arguments in the USING
clause. The default parameter mode is IN
. For DML statements that have a RETURNING
clause, you can place OUT
arguments in the RETURNING
INTO
clause without specifying the parameter mode. If you use both the USING
clause and the RETURNING
INTO
clause, the USING
clause can contain only IN
arguments.
At run time, bind arguments replace corresponding placeholders in the dynamic string. Every placeholder must be associated with a bind argument in the USING
clause and/or RETURNING
INTO
clause. You can use numeric, character, and string literals as bind arguments, but you cannot use Boolean literals (TRUE
, FALSE
, and NULL
). To pass nulls to the dynamic string, you must use a workaround. See "Passing Nulls to Dynamic SQL".
Dynamic SQL supports all the SQL datatypes. For example, define variables and bind arguments can be collections, LOB
s, instances of an object type, and refs.
As a rule, dynamic SQL does not support PL/SQL-specific types. For example, define variables and bind arguments cannot be Booleans or associative arrays. The only exception is that a PL/SQL record can appear in the INTO
clause.
You can execute a dynamic SQL statement repeatedly using new values for the bind arguments. However, you incur some overhead because EXECUTE
IMMEDIATE
re-prepares the dynamic string before every execution.
'Meteor' 카테고리의 다른 글
Atom Plug-in guide (0) | 2017.02.17 |
---|---|
소스 충돌과 반영 문제 (0) | 2017.02.16 |
oracle 일괄 처리 방식 (0) | 2017.02.13 |
딥러닝 소개하는 일주일짜리 MIT IAP강의! (0) | 2017.02.07 |
오라클 Oracle EXECUTE IMMEDIATE tips (0) | 2017.02.06 |