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;

posted @   delphi中间件  阅读(1587)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2014-03-29 unigui数据库连接池
点击右上角即可分享
微信分享提示