0

i am developing a web app with oracle database and yii framework

    $connection = Yii::app()->oo;
    $command = $connection->createCommand("DECLARE V_COD NUMBER; v_Return DATA.FIND.T_REG;
BEGIN
 V_COD := 1529;
 v_Return := FIND.DATA(
   V_COD => V_COD
 );
DBMS_OUTPUT.PUT_LINE('CODE, '|| V_RETURN.CODE ||' WITH SERIE: '||V_RETURN.SERIE);
END;");


        $rows = $command->execute();
        print_r($rows);

executing the query return 1, i want get a message output DBMS_OUTPUT.PUT_LINE. how can i do this? any idea? thanks in advance!!!

1 Answers1

0

You really, really, really do not want to build an application that depends on dbms_output. dbms_output exists primarily as a quick-and-dirty way of debugging code if you happen not to be able to use a real debugger. You should generally not assume that a buffer for dbms_output has been declared, that the buffer is large enough for whatever you want to write, or that a human will ever see what's written to the dbms_output buffer. Most client tools don't declare such a buffer and don't read from it if they do create a buffer.

The proper way to return data to a client is to have your code call the function (in this case) directly. If your function is returning a data type that your framework doesn't handle, create a separate wrapper procedure that calls the first function and has two OUT parameters for the code and serie. Use bind variables in your call and bind values (like 1529) from the code.

If you really, really, really want to read from the buffer (assuming it exists), you'd need to call dbms_output.get_line in the same session.

Justin Cave
  • 227,342
  • 24
  • 367
  • 384