1 / 45

Introduction to Anonymous Blocks in SQLPlus

Learn how to create and use anonymous blocks in SQLPlus, including inserting records, updating rows, and using bind and substitution variables.

blori
Download Presentation

Introduction to Anonymous Blocks in SQLPlus

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 2Anonymous Block DasarPemrograman Basis Data MI2163

  2. Block Types • unnamed blocks • are not stored in the database

  3. Create An Anonymous Block • Type the anonymous block in SQLPlus environment: SQL> BEGIN 2 DBMS_OUTPUT.PUT_LINE('Hello World'); 3 END; 4 / Hello World PL/SQL procedure successfully completed.

  4. Creating A PL/SQL Records

  5. The %ROWTYPE Attribute

  6. Inserting a Record Using %ROWTYPE

  7. Updating a Row in a Table Using a Record

  8. Example of Bind Variables in SQLPlus Environment SQL> VARIABLE v_word1 VARCHAR2(5); SQL> VARIABLE v_word2 VARCHAR2(5); SQL> BEGIN 2 :v_word1:='Hello'; 3 :v_word2:='World'; 4 DBMS_OUTPUT.PUT_LINE(:v_word1||' '||:v_word2); 5 END; 6 / Hello World PL/SQL procedure successfully completed.

  9. Example of Substitution Variables in SQLPlus Environment SQL> -- input nilaimenggunakanvariabelsubstitusi SQL> DECLARE 2 v_word1 VARCHAR2(5):= '&input1'; 3 v_word2 VARCHAR2(5):= '&input2'; 4 BEGIN 5 DBMS_OUTPUT.PUT_LINE(v_word1||' '||v_word2); 6 END; 7 / Enter value for input1: Hello Enter value for input2: World Hello World PL/SQL procedure successfully completed.

More Related