Category: PL/SQL

PL/SQL Instr

Oracle PL/SQL Instr Example Select INSTR('Instr Test',' ',1,3) From dual; Select INSTR( 'London', 'don' ) result From dual; Select SUBSTR('ora,for,tic', INSTR('ora,for,tic',',', 1, 2)+1) From dual;...

PL/SQL Inner Join

Oracle PL/SQL Inner Join Equijoin is also called simple join or inner join – the select of two different tables as a condition containing the equality operator. Inner Join Example: Select o.id, o.customer_id, c.name, o.amount From offers o, customers c Where...

PL/SQL If-Then-ElsIf-Else

Oracle PL/SQL If-Then-ElsIf-Else Example CREATE OR REPLACE Function Sales_Report ( p_user_name IN varchar2 ) RETURN varchar2 IS sale_amount number(12); message varchar2(20); Cursor c is Select sum(o.amount) From offers o, users u Where o.user_code=u.user_code And u.name = p_user_name; BEGIN Open c; Fetch...

PL/SQL Goto

Oracle PL/SQL Goto Example DECLARE v number := 123; BEGIN IF v = 123 THEN GOTO test; ELSE v := 123; END IF; DBMS_OUTPUT.PUT_LINE('PlSql Goto test'); NULL; END;...

PL/SQL For Loop

Oracle PL/SQL FOR LOOP Example DECLARE CURSOR c1 is SELECT * FROM emp ORDER BY sal DESC; v_c1 emp%ROWTYPE; BEGIN OPEN c1; FOR i IN 1..5 LOOP FETCH c1 INTO v_c1; EXIT WHEN c1%NOTFOUND; INSERT INTO emp_test VALUES (v_c1.empno, v_c1.ename, v_c1.job,...