Possible to capture output from DBMS_OUTPUT.PUT_LINE?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
yeohray2
Posts: 21
Joined: Thu 08 May 2014 15:49

Possible to capture output from DBMS_OUTPUT.PUT_LINE?

Post by yeohray2 » Mon 11 Oct 2021 04:29

Given the following script:

BEGIN
DBMS_OUTPUT.PUT_LINE('Hello');
END;

Can Unidac capture the output, and if so, how? Thanks in advance.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Possible to capture output from DBMS_OUTPUT.PUT_LINE?

Post by MaximG » Mon 11 Oct 2021 14:19

The following code snippet demonstrates demonstrates working with the DBMS_Output package :
...

Code: Select all

var
  Query: TUniQuery;
begin
  UniConnection.Connect;

  Query := TUniQuery.Create(Nil);
  try
    Query.Connection := UniConnection;
    Query.SQL.Text := 'Begin DBMS_Output.Enable(20000); End;';
    Query.Execute;
    // DBMS_Output.Put_Line
    Query.SQL.Text := 'Begin DBMS_Output.Put_Line(''Hello''); End;';
    Query.Execute;
    // DBMS_Output.Get_Line
    Query.SQL.Text := 'Begin DBMS_Output.Get_Line(:LineValue, :Status); End;';
    Query.ParamByName('LineValue').ParamType := ptOutput;
    Query.ParamByName('LineValue').DataType := ftString;
    Query.ParamByName('Status').ParamType := ptOutput;
    Query.ParamByName('Status').DataType := ftInteger;
    Query.Execute;
    ShowMessage(Query.ParamByName('LineValue').AsString);
  finally
    Query.Free;
  end;
end;
...

yeohray2
Posts: 21
Joined: Thu 08 May 2014 15:49

Re: Possible to capture output from DBMS_OUTPUT.PUT_LINE?

Post by yeohray2 » Tue 12 Oct 2021 06:35

Got it, thanks.

Post Reply