databases Online Quiz - 143
Description: databases Online Quiz - 143 | |
Number of Questions: 20 | |
Created by: Aliensbrain Bot | |
Tags: databases |
create or replace function add_three_numbers (a number := 0, b number := 0, c number := 0) return number is Begin return a+b+c; End; / Which is not a valid procedure call in Oracle 10g
In For Loop syntax to go in reverse order
Declare Cursor c is select * from emp; I emp%row_type; Begin open c; fetch c into I; loop Dbms_output_line(‘Emp name:’ || i.ename); fetch c into I; exit when c%notfound; End loop; End; What is the error in above PL/SQL Block
Declare A char := ‘AB’; Begin A = 1; End; What is the error in the above block?
SET SERVEROUTPUT ON; DECLARE stock_price NUMBER := 9.73; net_earnings NUMBER := 0; pe_ratio NUMBER; BEGIN -- Calculation might cause division-by-zero error. pe_ratio := stock_price / net_earnings; dbms_output.put_line('Price/earnings ratio = ' || pe_ratio); EXCEPTION -- exception handlers begin -- Only one of the WHEN blocks is executed. WHEN ZERO_DIVIDE THEN -- handles 'division by zero' error dbms_output.put_line('Company must have had zero earnings.'); pe_ratio := null; WHEN OTHERS THEN -- handles all other errors dbms_output.put_line('Some other kind of error occurred.'); pe_ratio := null; END; -- exception handlers and block end here What will be outcome of this program block?
What is true about the simple loop statement? 1. Loop block has entry criteria 2. Loop block checks for exit criteria 3. We need to put an entry criteria manually 4. We need to put an exit criteria manually. 5. Loop without any exit criteria will be indefinite loop.
BEGIN . . . BEGIN IF X=1 THEN RAISE A: ELSEIF X=2 THEN RAISE B; ELSE RAISE C; EXCEPTION WHEN A THEN . . . END; EXCEPTION WHEN B THEN . . . END; Whar will happen to exception B
Begin Dbms_output.put_line(‘Hello world’) End; What is the error in the above block?
DECLARE sal_limit NUMBER ( 4 ) := 0 ; my_ename emp.ename%TYPE ; my_sal emp.sal%TYPE ; CURSOR my_cursor IS SELECT ename , sal FROM emp WHERE sal > sal_limit ; BEGIN sal_limit := 1200 ; OPEN my_cursor; fetch my_cursor INTO my_ename , my_sal ; LOOP FETCH my_cursor INTO my_ename , my_sal ; EXIT WHEN my_cursor%NOTFOUND ; -- nothing returned INSERT INTO new_table VALUES ( my_ename , my_sal ) ; END LOOP ; COMMIT ; END ;
CREATE OR REPLACE FUNCTION dml_call_sql (p_sal NUMBER) RETURN NUMBER IS BEGIN INSERT INTO employees(employee_id, last_name, email, hire_date, job_id, salary) VALUES(1, 'employee 1', '[email protected]', SYSDATE, 'SA_MAN', 1000); RETURN (p_sal + 100); END; / Function created. UPDATE employees SET salary = dml_call_sql(2000) WHERE employee_id = 170; What is the error in the block
How many type of cursors are available?