PL/SQL

  • Rowcount on Oracle Dynamic SQLs

    A good friend asked me on how to capture the number of affected records on his delete statement. The answer would be as simple as below: DELETE FROM my_table WHERE mycolumn = ‘mysearch’; v_rec_count := SQL%ROWCOUNT; On this case, SQL%ROWCOUNT will return the number of affected records in the immediate preceding statement. It is the…

  • Update Oracle Sequence Last Number

    I only realized this last week that direct update of the last number of the sequence. Or maybe I just don’t know so what I did was to create a workaround.

  • Input truncated to 1 characters

    That pesky though harmless message “Input truncated to 1 characters” keep on appearing on one of my scripts and I can’t figure out what’s the problem. It turned out that the last line of my script is the slash (/). An extra new line is needed after the slash so that this message is suppressed.…

  • Oracle PL/SQL Continue Statement in Loops

    The CONTINUE statement is very handy feature when programming with loops in Oracle PL/SQL. Basically, it lets you skip to the next iteration of your loop (i.e., next record in the cursor loop). Unfortunately, it was only added in 11g Release 1 (11.1). This is stated in the Language Reference of that version. Below is…

  • Enable/Show DBMS_OUTPUT in PL/SQL

    The long and short of it is that the command is as below. SET SERVEROUTPUT ON There’s quite a misconception between DBMS_OUTPUT.ENABLE and SERVEROUTPUT directives. The SERVEROUTPUT tells Oracle to dump the buffer(i.e, sent via DBMS_OUTPUT.PUT_LINE) while the DBMS_OUTPUT.ENABLE starts the buffer messages which you may access by GET_LINE/GET_LINES. SERVEROUTPUT directive does two things: Issue…