TStoredProc doesn't get params

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
szabobeni
Posts: 1
Joined: Tue 09 Nov 2010 07:03

TStoredProc doesn't get params

Post by szabobeni » Tue 09 Nov 2010 07:14

Hello!

I use the UniDAC components for delphi7 I found a problem.
When I choose a stored procedure from the list(TUniStoredProc) it doesn't get the parameters of the procedure neither in design time nor in runtime.
If I active the dataset then get it but I need the params before call the procedure.
How can I solve this problem. Is there maybe a function or procedure, which can I use for this?
Thanks in advance.

AndreyZ

Post by AndreyZ » Tue 09 Nov 2010 09:50

Hello,

You can retrieve params of a stored procedure before calling it. For that you should double click the TUniStoredProc component and in the form that opened choose the name of your stored procedure.

joepasquariello
Posts: 38
Joined: Wed 16 May 2007 01:12

Post by joepasquariello » Fri 12 Nov 2010 22:16

Hello,

What if the UniStoredProc object is created at run-time?

With MSStoredProc, I simply assign the StoredProcName field as shown below, and then the parameters are "assigned". With UniStoredProc, I do the same thing, but the parameters are not assigned and I get an exception when I try to set one. Is there some way to make the parameters "live" for UniStoredProc created at run-time?

FWSubSP = new TMSStoredProc( NULL );
FWSubSP->Connection = GUIConnection;
FWSubSP->StoredProcName = "ScadaFWSub10";

Thank you,

Joe

AndreyZ

Post by AndreyZ » Mon 15 Nov 2010 08:41

You can use the TUniStoredProc.PrepareSQL method to obtain parameters of a stored procedure in the following way:

Code: Select all

  UniProc := TUniStoredProc.Create(nil);
  UniProc.Connection := UniConnection;
  UniProc.StoredProcName := 'Test_Proc';
  UniProc.PrepareSQL;
For more information please read UniDAC Reference Manual.

joepasquariello
Posts: 38
Joined: Wed 16 May 2007 01:12

Post by joepasquariello » Tue 16 Nov 2010 21:20

Thank you!

NGMI
Posts: 1
Joined: Sun 23 Apr 2017 08:33

Re: TStoredProc doesn't get params

Post by NGMI » Sun 23 Apr 2017 08:38

I used this code but i got an Access Violation Error in "preparesql" Line. I dont know where i made a mistake and how can i fix it!

Begin
PROC_DEL_TBL_Students := TUniStoredProc.Create(Nil);
PROC_DEL_TBL_Students.Connection := DataModule1.UniConnection1;
PROC_DEL_TBL_Students.StoredProcName := 'DEL_TBL_Students';
PROC_DEL_TBL_Students.PrepareSQL();
With PROC_DEL_TBL_Students Do
Begin
Params.FindParam('PSID').Value := SID;
ExecProc;
End;
PROC_DEL_tbl_Students.Free
End;

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TStoredProc doesn't get params

Post by azyk » Tue 25 Apr 2017 06:59

Please, compose a small test project to reproduce the problem and send it using the contact form on our website: http://www.devart.com/company/contactform.html . In the sample include a script to create the stored procedure.

Post Reply