[go: up one dir, main page]

0% found this document useful (0 votes)
27 views5 pages

Mengambil 1 Data:: Nama: Ahmad Wijaya Kelas: TI-2015-RPL-P1 Matkul: PLSQL Oracle

The document discusses using PL/SQL cursors in Oracle to retrieve data from the employees table. It provides examples of using a cursor to fetch a single row of data and multiple rows of data where the department ID is 30. It also gives an example of a query to retrieve employee ID, first name, last name and salary for employees with a job ID of IT_PROG without using a cursor. The document suggests creating a cursor program to print these fields for IT_PROG employees.

Uploaded by

Ahmad Wijaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

Mengambil 1 Data:: Nama: Ahmad Wijaya Kelas: TI-2015-RPL-P1 Matkul: PLSQL Oracle

The document discusses using PL/SQL cursors in Oracle to retrieve data from the employees table. It provides examples of using a cursor to fetch a single row of data and multiple rows of data where the department ID is 30. It also gives an example of a query to retrieve employee ID, first name, last name and salary for employees with a job ID of IT_PROG without using a cursor. The document suggests creating a cursor program to print these fields for IT_PROG employees.

Uploaded by

Ahmad Wijaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Nama : Ahmad Wijaya

Kelas : TI-2015-RPL-P1
Matkul : PLSQL Oracle

1. mengambil 1 data :

DECLARE
CURSOR emp_cursor IS
SELECT employee_id, first_name,last_name FROM employees
WHERE department_id =30;
empno employees.employee_id%TYPE;
fname employees.first_name%TYPE;
lname employees.last_name%TYPE;
BEGIN
OPEN emp_cursor;
FETCH emp_cursor INTO empno, fname, lname;
DBMS_OUTPUT.PUT_LINE( empno ||' '||fname ||' ' || lname);
END;
2. mengambil sejumlah data

DECLARE
CURSOR emp_cursor IS
SELECT employee_id, first_name,last_name FROM employees
WHERE department_id =30;
empno employees.employee_id%TYPE;
fname employees.first_name%TYPE;
lname employees.last_name%TYPE;
BEGIN
OPEN emp_cursor;
LOOP
FETCH emp_cursor INTO empno, fname,lname;
EXIT WHEN emp_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE( empno ||' '||fname ||' ' || lname);
END LOOP;
END;
3. buat program dengan cursor untuk mencetak employee_id, first_name, salary para IT_PROG
(=job_id)

Tanpa program CURSOR :

SELECT employee_id, first_name,last_name,salary FROM employees WHERE job_id ='IT_PROG';


4.
5.

You might also like