1 Reply Latest reply on Aug 17, 2012 3:45 PM by gdarling - oracle

    Call Stored procedure with output parameter using VBA

      Hi All,

      I have a stored procedure with output parameter as varchar2. Now i need to call it from Excel VBA.

      Oracle procedure is given below

      create or replace procedure ann_chk(p_in1 varchar2,
      p_in2 varchar2,
      p_out1 out varchar2,
      p_errot1 out varchar2)
      l_cnt number;
      select count(1) into l_cnt from ann_login_chk
      where user_emailid = p_in1 and password = p_in2;
      if(l_cnt = 1) then
      p_out1 := 'Success'
      p_out1 := 'Fail'
      end if;
      when others then
      p_errot1 := sqlerrm;

      Can anyone please tell me, how i can call this procedure using Excel VBA?
        • 1. Re: Call Stored procedure with output parameter using VBA
          gdarling - oracle
          Here's a vbs example I had laying around.
          You can find the constant definitions in C:\Program Files\Common Files\System\ado\adovbs.inc
          'create or replace procedure pass_it_out(v1 in varchar2, v2 out varchar2) as
          'v2 := v1 || ' from stored proc';
          strval = "hello world"
          set con = createobject("adodb.connection")
          con.open "provider=oraoledb.oracle;user id=scott;password=tiger;data source=orcl"
          'con.open "dsn=orcl;uid=scott;pwd=tiger"
          set cmd = CreateObject("adodb.command")
          cmd.CommandText = "pass_it_out"
          cmd.ActiveConnection = con
          Set prminput = cmd.CreateParameter("", 200, 1, Len(strval), strval)
          Set prmoutput = cmd.CreateParameter("", 200,2, 500)
          cmd.Parameters.Append prminput
          cmd.Parameters.Append prmoutput
          wscript.echo prmoutput.value
          ' cleanup ommitted
          Hope it helps,