🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #2116

Stored Procedures and Oracle

#2116
From: Dennis Boy
Date: Fri, 07 Nov 2003 11:01
68 lines
2775 bytes
Hello All!

I'm having a problem using the ADOStoredProc component together with
an Oracle database. My goal is to execute a stored procedure in the
Oracle database, which should return a number to my Borland C++
application.

The stored procedure looks like this:

FUNCTION get_mod_id(
  barcode IN varchar2 )
  RETURN number IS
    model_name varchar2(10);
    model_id        number(20);
  begin
    api_derivat.get_derivation('MODEL',barcode,model_name);
    select id
      into model_id
      from models
      where name = model_name;
    return model_id;
  exception
   when no_data_found then
     raise_application_error(-20000,'PLS-00601');
  end;


My test application uses the following code snippets:

  ADOConnection1->Connected = true;

  long lModId;
  TParameter *P1, *P2;
  P1 = NULL;
  P2 = NULL;

  ADOStoredProc1->Parameters->Clear();
  P1 = ADOStoredProc1->Parameters->AddParameter();
  P1->Name = "barcode";
  P1->DataType = ftString;
  P1->Value = "WM44AZB942796EWIZ";
 
  P2 = ADOStoredProc1->Parameters->AddParameter();
  P2->Name = "model_id";
  P2->DataType = ftInteger;
  P2->Value = 0;

  ADOStoredProc1->ExecProc();
  lModId = StrToInt(ADOStoredProc1->Parameters->Items[1]->Value);

  delete P1;
  delete P2;
  ShowMessage(lModId);


When I try to run the application it terminates at the call ExecProc()
with the message:
"Project Testapp.exe raised exception class EOleException with message
'ORA-06550: line 1, column 7: PLS-00306: wrong number or types of
arguments in call 'GET_MOD_ID' ORA-06550: line 1, column 7: PL/SQL:
Statement ignored'. Process stopped. Use Step or Run to continue."

The database is delivered by our costumer, so I can't change the
stored procedure. However I am quite confident, that the stored
procedure works.

Any ideas on what I am doing wrong in my applicaton code? Any help
will be greatly appreciated!
Technical Details
Message-ID: <7309ca61.0311070301.29702299@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews2.google.com!postnews1.google.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,63a9219ab7b41265,start
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2003-11-07 03:01:54 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews2.google.com!postnews1.google.com!not-for-mail
From: dennisboy1978@hotmail.com (Dennis Boy)
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Stored Procedures and Oracle
Date: 7 Nov 2003 03:01:53 -0800
Organization: http://groups.google.com
Lines: 68
Message-ID: <7309ca61.0311070301.29702299@posting.google.com>
NNTP-Posting-Host: 62.242.20.246
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1068202913 3936 127.0.0.1 (7 Nov 2003 11:01:53 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 7 Nov 2003 11:01:53 +0000 (UTC)