Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Database programming with PLSQL, Assignments of Database Programming

In this exercise, there is an introduction to the use of Oracle PL SQL such as anonymous PL/SQL block, functions, subprograms, compilers, procedures.

Typology: Assignments

2019/2020

Available from 08/24/2023

anisa-ica
anisa-ica 🇮🇩

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Database Programming with PL/SQL
Practice Activities
Vocabulary
Identify the vocabulary word for each definition below:
Anonymous PL/SQL
Block
Unnamed blocks of code not stored in the database and do not exist
after they are executed
Function
A program that computes and returns a single value
Subprograms
Named PL/SQL blocks that are stored in the database and can be de-
clared as procedures or functions
Compiler
Software that checks and translates programs written in high-level pro-
gramming languages into binary code to execute
Procedur
A program that performs an action, but does not have to return a value
Try It / Solve It
1. Complete the following chart defining the syntactical requirements for a PL/SQL block:
Optional or Mandatory?
Describe what is included in
this section
DECLARE
Optional
Deklarasi variabel, konstanta,
cursor dan exception (yang
ditetapkan pengguna).
BEGIN
Mandatory
SQL Statement dan PL/SQL
Statement .
EXCEPTION
Optional
Bagian pengecualian di bagian
yang bisa di eksekusi /
(handling error) .
END;
Mandatory
END ;
(Mengakhiri BEGIN dengan
END; )
pf2

Partial preview of the text

Download Database programming with PLSQL and more Assignments Database Programming in PDF only on Docsity!

Database Programming with PL/SQL

Practice Activities

Vocabulary

Identify the vocabulary word for each definition below:

Anonymous PL/SQL

Block

Unnamed blocks of code not stored in the database and do not exist after they are executed

Function

A program that computes and returns a single value

Subprograms

Named PL/SQL blocks that are stored in the database and can be de- clared as procedures or functions

Compiler

Software that checks and translates programs written in high-level pro- gramming languages into binary code to execute

Procedur

A program that performs an action, but does not have to return a value

Try It / Solve It

  1. Complete the following chart defining the syntactical requirements for a PL/SQL block: Optional or Mandatory? Describe what is included in this section DECLARE

Optional

Deklarasi variabel, konstanta, cursor dan exception (yang ditetapkan pengguna). BEGIN

Mandatory

SQL Statement dan PL/SQL Statement. EXCEPTION

Optional

Bagian pengecualian di bagian yang bisa di eksekusi / (handling error). END;

Mandatory

END ;

(Mengakhiri BEGIN dengan END; )

  1. Which of the following PL/SQL blocks executes successfully? For the blocks that fail, explain why they fail A. BEGIN END; B. DECLARE amount INTEGER(10); END; C. DECLARE BEGIN END; D. DECLARE amount NUMBER(10); BEGIN DBMS_OUTPUT.PUT_LINE(amount); END;

Jawab :

A) Gagal , karena untuk untuk mengeksekusi nya tidak cukup hanya BEGIN dan END harus ada statement nya minimal 1 statement agar bisa di eksekusi. B) Gagal , karena bagian paling penting yaitu BEGIN tidak ada jadi tidak bisa di eksekusi. C) Gagal , karena untuk mengeksekusinya harus ada statement nya minimal 1 agar bisa di eksekusi. D) Sukses.

  1. Fill in the blanks: A. PL/SQL blocks that have no names are called Anonymous blocks. B. Procedures and Functions are named blocks and are stored in the database.
  2. In Application Express, create and execute a simple anonymous block that outputs “Hello World.” Jawab : BEGIN DBMS_OUTPUT.PUT_LINE('Hello World'); END;
  3. Create and execute a simple anonymous block that does the following:
    • Declares a variable of datatype DATE and populates it with the date that is six months from today
    • Outputs “In six months, the date will be: .” Jawab : DECLARE v_date DATE:= ADD_MONTHS(sysdate, 6); BEGIN DBMS_OUTPUT.PUT_LINE('In six months, the date will be: ' ||v_date); END;