1.

What does a basic loop do in PL/SQL?

Answer»

A subprogram in PL/SQL is EITHER a procedure or a function that can be invoked repeatedly. Each subprogram has a name and a LIST of parameters. It performs a specific task and the following two subprograms EXIST in PL/SQL:

  • Functions: RETURN a single value.
  • Procedures: Do not return a value directly.

The following are the parts of a subprogram:

  • Declarative

It contains declarations of cursors, constants, variables, exceptions, etc.

  • Executable

Had statements that perform actions.

  • Exception Handling

The code that handles run-time errors.

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