How to use UniStoredProc from the code
How to use UniStoredProc from the code
Hello,
What is the proper way to use Stored Procedures from code?
I want create a UniStoredProc object from code. How declare input and output parameters and its types?
Could you write some examples for different input and output types ?
Regards
Michal
What is the proper way to use Stored Procedures from code?
I want create a UniStoredProc object from code. How declare input and output parameters and its types?
Could you write some examples for different input and output types ?
Regards
Michal
Re: How to use UniStoredProc from the code
Hello,
To create TUniStoredProc and parameter setting, you can use the following code.
To create TUniStoredProc and parameter setting, you can use the following code.
Code: Select all
var
UniStoredProc: TUniStoredProc;
begin
UniStoredProc := TUniStoredProc.Create(nil);
try
UniStoredProc.Connection := UniConnection1;
UniStoredProc.StoredProcName := 'my_storedproc';
UniStoredProc.ParamByName('p1').ParamType := ptInput;
UniStoredProc.ParamByName('p1').DataType := ftInteger;
UniStoredProc.ParamByName('p2').ParamType := ptOutput;
UniStoredProc.ParamByName('p2').DataType := ftString;
UniStoredProc.Execute;
ShowMessage(UniStoredProc.ParamByName('p2').AsString);
finally
UniStoredProc.Free;
end;
end;
Re: How to use UniStoredProc from the code
Hello,
Thanks.
How to send and receive more complicated structures like arrays or records.
How to get a dataset(-s) as output ?
Regards
Michal
Thanks.
How to send and receive more complicated structures like arrays or records.
How to get a dataset(-s) as output ?
Regards
Michal
Re: How to use UniStoredProc from the code
Work with such types depends on the DB you are using. Please specify the DB name and types you are interested to work with.
Re: How to use UniStoredProc from the code
Hello,
The example code doesn't work:
UniStoredProc.ParamByName('p1').ParamType := ptInput;
UniStoredProc.ParamByName('p1').DataType := ftInteger;
I receive error message "Parameter 'p1' not found.
I'm using PostgreSQL.
Regards
Michal
The example code doesn't work:
UniStoredProc.ParamByName('p1').ParamType := ptInput;
UniStoredProc.ParamByName('p1').DataType := ftInteger;
I receive error message "Parameter 'p1' not found.
I'm using PostgreSQL.
Regards
Michal
Re: How to use UniStoredProc from the code
Before calling parameters, the UniStoredProc.Prepare method should be called
Re: How to use UniStoredProc from the code
Thanks,
But what of these questions:
How to send and receive more complicated structures like arrays or records.
How to get a dataset(-s) as output ?
Regards
Michal
But what of these questions:
How to send and receive more complicated structures like arrays or records.
How to get a dataset(-s) as output ?
Regards
Michal
Re: How to use UniStoredProc from the code
You can work with such types only as with strings
If a procedure or a function returns the cursor (DataSet), then you can work with TUniStoredProc as with a normal DataSet
If a procedure or a function returns the cursor (DataSet), then you can work with TUniStoredProc as with a normal DataSet
Re: How to use UniStoredProc from the code
Thanks,
Regards
Michal
Regards
Michal
Re: How to use UniStoredProc from the code
You are welcome. Feel free to contact us if you have any further questions about UniDAC.