1 / 7

ARRAY

ARRAY. Dikompilasi Oleh : Ary Bima Kurniawan ST., MT. Pendahuluan. Definisi Tipe data bentukan yang dapat menyimpan sekumpulan nilai dari tipe data yang sama dan dikemas dalam bentuk larik.

Download Presentation

ARRAY

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. ARRAY DikompilasiOleh : AryBimaKurniawan ST., MT.

  2. Pendahuluan • Definisi • Tipe data bentukan yang dapat menyimpan sekumpulan nilai dari tipe data yang sama dan dikemas dalam bentuk larik. • Nilai dari elemen-elemen array dapat diacu atau diakses melalui indeksnya, perlu diperhatikan bahwa indeks array harus dari tipe data yang mempunyai keterurutan, seperti halnya tipe integer.

  3. Membuat Tipe Array • Bentuk Umum : TYPE nama_tipe IS TABLE OF tipe_data INDEX BY BINARY_INTEGER; • Contoh : DECLARE TYPE array_ku IS TABLE OF CHAR(5) INDEX BY BINARY_INTEGER; X array_ku;

  4. Mengisikan Nilai pada Elemen Array • Contoh 1 : BEGIN X(1) := ‘A’; X(2) := ‘B’; END; • Contoh 2 : BEGIN X(1) := 10; X(2) := 20; END;

  5. Contoh 1 SET SERVEROUTPUT ON DECLARE TYPE LARIK IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; A LARIK; I INTEGER; BEGIN FOR I IN 1..5 LOOP A(I) := I * 10; END LOOP; FOR I IN 1..5 LOOP DBMS_OUTPUT.PUT_LINE(‘Nilai elemen larik ke-’ || TO_CHAR(I) || ‘ = ‘ || TO_CHAR(A(I))); END LOOP; END; /

  6. Contoh 2 SET SERVEROUTPUT ON DECLARE TYPE SISWA IS TABLE OF VARCHAR2(25) INDEX BY BINARY_INTEGER; NAMA SISWA; I INTEGER; BEGIN NAMA(1) := ‘Arista Destriana’; NAMA(2) := ‘Yandri Gunawan’; NAMA(3) := ‘Herry Wahyudinata’; NAMA(4) := ‘Budi Raharjo’; NAMA(5) := ‘Noni Sutrisna’; FOR I IN 1..5 LOOP DBMS_OUTPUT.PUT_LINE(‘Nama siswa ke-’ || TO_CHAR(I) || ‘ : ‘ || NAMA(I)); END LOOP; END; /

  7. Pustaka • Pemrograman PL/SQL ORACLE • Imam Heryanto dan Budi Raharjo • Penerbit Informatika Bandung • 2003

More Related