1 / 12

Cursor

Cursor. Cursors Operations. Cursors adalah suatu nama area yang berisi hasil dari suatu statement SQL. 1. OPEN 2. FETCH 3. CLOSE. Cursors Attribute. 1. %FOUND 2. %NOTFOUND 3. %ROWCOUNT 4. %ISOPEN. Function & Procedure. Function. FUNCTION Nama_Function (parameter) RETURN TYPE IS

katharines
Download Presentation

Cursor

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. Cursor

  2. Cursors Operations Cursors adalah suatu nama area yang berisi hasil dari suatu statement SQL. 1. OPEN 2. FETCH 3. CLOSE

  3. Cursors Attribute 1. %FOUND 2. %NOTFOUND 3. %ROWCOUNT 4. %ISOPEN

  4. Function & Procedure

  5. Function FUNCTION Nama_Function (parameter) RETURN TYPE IS deklarasi variabel BEGIN statement; statement; RETURN(variable/value); END;

  6. Procedure PROCEDURE Nama_Procedure (parameter) IS deklarasi variabel BEGIN statement; statement; EXCEPTION statement; END;

  7. Parameter Syntax parameter_name [IN | OUT | IN OUT] datatype [:= expr]

  8. Procedure Parameter Modes Procedure Calling Environment IN Argument OUT Argument IN OUT Argumen (DECLARE) BEGIN EXCEPTION END;

  9. Function Parameter Modes Function Calling Environment IN Argument (DECLARE) BEGIN EXCEPTION END;

  10. Procedure vs Function

  11. DECLARE v_tax number; v_sal emp.salary%TYPE; BEGIN SELECT salary into v_sal FROM emp WHERE id = 97001; v_tax := Tax(v_sal); EXCEPTION WHEN NO_DATA_FOUND THEN v_tax := 0; END; FUNCTION Tax(v_value IN NUMBER) RETURN NUMBER IS BEGIN RETURN(v_value * .07); END Tax; Example

  12. DECLARE v_id emp.id%TYPE := 97001; v_sal emp.salary%TYPE; BEGIN SELECT salary into v_sal FROM emp WHERE id = v_id; Change_Salary(v_id, v_sal*1.1); EXCEPTION WHEN NO_DATA_FOUND THEN NULL; END; PROCEDURE Change_Salary (v_emp_id IN NUMBER, v_new_salary IN NUMBER) IS BEGIN UPDATE s_emp SET salary = v_new_salary WHERE id = v_emp_id; COMMIT; END Change_Salary; Example

More Related