pl/sql& Stored Procedures | | Storage functions & Triggers

Source: Internet
Author: User
Tags close close

Plsql a bit: interactive non-process data manipulation ability strong Automatic navigation statement simple debugging simple want to rate high declaration type Way 1. Basic type 2. Reference variable 3. Record type variable basic format declare declaration begin exception End judgment Sentence if:. Then ... else End If;

Looping loop exit condition exit when ...;

End Loop;

Cursors Cursor---resltset returns multiple rows of data

Format cursor indicates OPER open fetch GO line cursor close close

Oracle Exception Handling exception

Timeout_on_resourrce Request Timeout Stored procedure store function trigger based on Plsql

Stored procedure format create (or replace) procedure as

Stored procedure storage function \ Difference: The storage function must have a return value can only accept one parameter two stored procedure optional return value optional parameter and can accept multiple parameters and return value can be a collection

You can call the stored procedure using the cursor Java

1: Create DATABASE link connectio 2. Precompiled SQL objects can create a result set of 3. Result set object (using cursor)

Sql:string sql = "{call Mypackage.queryemplist (?,?)}"; Call the stored procedure with the cursor Call.registeroutparameter (2, oracletypes.cursor); Cursor type

Data dictionary Meta Data Database framework

Triggers: Row-level triggers, statement-level triggers

Instance:

/*implement complex security checks to prohibit insertion of new employees during non-business hours non-working hours: 1. Weekend: To_char (sysdate, ' Day ') in (' Saturday ', ' Sunday ') 2. After work: To_number (To_char (Sysdate, ' Hh24 ')) not betweeen 9 and*/Create or Replace TriggerSecurityempbeforeInsert onEMPbegin   ifTo_char (Sysdate,' Day')inch('Saturday','Sunday')orTo_number (To_char (Sysdate,'hh24')) not between 9  and  -  Then         --Throw ErrorRaise_application_error (-20001,'prohibit inserting new employees during non-working hours'); End if;End;/
--the salary after the rise cannot be less than the wages before the riseCreate or Replace TriggerChecksalbeforeUpdate onEMP forEach rowbegin  --If the salary after the rise < before the salary then  if: New.sal<: Old.sal ThenRaise_application_error (-20002,'after the rise of wages can not be less than before the rise of wages. After the rise:'||: New.sal||'before the rise:'||: Old.sal); End if;End;/

pl/sql& Stored Procedures | | Storage functions & Triggers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.