1.Sebutkan macam-macam kondisi pada PL/SQL?
Jawab:
IF-THEN
IF-THEN-ELSE
IF-THEN-ELSIF
CASE
Jawab:
Perintah IF-THEN
Bentuk umum :
IF condition THEN
sequence_of_statements
END IF;
Perintah IF-THEN-ELSE
Bentuk umum :
IF condition THEN
sequence_of_statements1
ELSE
sequence_of_statements2
END IF;
Perintah IF-THEN-ELSIF
Bentuk umum :
IF condition1 THEN
sequence_of_statements1
ELSIF condition2 THEN
sequence_of_statements2
ELSE
sequence_of_statements3
END IF;
Perintah CASE
Bentuk umum :
[<>]
CASE selector
WHEN expression1 THEN sequence_of_statements1;
WHEN expression2 THEN sequence_of_statements2;
…
WHEN expressionN THEN sequence_of_statementsN;
[ELSE sequence_of_statementsN+1;]
END CASE [label_name];
3.Buatlah salah satu contoh program menggunkan kondisi pada PL/SQL?
Jawab:
SET SETVEROUTPUT ON
DECLARE
J NUMBER;
JUM VARCHAR(20);
BEGIN
SELECT COUNT(*) INTO J FROM TAB;
IF J=1 THEN
JUM := ’SATU’;
ELSIF J=2 THEN
JUM := ’DUA’;
ELSIF J=3 THEN
JUM := ’TIGA’;
ELSIF J=4 THEN
JUM := ’EMPAT’;
ELSIF J=5 THEN
JUM := ’LIMA’;
END IF;
DBMS_OUTPUT.PUT_LINE(‘JUMLAH TABEL = ’||J||’ (’||JUM||’)’);
END;
/
1 komentar:
lo tau???? gue diharuskan mengetik ini 20 kali ha,,ha,,,
*keep enjoy
Posting Komentar