top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

HOW PL/SQL GETS EXECUTED

+1 vote
449 views
HOW PL/SQL GETS EXECUTED
posted Jun 17, 2014 by Swati Arora

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Every time an anonymous PL/SQL block is executed, the code is sent to the PL/SQL engine on the server where it is compiled. The named PL/SQL block is compiled only at the time of its creation, or if it has been changed. The compilation process includes syntax checking, binding, and p-code generation.

Syntax checking involves checking PL/SQL code for syntax or compila-tion errors. Syntax error occurs when a statement does not exactly corre-spond to the syntax of the programming language. Errors such as misspelled keyword, missing semicolon at the end of the statement, or undeclared variable are examples of syntax errors.

Once the programmer corrects syntax errors, the compiler can assign a storage address to program variables that are used to hold data for Oracle. This process is called binding. It allows Oracle to reference storage ad-dresses when the program is run. At the same time, the compiler checks references to the stored objects such as table name or column name in the SELECT statement, or a call to a named PL/SQL block.

Next, p-code is generated for the PL/SQL block. P-code is a list of instruc-tions to the PL/SQL engine. For named blocks, p-code is stored in the database, and it is used the next time the program is executed. Once the process of compilation has completed successfully, the status for a named PL/SQL block is set to VALID, and also stored in the database. If the com-pilation process was not successful, the status of a named PL/SQL block is set to INVALID.

It is important to remember that successful compilation of the named PL/SQL block does not guarantee successful execution of this block in the future. If, at the time of the execution, any one of the stored objects ref-erenced by the block is not present in the database or not accessible to the block, the execution will fail. The status of the named PL/SQL block will be changed to INVALID.

answer Jun 18, 2014 by Aarati Mahajan
Similar Questions
+1 vote

declare
lc_status:='XXstatus';
Begin
Update xxtable
set Status_fg=lc_status
where con_bill_id=1234;

-- here i need to display how rows were updated.

end;

...