使用Delphi中ADO的控件ADOStoredProc调用MSSQL存储过程proc TestPro @a1 char(1),@a2 char(1) output
as
select @a2='Y'
select * from Table
go用ADOStoredProc在分别调用:
execproc -〉返回值正确,但得不到查询的表
open -〉提示返回值错误如何才能既得到返回值,又能操作查询的表呢
as
select @a2='Y'
select * from Table
go用ADOStoredProc在分别调用:
execproc -〉返回值正确,但得不到查询的表
open -〉提示返回值错误如何才能既得到返回值,又能操作查询的表呢
1.表的创建
-- Create table
create table TEST
(
TEST_ID VARCHAR2(4),
TEST_NAME VARCHAR2(10)
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 64K
minextents 1
maxextents unlimited
pctincrease 50
);
2.创建包
create or replace package pkg_ref_cursor as
TYPE service_cursor is REF CURSOR; --定义游标
PROCEDURE get_service_p(P_id test.test_id%type,o_servicelist OUT
service_cursor);
--说明存储过程
end pkg_ref_cursor;
3.创建包体
create or replace package body pkg_ref_cursor as
PROCEDURE get_service_p(P_id test.test_id%type,o_servicelist OUT
service_cursor)
--把游标定义为OUT,这样就可以返回数据集了
is
begin
open o_servicelist for select test_id,test_name
from test where test_id < p_id;
end;
end pkg_ref_cursor;
:)