动态查询,动态生成cursor或者动态执行SQL的DML操作
Jun 07, 2016 pm 05:46 PM定义PROCEDURE P1 ( P_Asset_Type IN varchar2,P_Asset_SubType IN varchar2,P_OrderIds IN varchar2)。
需要根据传入参数动态查询,动态生成cursor或者动态执行SQL的DML操作。
1.简单的查询
SELECT ABC from TableA where ORDER_ID IN ( P_OrderIds) ;
2. 动态生成cursor
定义游标和变量:
type v_cursor is ref cursor;
C1 v_cursor; v_command varchar2(2000);
v_command := ''SELECT ABC from TableA where ORDER_ID IN ( '' ||P_OrderIds|| '' ) '';
OPEN C1 for v_command;
3.动态DML操作
v_command2 := ''UPDATE TableA
SET ASSET_TYPE_CD = ''''''||P_Asset_Type||'''''',''
||''ASSET_SUBTYPE_CD = ''''''||P_Asset_SubType||''''''''
||''WHERE ORDER_ID IN ( ''||P_OrderIds||'' ) '';
execute immediate v_command2;(动态sql)

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution: Your organization requires you to change your PIN

How to adjust window border settings on Windows 11: Change color and size

How to change title bar color on Windows 11?

OOBELANGUAGE Error Problems in Windows 11/10 Repair

How to enable or disable taskbar thumbnail previews on Windows 11

10 Ways to Adjust Brightness on Windows 11

How to turn off private browsing authentication for iPhone in Safari?
