Print Thread
Clob as out parameter to Storedproc component
#48919 04/22/14 04:45 AM
Joined: May 2013
Posts: 20
S
Member
OP Offline
Member
S
Joined: May 2013
Posts: 20
Hi,

I want to use clob as out parameter in storedproc component. I tried this but i am unable to accomplish it. please guide me how can i achieve this.

thanks
sudheer.

Re: Clob as out parameter to Storedproc component
Sudheer B #48921 04/22/14 10:33 AM
Joined: Aug 1999
Posts: 22,201
Member
Offline
Member
Joined: Aug 1999
Posts: 22,201
What exactly goes wrong?

Note that you need to create a TLOBLocator instance through the TLOBLocator.CreateTemporary constructor, so that you obtain a Temporary CLOB that can be used for stored procedure calls.

See also the CreateTemporary topic in the User's Guide.


Marco Kalter
Allround Automations
Re: Clob as out parameter to Storedproc component
Marco Kalter #48928 04/23/14 11:12 AM
Joined: May 2013
Posts: 20
S
Member
OP Offline
Member
S
Joined: May 2013
Posts: 20
the following delphi procedure what we are using.
procedure getclob();
var
templob : TLOBLocator;
tempSession : TOracleSession;
tempPackage : TOraclePackage;
begin
tempSession := TOracleSession.Create(Self);
tempSession.LogonDatabase := 'temp';
tempSession.LogonUsername := 'temp';
tempSession.LogonPassword := 'temp';
tempSession.Connected := True;
tempPackage := TOraclePackage.Create(Self);
tempPackage.PackageName := 'temptest';
tempPackage.CallProcedure('getclob',[]); // there are no IN or INOUT parameters. Only one OUT parameter p_returnclob of type CLOB
templob := TLOBLocator.Create(tempSession,otCLOB);
templob := tempPackage.GetParameter('p_retrunclob');
showmessage(templob.ToString);
end;

the following PL/SQL procedure what we are using under the package temptest.

procedure getclob( p_returnclob OUT CLOB) is
begin
p_returnclob := 'test';
end;

Re: Clob as out parameter to Storedproc component
Sudheer B #48930 04/24/14 09:07 AM
Joined: Aug 1999
Posts: 22,201
Member
Offline
Member
Joined: Aug 1999
Posts: 22,201
You cannot use the TOraclePackage to call procedures with complex paramaters such as CLOB's. You will need to use a TOracleQuery instance with a PL/SQL Block with the procedure call. For example:
Code
var LOB: TLOBLocator;
begin
  with LOBQuery do
  begin
    SetVariable('v_id', ...);
    // Create a new temporary CLOB
    LOB := TLOBLocator.CreateTemporary(Session, otCLOB, True);
    // Assign it to the returning variable
    SetComplexVariable('v_clob', LOB);
    // Call the procedure
    Execute;
    // Do something with the data
    ShowMessage(LOB.AsString);  
    // Free the CLOB
    LOB.Free;
  end;
end; 


Marco Kalter
Allround Automations

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.026s Queries: 15 (0.008s) Memory: 2.5083 MB (Peak: 3.0398 MB) Data Comp: Off Server Time: 2024-04-23 20:25:27 UTC
Valid HTML 5 and Valid CSS