PL/SQL - продължението
Xamine the following code. At Line A, we want to assign a value of 25 to the outer block’s variable (V1). What must we do? DECLARE v_myvar NUMBER; — This is V1 BEGIN DECLARE v_myvar NUMBER := 8; BEGIN — Line A END; END;
At Line A, code: v_myvar := 25;
Label both blocks and at line A, code: v_myvar := 25;
It cannot be done because the outer block’s v_myvar is out of scope at Line A.
Label the outer block and (at Line A) dot-prefix v_myvar with the block label.
It cannot be done because the outer block’s v_myvar is in scope but not visible at Line A.
CREATE TRIGGER emp_trigg — Line A BEGIN INSERT INTO log_table VALUES (USER, SYSDATE); END; Which of the following can NOT be coded at Line A?
BEFORE UPDATE ON employees
AFTER SELECT ON employees
AFTER INSERT OR DELETE ON employees
BEFORE DELETE ON employees
AFTER UPDATE OF last_name ON employees
Procedure TESTPROC accepts one parameter P1, whose value is up to 1000 characters in length. Which one of the following declares this parameter correctly?
CREATE PROCEDURE testproc (p1 VARCHAR2(100) ) IS BEGIN
CREATE PROCEDURE testproc IS p1 VARCHAR2(100); BEGIN ….
CREATE PROCEDURE testproc DECLARE p1 VARCHAR2(100); BEGIN ….
CREATE PROCEDURE testproc p1 VARCHAR2 IS BEGIN ….
CREATE PROCEDURE testproc (p1 VARCHAR2) IS BEGIN ….
He following anonymous block of code is run: BEGIN INSERT INTO countries (id, name) VALUES ('XA', 'Xanadu'); SAVEPOINT XA; INSERT INTO countries (id, name) VALUES ('NV','Neverland'); COMMIT; ROLLBACK TO XA; END; What happens when the block of code finishes?
No data is inserted and no errors occur.
No data is inserted and an error occurs
Two rows are inserted and no errors occur.
Wo rows are inserted and an error occurs
User ALICE owns a procedure show_emps which references table employees. Which of the following will generate information that shows this dependency?
BEGIN deptree_fill(‘TABLE’,’EMPLOYEES’); END;
BEGIN deptree_fill(‘PROCEDURE’,’ALICE’,’SHOW_EMPS’); END;
BEGIN deptree_fill(‘ALICE’,’TABLE’,’EMPLOYEES’); END;
BEGIN deptree_fill(‘TABLE’,’ALICE’,’EMPLOYEES’); END;
BEGIN deptree_fill(‘ALICE’,’PROCEDURE’,’SHOW_EMPS’); END;
Whenever an employee’s JOB_ID is updated, we want to insert a row into a logging table to record the employee_id and the new value of JOB_ID. We create a row trigger whose body includes the following code: BEGIN INSERT INTO logging_table (emp_id, job_id) VALUES — Point A END; At point A, which of the following will insert the correct data into the logging table? (Choose two.)
(:OLD.employee_id, :OLD.job_id);
(:OLD.employee_id, :NEW.job_id);
(:NEW.employee_id, :OLD.job_id);
(:NEW.employee_id, :NEW.job_id);
(NEW.employee_id, NEW.job_id);
Examine the following code: DECLARE v_score NUMBER(3); v_grade CHAR(1); BEGIN CASE v_score -- Line A .... The CASE statement must convert a numeric score to a letter grade: 90 -> A, 80 -> B, 70 -> C and so on. What should be coded at Line A?
WHEN 90 THEN v_grade := 'A'
WHEN 90 THEN v_grade := 'A';
WHEN 90 THEN 'A'
WHEN 90 THEN 'A';
You can reference explicit cursor attributes directly in a SQL statement. True or False?
True
False
How many INSERTs can you have in one transaction?
One
As many as you want until you do a COMMIT or ROLLBACK.
As many as you can execute before the database does an AUTOSAVE
As many as you want until a different DML statement (UPDATE, DELETE or MERGE) is executed.
Which implicit cursor attribute identifies the number of rows updated in the following statement? DBMS_OUTPUT.PUT_LINE(__________ || ' rows updated.');
SQL%NUMBER
SQL%ROWCOUNT
SQLROW%COUNT
SQL%COUNT
Which of the following statements is true? (1) Points
You can embed PL/SQL statements within SQL code.
You can embed SQL statements within PL/SQL code.
You can embed procedural constructs within SQL code.
None.
The following are the steps involved in creating, and later modifying and re-creating, a PL/SQL procedure in Application Express. Which step is missing? Type the procedure code in the SQL Commands window Click on the “Save” button and save the procedure code Retrieve the saved code from “Saved SQL” in SQL Commands Modify the code in the SQL Commands window Execute the code to re-create the procedure
Execute the procedure from USER_SOURCE data dictionary view
Execute the code to create the procedure
Enter parameters and data type
Invoke the procedure from an anonymous block
Which of the following is a valid naming convention for an identifier? (Choose two.) (1) Points (Choose all correct answers)
Can include letters or numbers
Cannot contain a reserved word
Can be over 30 characters
Can start with a number or special character
PL/SQL can be used not only with an Oracle database, but also with any kind of relational database. True or False? (1) Points
True
False
Which of the following best describes a database transaction?
All the DML statements in a single PL/SQL block
A related set of SQL DML statements which must be executed either completely or not at all
A single SQL statement that updates multiple rows of a table
A SELECT statement based on a join of two or more database tables
Examine the following code: BEGIN FOR I IN 1..5 LOOP FOR j IN 1..8 LOOP EXIT WHEN j = 7; DBMS_OUTPUT.PUT_LINE(i || j); END LOOP; END LOOP; END; How many lines of output will be displayed when this code is executed?
35
6
30
40
When multiple SQL statements are combined into PL/SQL blocks, performance improves. True or False? (1) Points
True
False
The fact that PL/SQL is portable is a good thing because: (1) Points
Exceptions can be ported to different operating systems
Blocks can be sent to the operating system.
PL/SQL code can be developed on one platform and deployed on another
PL/SQL code can be run on any operating system without a database
In a FOR loop, an explicitly declared counter is automatically incremented by 1 for each iteration of the loop. True or False? (1) Points
True
False
The UTL_MAIL package allows sending email from the Oracle database to remote recipients. Mark for Review (1) Points
True
False
A cursor FOR loop using a subquery can shorten code length when compared to an explicit cursor declaration. True or False?
True
False
Which of the following tools can NOT be used to develop and test PL/SQL code?
Oracle Jdeveloper
Oracle Application Express
Oracle JSQL
Oracle iSQL*Plus
Which statement best describes when a FOR loop should be used?
When the number of iterations is known
When testing the value in a Boolean variable
When the controlling condition must be evaluated at the start of each iteration
What will be the value of variable c after the following code is executed? DECLARE a BOOLEAN := TRUE; b BOOLEAN := NULL; c NUMBER; BEGIN IF a AND b THEN c := 2; ELSIF a OR b THEN c := 0; ELSE c := 1; END IF; END; (1) Points
1
Null
0
2
Which of the following variable declarations does NOT use a number data type?
V_count PLS_INTEGER := 0;
V_median_age NUMBER(6,2);
V_students LONG;
V_count BINARY_INTEGER;
Which of the following is NOT allowed when using multiple cursors with parameters?
Declaring a cursor based on a join
Declaring a cursor FOR UPDATE
OPENing more than one cursor at the same time
Using cursor FOR loops
None of these--they are all allowed.
Examine the following code: DECLARE v_salary NUMBER(6); v_constant NUMBER(6) := 15000; v_result VARCHAR(6) := 'MIDDLE'; BEGIN IF v_salary != v_constant THEN v_result := 'HIGH'; ELSE v_result := 'LOW'; END IF; END; What is the final value of v_result? (1) Points
HIGH
LOW
MIDDLE
Null
1.Using parameters with a cursor, you can open and close the cursor several times in a block, returning a different active set each time. True or False?
True
False
What will be displayed when the following block is executed?: DECLARE x NUMBER(6) := 0 ; BEGIN FOR I IN 1..10 LOOP FOR j IN 1..5 LOOP x := x+1 ; END LOOP; END LOOP; DBMS_OUTPUT.PUT_LINE(x); END;
5
10
15
50
When using multiple nested cursors, what kinds of loops can you use?
Cursor FOR loops only.
Basic loops only.
WHILE loops only.
None of the above.
All of the above.
Which of the following are valid identifiers? (Choose two.) (1) Points (Choose all correct answers)
yesterday
Yesterday's date
number_of_students_in_the_class
V$testresult
#students
Look at this SQL statement: MERGE INTO old_trans ot USING new_trans nt ON (ot.trans_id = nt.trans_id) .... ; OLD_TRANS is the source table and NEW_TRANS is the target table. True or false?
True
False
What will be displayed when this block is executed? DECLARE v_bool1 BOOLEAN := NULL; v_bool2 BOOLEAN := NULL; v_char VARCHAR(10) := 'Start'; BEGIN IF (v_bool1 = v_bool2) THEN v_char:='Equal'; ELSE v_char:='Not equal'; END IF; DBMS_OUTPUT.PUT_LINE(v_char); END; (1) Points
Equal
Not equal
Start
Othing will be displayed. The block will fail because you cannot compare two null values.
Which of the following statements about PL/SQL and SQL is true? (1) Points
PL/SQL and SQL are both ANSI-compliant.
PL/SQL and SQL can be used with many types of databases, including Oracle.
PL/SQL and SQL are both Oracle proprietary programming languages.
PL/SQL allows basic program logic and control flow to be combined with SQL statements.
Place the following statements in the correct sequence: OPEN my_curs; CLOSE my_curs; CURSOR my_curs IS SELECT my_column FROM my_table; FETCH my_curs INTO my_variable;
C,D,A,B
C,A,D,B
A,C,D,B
C,A,B,D
We want to create a log record automatically every time any DML operation is executed on either or both of the EMPLOYEES and DEPARTMENTS tables. What is the smallest number of triggers that must be create to do this?
One
Two
Three
Six
Eight
Using Oracle Application Express, you can create Web applications that include PL/SQL. True or False? (1) Points
True
False
{"name":"PL\/SQL - продължението", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"xamine the following code. At Line A, we want to assign a value of 25 to the outer block’s variable (V1). What must we do? DECLARE v_myvar NUMBER; — This is V1 BEGIN DECLARE v_myvar NUMBER := 8; BEGIN — Line A END; END;, CREATE TRIGGER emp_trigg — Line A BEGIN INSERT INTO log_table VALUES (USER, SYSDATE); END; Which of the following can NOT be coded at Line A?, Procedure TESTPROC accepts one parameter P1, whose value is up to 1000 characters in length. Which one of the following declares this parameter correctly?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}