Page 1 of 1

Possible to capture output from DBMS_OUTPUT.PUT_LINE?

Posted: Mon 11 Oct 2021 04:29
by yeohray2
Given the following script:

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

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

Re: Possible to capture output from DBMS_OUTPUT.PUT_LINE?

Posted: Mon 11 Oct 2021 14:19
by MaximG
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;
...

Re: Possible to capture output from DBMS_OUTPUT.PUT_LINE?

Posted: Tue 12 Oct 2021 06:35
by yeohray2
Got it, thanks.