Chapter 2 Anonymous Block Dasar Pemrograman Basis Data MI2163
Block Types unnamed blocks are not stored in the database
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.
Creating A PL/SQL Records
The %ROWTYPE Attribute
Inserting a Record Using %ROWTYPE
Updating a Row in a Table Using a Record
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.
Example of Substitution Variables in SQLPlus Environment SQL> -- input nilai menggunakan variabel substitusi 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.