- SQL code
create or replace procedure sp_test1(DWMC in VARCHAR2, LX in VARCHAR2)ISv_sql VARCHAR2(1000);begin v_sql := 'select * from test_table where dwmc:='+DWMC+' and lx:='+LX+''; execute immediate v_sql;end sp_test1;
我这样写的有问题,据说要游标还要包什么的,为什么?
谁给我写一下,最好加注释让我明白为什么这样写!
------解决方案--------------------
- SQL code
--声明包头CREATE OR REPLACE PACKAGE PACK_TESTAS --这个是游标 TYPE TESTCUR IS REF CURSOR;--这个是过程 PROCEDURE sp_test1(DWMC in VARCHAR2, LX in VARCHAR2,P_CUR OUT TESTCUR); END PACK_TEST; --声明包体CREATE OR REPLACE PACKAGE BODY PACK_TESTASPROCEDURE sp_test1(DWMC in VARCHAR2, LX in VARCHAR2,P_CUR OUT TESTCUR) isstrsql varchar2(1000);beginstrsql:='select * from test_table where dwmc='':dwmc'' and lx='':lx''';open p_cur for strsql using dwdc,lx;--上一句的:及这一句为绑定变量end sp_test1; end PACK_TEST;
------解决方案--------------------
------解决方案--------------------