Pl sql procedure sample programs




















Batch Transaction Processing Sample 5. Calling a Stored Procedure Running the Programs All the sample programs in this appendix and several others throughout this guide are available online. FOR Loop" sample2 "Sample 2. Cursors" sample3 "Sample 3. Scoping" sample4 "Sample 4. Batch Transaction Processing" sample5 "Sample 5. Input Table Not applicable. Cursors The following example uses a cursor to select the five highest paid employees from the emp table.

Scoping The following example illustrates block structure and scope rules. Batch Transaction Processing In the next example the accounts table is modified according to instructions stored in the action table. Create it. Value inserted. Updated instead. No action taken. Sample 5. All Rights Reserved. Below are the terminologies that we are going to discuss.

This parameter allows to give input to the subprograms and to extract from these subprograms. Based on their purpose parameters are classified as. RETURN is the keyword that instructs the compiler to switch the control from the subprogram to the calling statement.

Normally, parent or main block will call the subprograms, and then the control will shift from those parent block to the called subprograms. The datatype of this value is always mentioned at the time of function declaration. This subprogram unit in the Oracle database is stored as a database object. Note: Subprogram is nothing but a procedure, and it needs to be created manually as per the requirement.

Once created they will be stored as database objects. In this example, we are going to create an Oracle procedure that takes the name as input and prints the welcome message as output. We are going to use EXEC command to call procedure.

Below are some of the characteristics of functions. In this program, we are going to create a function that takes the name as input and returns the welcome message as output. Parameters are passed by reference. An OUT parameter returns a value to the calling program. Inside the subprogram, an OUT parameter acts like a variable.

You can change its value and reference the value after assigning it. The actual parameter must be variable and it is passed by value. An IN OUT parameter passes an initial value to a subprogram and returns an updated value to the caller. It can be assigned a value and the value can be read. The actual parameter corresponding to an IN OUT formal parameter must be a variable, not a constant or an expression.

Formal parameter must be assigned a value. Actual parameter is passed by value. This program finds the minimum of two values. Here, the procedure takes two numbers using the IN mode and returns their minimum using the OUT parameters.

This procedure computes the square of value of a passed value. This example shows how we can use the same parameter to accept a value and then return another result.



0コメント

  • 1000 / 1000