01 e tipe data komposit dan variable.pptx

Post on 20-Jan-2016

22 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Inne Gartina Husein, S.Kom., M.T.Hanya untk kepentingan pengajaran di Politeknik Telkom

Tipe Data Komposit dan Variable

1 - 3

2

Tipe DataTipe Variable Contoh Tipe data

Skalar DATE, NUMBER, CHAR, VARCHAR2, BOOLEAN, %TYPE

Composite RECORD, INDEX BY, %ROWTYPE

Reference Variabel substitusi yang diawali oleh simbol ampersand (&)

LOB CLOB, BLOB, BFILE, NCLOB

Non-PL/SQL Bind variable

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 substitusiSQL> 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: HelloEnter value for input2: WorldHello World

PL/SQL procedure successfully completed.

25

Latihan 1 Bagian Deklarasi, Bagian Eksekusi, Bagian Exception

Declare a int; b number(2,1); c number(2,1);begina:=&a_value;b:=&b_value;c:=a/b;dbms_output.put_line('nilai c = '||c||’ kotak’);exception when ZERO_DIVIDE then dbms_output.put_line('nilai b tidak boleh=0');end;/

top related