1.

How to close a CURSOR in PL/SQL?

Answer»

PL/SQL Block Structures and it executes as a whole block.

The block structure can be understood with the concept of subprograms in PL/SQL. A block structure has the following PARTS:

  • Declarative

It contains declarations of cursors, CONSTANTS, VARIABLES, exceptions, etc. Variables are declared here.

  • Executable

Had statements that perform actions. It must have atleast one statement.

  • Exception Handling

The code that handles run-time errors. It use EXCEPTION keyword. 

The following is the syntax to create a subprogram (procedure):

CREATE [OR REPLACE] PROCEDURE name_of_procedure [(parameter_name [IN | OUT | IN OUT] type [, ...])] {IS | AS} BEGIN  < procedure_body > END name_of_procedure;

Here,

  • CREATE [OR REPLACE] MEANS a new procedure is created or modifies the EXISTING one.
  • name_of_procedure is the procedure name.
  • procedure_body is the executable part.

Here is an example of a subprogram (procedure):

CREATE OR REPLACE PROCEDURE one AS BEGIN   dbms_output.put_line('Welcome!'); END; /

The output displays the procedure created successfully:

Procedure created.


Discussion

No Comment Found