Membuat Looping pada Oracle

SQL> conn
Enter user-name: system
Enter password:

SQL> create table nim (no number(8),nim varchar(30));
Table created.

SQL> declare
x number(8);
begin
x:=1;– nilai awal
LOOP
insert into nim values(x,’0965000′ ||x);
x:=x+1;
EXIT WHEN x=10;
END LOOP;
COMMIT;
END;
/

PL/SQL procedure successfully completed.

SQL> select * from nim;

NO NIM
———- ——————————
1 09650001
2 09650002
3 09650003
4 09650004
5 09650005
6 09650006
7 09650007
8 09650008
9 09650009

9 rows selected.

Penjelasan:
perintah untuk login di oracle: conn

pembuatan table:
create table nim (no number(8),nim varchar(30));

LOOPING:
declare
x number(8);
begin
x:=1;– nilai awal
LOOP
insert into nim values(x,’0965000′ ||x);
x:=x+1;
EXIT WHEN x=10;
END LOOP;
COMMIT;
END;
/

perintah menampilkan isi table:
select * from nim;

isi table:
NO NIM
———- ——————————
1 09650001
2 09650002
3 09650003
4 09650004
5 09650005
6 09650006
7 09650007
8 09650008
9 09650009

9 rows selected.

Advertisements

2 Comments »

  1. semoga informasi ini bisa menambah ilmu saya sebagai tambahan bahan pengajaran.

    • amey Said:

      y smoga bisa bermanfaat…
      terimakasih, :)…


{ RSS feed for comments on this post} · { TrackBack URI }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: