delphi调用oracle存储过程(ODAC)

CREATE OR REPLACE PACKAGE p_lee01
IS
TYPE cur_lee01 IS REF CURSOR;
END;

CREATE OR REPLACE PROCEDURE pro_lee01(in_a IN NUMBER,out_01 OUT NUMBER,cur_01 OUT p_lee01.cur_lee01) IS
BEGIN 
 out_01 := 3;
 OPEN cur_01 FOR 
      SELECT * FROM TLEE01;
 dbms_output.put_line(IN_a);

END;


-- Create table
create table TLEE01
(
  ID    NUMBER,
  FNAME VARCHAR2(10)
)

----------------------------------
ODAC  两种调用方式

procedure TForm1.Button15Click(Sender: TObject);
begin
  orastoredproc1.Params.clear;
  OraStoredProc1.StoredProcName := 'pro_lee01';
  orastoredproc1.PrepareSQL;
  orastoredproc1.ParamByName('in_a').Value := 5;
  orastoredproc1.prepare;
  OraStoredProc1.ExecProc;
  showmessage(OraStoredProc1.ParamByName('out_01').AsString);
  ShowValue(OraStoredProc1, Button8.Caption);
end;


procedure TForm1.Button9Click(Sender: TObject);
var
  s: string;
begin
  s := 'begin pro_lee01(:a,:b,:cur_01 ); end;';
  OraQuery1.SQL.Clear;
  OraQuery1.SQL.Add(s);
  OraQuery1.AutoCommit := false;
  OraQuery1.FetchAll := true;
  OraQuery1.ParamByName('a').value := 4;
  OraQuery1.ParamByName('b').ParamType := ptoutput;
  OraQuery1.ParamByName('b').DataType:= ftinteger;

  OraQuery1.ParamByName('cur_01').ParamType := ptoutput;
  OraQuery1.ParamByName('cur_01').DataType:= ftcursor;
  OraQuery1.Open;

  showmessage(OraQuery1.ParamByName('b').AsString);   //显示返回值
  ShowValue(OraQuery1, Button8.Caption);
end;

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值