Wednesday

PL/SQL FAQ'S

Question: What are the two types of subprograms? Answer: procedure and function -------------------------- Question: Which statement would you use to invoke a stored procedure in iSQL*Plus? Answer: EXECUTE ------------------------------------- Question: Which SQL statement allows a privileged user to assign privileges to other users? Answer: GRANT ------------------------------------- Question: Which column of the USER_OBJECTS data dictionary view contains the date and time a particular object was initially stored in the database? Answer: CREATED ------------------------------------------ Question: Which column of the USER_OBJECTS data dictionary view indicates whether the database object is a procedure, function, trigger, or package? Answer: OBJECT_TYPE ------------------------------------------------ Question: What is the syntax of the SHOW ERRORS SQL*Plus command? Answer: SHOW ERRORS [construct_type] [construct_name] --------------------------------------------------------- Question: Which two values are allowed for the STATUS column of the USER_OBJECTS data dictionary view? Answer: VALID and INVALID ---------------------------------------------------------------------- Question: Which system privilege allows a user to create procedures, functions, and packages? Answer: CREATE PROCEDURE ------------------------------------------------------------------------- Question: Which SQL statement allows a privileged user to remove privileges from a user? Answer: REVOKE ------------------------------------------------------------------------- Question: If you are not the object's owner, which privilege must you be granted to run a PL/SQL construct, such as a function or procedure? Answer: EXECUTE -------------------------------------------------------------------------- Question: Which view contains a STATUS column that indicates whether a database object is valid? Answer: USER_OBJECTS -------------------------------------------------------------------------- Question: Which system privilege is required to manually recompile a stored procedure owned by another user? Answer: ALTER ANY PROCEDURE ---------------------------------------------------------------------------- Question: What is returned when you use the SQL*Plus DESCRIBE command with a PL/SQL construct, such as a procedure or function? Answer: the construct's argument list --------------------------------------------------------------------------- Question: Which column of the USER_SOURCE data dictionary view contains the source code that defines the associated procedure, function, or package? Answer: TEXT --------------------------------------------------------------------------- Question: Where are BFILES stored? Answer: in a file stored outside of the database -------------------------------------------------------------------------- Question: What are the two distinct parts of an internal LOB? Answer: LOB value - data that constitutes the real object being stored LOB locator - a pointer to the location of the LOB value stored in the database ---------------------------------------------------------------------------- Question: Which database object provides for the administration of access and usage of BFILEs? Answer: DIRECTORY ---------------------------------------------------------------------------- Question: Which function would you use to initialize a BFILE column? Answer: BFILENAME --------------------------------------------------------------------------- Question: Which three types of LOBs are internal LOBs? Answer: CLOB, NCLOB, and BLOB ------------------------------------------------------------------------------ Question: Which LOB data type represents a multibyte character large object? Answer: NCLOB -------------------------------------------------------------------- Question: Which statement would you use to migrate a LONG column to a NCLOB column? Answer: ALTER TABLE ------------------------------------------------------------------------ Question: Which LOB data type represents a character large object? Answer: CLOB ----------------------------------------------------------------------- Question: Which DBMS_LOB procedure would you use to load a BFILE? Answer: DBMS_LOB.FILEOPEN ------------------------------------------------------- Question: Can you migrate a LONG column to a CLOB or NCLOB column? Answer: Yes ------------------------------------------------------- Question: Which supplied package manages LOBs? Answer: DBMS_LOB ------------------------------------------------------- Question: Can you migrate a LONG RAW column to a CLOB column? Answer: No. You can migrate a LONG RAW column to a BLOB column, not a CLOB column. -------------------------------------------------------------------------- Question: Are dependencies between objects residing on different databases handled the same as those residing on the same database? Answer: No. When remote referenced objects are marked invalid, any local dependent objects are not marked invalid ----------------------------------------------------------------------- Question: What does the utldtree.sql script do? Answer: It creates the DEPTREE_FILL procedure and two additional views, DEPTREE and IDEPTREE, which can be used to determine indirect dependencies between database objects. --------------------------------------------------------------------------------- Question: Which three guidelines can minimize recompilation failure? Answer: declaring identifiers using the %TYPE and %ROWTYPE attributes, using SELECT * notation in queries, and including a column list in INSERT statements --------------------------------------------------------------------------- Question: Does modifying a procedure's argument list affect the constructs that the procedure executes? Answer: No, but it does affect other constructs that reference the procedure ----------------------------------------------------------------------------- Question: What is automatic implicit recompilation? Answer: the process by which invalid subprograms are implicitly recompiled the next time they are referenced -------------------------------------------------------------------------------- Question: What happens when a change is made to a database object that is referenced by other database objects? Answer: All dependent objects are marked invalid. -------------------------------------------------------------------------------- Question: When a local procedure depends on another local procedure, and the called procedure is changed, when is the dependent procedure recompiled? Answer: the next time it is executed --------------------------------------------------------------------------------- Question: What are database objects that rely on database objects in a different database referred to as? Answer: remote dependent objects --------------------------------------------------------------------------------- Question: What are database objects that rely on another database object in the same database referred to as? Answer: local dependent objects ---------------------------------------------------------------------------------- Question: When a local procedure depends on a remote procedure and the remote procedure is modified,when is the local procedure recompiled? Answer: the second time it is executed after the change ---------------------------------------------------------------------------------- Question: Which standard data dictionary view can you use to display dependencies between database objects? Answer: USER_DEPENDENCIES ---------------------------------------------------------------------------------- Question: Which syntax can you use to manually recompile a package? Answer: ALTER PACKAGE package_name COMPILE; ------------------------------------------------------------------------------- Question: Which two views are created by running the utldtree.sql script? Answer: DEPTREE and IDEPTREE ------------------------------------------------------------------------------- Question: When does code included in the executable section of a package body execute? Answer: the first time the package is referenced within a session or when the package is recompiled ------------------------------------------------------------------------------- Question: Within a package, where would you include code that needs to execute only the first time the package is referenced within a session? Answer: in the executable section of a package body ------------------------------------------------------------------------------------ Question: Is a package variable accessible after the package has finished executing? Answer: Yes, the state of a package variable persists throughout the current user session. ------------------------------------------------------------------------------------- Question: What is an overloaded package? Answer: a package that contains two different subprograms with the same name, but argument lists that differ in number, order, or data type family ------------------------------------------------------------------------------------- Question: Which compiler directive would you use to specify the purity level of a function? Answer: PRAGMA RESTRICT_REFERENCES ------------------------------------------------------------------------------------ Question: What are package subprograms that reference each other known as? Answer: mutually referential subprograms ---------------------------------------------------------------------------------- Question: Can stand-alone stored procedures be overloaded? Answer: No, only local subprograms or packaged subprograms can be overloaded ----------------------------------------------------------------------------------- Question: When using forward declaration, what must be specified in the package specification prior to declaring the calling subprogram? Answer: the subprogram name and formal parameter list ---------------------------------------------------------------------------------- Question: Must procedures within a package have a unique name? Answer: No. By overloading a package, you can create two procedures with the same name, but the procedures' argument lists must differ in number, order, or data type family ----------------------------------------------------------------------------------- Question: What are the three parts of a package body? Answer: header, declaration, and executable section --------------------------------------------------------------------------------- Question: What are variables declared in a package specification or body known as? Answer: package variables -------------------------------------------------------------------------------- Question: Does PL/SQL allow forward references? Answer: No, you must declare a construct before referencing it. ------------------------------------------------------------------------------ Question: What is a forward declaration? Answer: when you declare only a subprogram specification, prior to declaring the body of the subprogram,so that other subprograms may reference it -------------------------------------------------------------------------------- Question: In which three languages can a procedure being called in a CALL statement be written? Answer: PL/SQL, C, or Java --------------------------------------------------------------------------------- Question: What does a CALL statement within a trigger body allow you to do? Answer: call a stored procedure ------------------------------------------------------------------------------- Question: What are the three DDL_Event triggers? Answer: CREATE, ALTER, and DROP ------------------------------------------------------------------------------- Question: What are the two options for the LOGON and LOGOFF triggers? Answer: ON SCHEMA - fires for the specific user ON DATABASE - fires for all users ------------------------------------------------------------------------------- Question: Which data dictionary view contains the status of a trigger and the date the trigger was created? Answer: USER_OBJECTS ------------------------------------------------------------------------------------ Question: If a database trigger fails, is the DML operation that invoked the trigger rolled back? Answer: Yes ------------------------------------------------------------------------------------ Question: Which three programming languages can be used to create a database trigger? Answer: PL/SQL, C, or Java --------------------------------------------------------------------------- Question: If an error occurs when a trigger is being created, what happens? Answer: The trigger is still created. -------------------------------------------------------------------------- Question: What does the CREATE TRIGGER privilege allow a user to do? Answer: to create database triggers on a table in their schema and to drop and alter the database triggers they have created --------------------------------------------------------------------------- Question: Do DDL triggers fire for the creation of tablespaces? Answer: Yes. DDL triggers fire for clusters, functions, indexes, packages, procedures, roles, sequences,synonyms, tables, tablespaces, triggers, types, views, or users. ----------------------------------------------------------------------------------- Question: What is the result if a row level database trigger attempts to read the same table on which the triggering event is defined? Answer: An error occurs because the table is mutating ----------------------------------------------------------------------------------- Question: Should you place a colon at the end of a CALL statement? Answer: No ----------------------------------------------------------------------------------- Question: Which column of the USER_TRIGGERS view contains the source code of the database trigger? Answer: TRIGGER_BODY ---------------------------------------------------------------------------------- Question: What are the five Database_event triggers? Answer: AFTER SERVERERROR, AFTER LOGON, BEFORE LOGOFF, AFTER STARTUP, and BEFORE SHUTDOWN ---------------------------------------------------------------------------------- Question: Which data dictionary view could you query to display compilation errors that occurred when a trigger was compiled? Answer: USER_ERRORS ---------------------------------------------------------------------------------- Question: Which two data dictionary views could you use to display all triggers that you and other users have created and that you have access to? Answer: ALL_OBJECTS and ALL_TRIGGERS ------------------------------------------------------------------------------------ Question: Which command could you use in iSQL*Plus to see compilation errors that occurred when a trigger was compiled? Answer: SHOW ERRORS ------------------------------------------------------------------------------------ Question: After compiling a trigger, which SQL*Plus command can you use to display compilation errors? Answer: SHOW ERRORS ------------------------------------------------------------------------------------ Question: If you have the appropriate privileges, which two data dictionary views could you query to display all triggers defined on a table? Answer: DBA_OBJECTS and DBA_TRIGGERS ------------------------------------------------------------------------------------ Question: If you have the appropriate privileges, which two data dictionary views could you query to display all triggers defined on a table? Answer: DBA_OBJECTS and DBA_TRIGGERS ------------------------------------------------------------------------------------ Question: Which type of database trigger allows you to capture the values that exist before the trigger body executes and the values after the trigger body executes? Answer: row level, because a row level trigger fires once for each affected row ------------------------------------------------------------------------------------ Question: Which two triggers monitor how often you log on and log off the database? Answer: LOGON and LOGOFF ------------------------------------------------------------------------------------ Question: Can a function be invoked from within a SELECT clause of a SQL statement? Answer: Yes, as long as the function returns an Oracle server internal data type and does not modify database tables. ------------------------------------------------------------------------------------ Question: Can a function include more than one RETURN statement in its executable section? Answer: Yes, this is customary in an IF block to return different values based on some condition. However, only one of the RETURN statements executes. ------------------------------------------------------------------------------------ Question: Can you rollback a DROP FUNCTION statement? Answer: No. The DROP FUNCTION statement is a DDL command and is, therefore, auto-committing. ------------------------------------------------------------------------------------ Question: When passing a SQL*Plus variable to a function, why is the variable prefixed with a colon? Answer: This statement is actually an implicit PL/SQL anonymous block, and when referencing host variables within a PL/SQL construct, you must use the colon to distinguish them from local PL/SQL variables. ------------------------------------------------------------------------------------ Question: Which statement should you use to permanently remove a function from the database? Answer: DROP FUNCTION ------------------------------------------------------------------------------------ Question: Which statement is the equivalent to removing a function and recreating it? Answer: CREATE AND REPLACE FUNCTION ------------------------------------------------------------------------------------ Question: Must a function return a value? Answer: Yes, functions must return a single value ---------------------------------------------------------------------------------- Question: How is a function invoked? Answer: as part of an expression ---------------------------------------------------------------------------------- Question: Can functions be invoked using the EXECUTE statement? Answer: No, functions must be executed as part of an expression. ----------------------------------------------------------------------------- Question: How many IN arguments are required for a stored function? Answer: None, a function can return a value that is not derived from an input argument. ------------------------------------------------------------------------------- Question: What are the four sections of a PL/SQL function? Answer: header, declaration, executable, and exception --------------------------------------------------------------------------------- Question: What is the purpose of the RETURN statement included in a function's header section? Answer: to specify the data type to be returned --------------------------------------------------------------------------------- Question: Will a function compile successfully without a RETURN statement in the executable section? Answer: Yes. Although a function will compile successfully without a RETURN statement in the executable section, it will generate a run-time error if no value is returned to the calling environment when executed ------------------------------------------------------------------------------------ Question: Which statement would you issue to drop a stored function from the database? Answer: DROP FUNCTION ------------------------------------------------------------------------------------ Question: Can a user-defined function be referenced in a FROM clause of a SQL statement? Answer: No ----------------------------------------------------------------------------------- Question: When invoking functions, what is used to transfer values to and from the calling environment? Answer: formal parameters ---------------------------------------------------------------------------------- Question: Which three components are included in a stored function header? Answer: the function name, the argument list, and the RETURN statement that identifies the data type to be returned ----------------------------------------------------------------------------------- Question: Which type of named subprogram must you use to return a value within a SQL statement? Answer: a function ----------------------------------------------------------------------------------- Question: What is the syntax for defining a stored function? Answer: CREATE [OR REPLACE] FUNCTION function_name [(parameter1 [mode1] datatype1, parameter2 [mode2] datatype2, ... )] RETURN datatype IS AS ... BEGIN ... [EXCEPTION] ... END function_name; --------------------------------------------------------------------------------- Question: Can functions be invoked within a CHECK constraint? Answer: No ---------------------------------------------------------------------------------- Question: Which PL/SQL statement passes a function value back to the calling environment? Answer: RETURN ---------------------------------------------------------------------------------- Question: When defining a function, where is the argument list defined? Answer: in the header section after the procedure name, but before the RETURN statement ---------------------------------------------------------------------------------- Question: What is the purpose of the RETURN statement in the executable section of a function? Answer: to return the value of the parameter to the calling environment ---------------------------------------------------------------------------------- Question: If you recreate a function using the CREATE AND REPLACE FUNCTION statement, what happens to the privileges on the function? Answer: The function privileges remain the same. ----------------------------------------------------------------------------------- Question: For a function to compile successfully, what is the minimum number of RETURN statements? Answer: Two. One RETURN statement must be included in the header section to specify the data type to be returned, and another RETURN statement must be included in the executable section to return the value. ----------------------------------------------------------------------------------- Question: Which procedure in the Oracle-supplied DBMS_OUTPUT package places a line of text into the buffer and displays the buffer contents to the screen? Answer: PUT_LINE ----------------------------------------------------------------------------------- Question: Which procedure of the DBMS_OUTPUT package retrieves one or more lines from the buffer into a PL/SQL table? Answer: GET_LINES ----------------------------------------------------------------------------------- Question: Why would you use the RECEIVE_MESSAGE function of the DBMS_PIPE package? Answer: to retrieve a message from the named pipe and place it into the local message buffer to be unpacked by the UNPACK_MESSAGE procedure ------------------------------------------------------------------------------------ Question: Which action does the EXECUTE function of the DBMS_SQL package perform? Answer: It executes the SQL statement and returns the total number of rows processed. ------------------------------------------------------------------------------------ Question: Which procedure of the DBMS_OUTPUT package retrieves a single line from the buffer into a variable? Answer: GET_LINE ----------------------------------------------------------------------------------- Question: Which Oracle-supplied package can you use to display messages in a SQL*Plus session? Answer: DBMS_OUTPUT ------------------------------------------------------------------------------------ Question: Using DBMS_SQL, what happens during the fetch phase of executing a SQL statement? Answer: Rows are selected based on the query criteria. ----------------------------------------------------------------------------------- Question: Which procedure of the DBMS_SQL package allows you to assign values to bind variables at runtime? Answer: BIND_VARIABLE ------------------------------------------------------------------------------------ Question: Which procedure of the DBMS_SQL package allows you to assign values to bind variables at runtime? Answer: BIND_VARIABLE ------------------------------------------------------------------------------------ Question: Which procedure of the DBMS_DDL package can you use to generate statistics for a given table? Answer: ANALYZE_OBJECT ----------------------------------------------------------------------------------- Question: Which SQL*Plus command must you first issue to view output from DBMS_OUTPUT? Answer: SET SERVEROUTPUT ON ----------------------------------------------------------------------------------- Question: What happens during the parse phase of executing a SQL statement? Answer: The statement is checked for syntax errors and validity, all object references are resolved, and the user's privileges to those objects are checked. ----------------------------------------------------------------------------------- Question: In the DBMS_OUTPUT package, which two procedures can you use to place messages in a buffer for future use? Answer: PUT and PUT_LINE ----------------------------------------------------------------------------------- Question: Which function of the DBMS_PIPE package sends the contents of the message buffer to the pipe? Answer: SEND_MESSAGE ----------------------------------------------------------------------------------- Question: Which action does the NEW_LINE procedure of the DBMS_OUTPUT package perform? Answer: It places an end-of-line marker in the output buffer. ----------------------------------------------------------------------------------- Question: Which procedure of the DBMS_DDL Oracle-supplied package allows you to compile PL/SQL constructs? Answer: ALTER_COMPILE ------------------------------------------------------------------------------------ Question: Which two Oracle-supplied packages could you use if you needed to perform DDL within a PL/SQL procedure? Answer: DBMS_DDL or DBMS_SQL ------------------------------------------------------------------------------------ Question: Which Oracle-supplied package provides many subprograms for managing both local and distributed transactions? Answer: DBMS_TRANSACTION ----------------------------------------------------------------------------------- Question: Which function of the DBMS_SQL package opens a new cursor and returns a cursor identification number? Answer: OPEN_CURSOR ----------------------------------------------------------------------------------- Question: Which Oracle-supplied package allows two or more sessions connected to the same instance to communicate through a pipe? Answer: DBMS_PIPE ----------------------------------------------------------------------------------- Question: Which function of the DBMS_SQL package fetches a row or rows from an open cursor? Answer: FETCH_ROWS ---------------------------------------------------------------------------------- Question: Using DBMS_SQL, what happens during the bind phase of executing a SQL statement? Answer: Oracle obtains the needed values for any bind variables included in the SQL statement. --------------------------------------------------------------------------------- Question: Which term refers to SQL statements that are NOT completed until run-time? Answer: dynamic SQL --------------------------------------------------------------------------------- Question: What is the difference between the PUT and PUT_LINE procedures of the Oracle-supplied DBMS_OUTPUT package? Answer: The PUT_LINE procedure also appends a newline character ---------------------------------------------------------------------------------- Question: Which action does the CLOSE_CURSOR procedure of the DBMS_SQL package accomplish? Answer: It closes a specified cursor that was previously opened using DBMS_SQL. --------------------------------------------------------------------------------- Question: What does the BIND_VARIABLE procedure of the DBMS_SQL package do? Answer: It binds a scalar value to a variable named in the parsed SQL statement of a given cursor ----------------------------------------------------------------------------------- Question: Which function of the DBMS_SQL package opens a cursor and is always required? Answer: OPEN_CURSOR ---------------------------------------------------------------------------------- Question: Which Oracle-supplied package can you use to create jobs or schedules? Answer: DBMS_JOB ---------------------------------------------------------------------------------- Question: Which four basic steps would you take to dynamically execute a SQL statement using the DBMS_SQL package? Answer: 1. Call the OPEN_CURSOR function to allocate memory and obtain a pointer. 2. Call the PARSE procedure to validate the SQL statement. 3. Call the EXECUTE function to run the SQL statement. 4. Call the CLOSE_CURSOR procedure to close the cursor. ----------------------------------------------------------------------------------- Question: Which procedure of the DBMS_SQL package immediately parses a specified SQL statement? Answer: PARSE ------------------------------------------------------------------------------------ Question: Which statement would you use to prevent a single trigger from executing? Answer: ALTER TRIGGER ------------------------------------------------------------------------------------ Question: Which statement would you use to permanently remove a trigger from the database? Answer: DROP TRIGGER ------------------------------------------------------------------------------------ Question: Which keywords can you include in an ALTER TABLE statement to temporarily disable all triggers on a table? Answer: DISABLE ALL TRIGGERS ------------------------------------------------------------------------------------- Question: When creating a DML trigger, which five components must be identified? Answer: trigger name, timing, DML event, table, and trigger body ------------------------------------------------------------------------------------- Question: Which keyword should you use if the trigger body should execute prior to the triggering event? Answer: BEFORE ------------------------------------------------------------------------------------ Question: Which keyword must you include in an ALTER TRIGGER statement to temporarily prevent a trigger from executing? Answer: DISABLE ------------------------------------------------------------------------------------ Question: Which two keywords specify trigger timing in relation to the triggering event? Answer: BEFORE and AFTER ------------------------------------------------------------------------------------ Question: By default, are triggers statement level or row level? Answer: statement level ------------------------------------------------------------------------------------ Question: Which special type of row trigger can be coded for views to fire the trigger in place of executing the triggering statement? Answer: INSTEAD OF ----------------------------------------------------------------------------------- Question: What is the syntax for creating a statement trigger? Answer: CREATE [OR REPLACE] TRIGGER trigger_name timing event1 [OR event2 OR event3] ON table_name BEGIN ... END; ---------------------------------------------------------------------------------- Question: Which additional keywords must a row trigger include? Answer: FOR EACH ROW ---------------------------------------------------------------------------------- Question: What happens when you disable a database trigger? Answer: The trigger remains in the data dictionary, but will not execute until it is re-enabled ----------------------------------------------------------------------------------- Question: Which type of database trigger fires once for the triggering event? Answer: statement trigger ------------------------------------------------------------------------------------ Question: Which syntax can you use to disable a trigger? Answer: ALTER TRIGGER trigger_name DISABLE; ----------------------------------------------------------------------------------- Question: Which two actions occur when a database trigger terminates abnormally? Answer: A rollback occurs, and the triggering statement is rolled back. ----------------------------------------------------------------------------------- Question: When would you use the UPDATE OF keywords in a trigger definition? Answer: if you want the trigger to fire in response to updating a specific column or columns in the specified table ------------------------------------------------------------------------------------ Question: Which keyword should you include if the trigger body should execute following the triggering event? Answer: AFTER --------------------------------------------------------------------------------- Question: Database triggers can be defined on which types of database objects? Answer: tables or views ------------------------------------------------------------------------------- Question: Can you reference the OLD and NEW qualifiers in a statement level trigger? Answer: No, only in a row level trigger that affects each row processed ------------------------------------------------------------------------------- Question: How are trigger predicates like INSERTING, UPDATING, and DELETING usually referenced? Answer: in an IF statement ------------------------------------------------------------------------------- Question: In the trigger body, which determines how many times the trigger body will execute? Answer: trigger type -------------------------------------------------------------------------------- Question: Within row triggers, for which purpose are the OLD and NEW qualifiers used? Answer: to reference old and new values of columns -------------------------------------------------------------------------------- Question: Which data dictionary view would you use to display the source code for only database triggers that you have created? Answer: USER_TRIGGERS -------------------------------------------------------------------------------- Question: What is the syntax to re-enable a database trigger? Answer: ALTER TRIGGER trigger_name ENABLE; -------------------------------------------------------------------------------- Question: Other than dropping a trigger, how can you temporarily prevent the trigger from executing? Answer: by disabling the trigger -------------------------------------------------------------------------------- Question: Which syntax would you use to prevent all triggers on a given table from executing? Answer: ALTER TABLE. . . DISABLE ALL TRIGGERS; -------------------------------------------------------------------------------- Question: Which type of trigger fires for each row affected by the triggering event? Answer: row trigger -------------------------------------------------------------------------------- Question: When a trigger is defined to execute for multiple DML statements, how can you determine the type of statement that invoked the trigger? Answer: by referencing the INSERTING, UPDATING, and DELETING trigger predicates -------------------------------------------------------------------------------- Question: What is the syntax for creating a row level trigger? Answer: CREATE [OR REPLACE] TRIGGER trigger_name timing event1 [OR event2 OR event3] ON table_name [REFERENCING OLD AS old NEW AS new] FOR EACH ROW [WHEN condition] BEGIN ... END; -------------------------------------------------------------------------------- Question: Which statement should you use to compile a database trigger? Answer: ALTER TRIGGER -------------------------------------------------------------------------------- Question: Which additional clause can be included in the header of a database trigger to determine for which affected rows the trigger should execute? Answer: WHEN -------------------------------------------------------------------------------- Question: What is a pragma? Answer: a directive to the PL/SQL compiler -------------------------------------------------------------------------------- Question: Can public package variables be referenced outside the package? Answer: Yes, by prefixing them with the package name -------------------------------------------------------------------------------- Question: What is the syntax for creating a package specification? Answer: CREATE [OR REPLACE] PACKAGE package_name IS AS ... END package_name; -------------------------------------------------------------------------------- Question: Can procedures declared only in the package body be invoked from outside the package? Answer: No, they are considered to be private -------------------------------------------------------------------------------- Question: Can packages be nested? Answer: No -------------------------------------------------------------------------------- Question: Can private package variables be referenced outside the package? Answer: No, only by other constructs within the package -------------------------------------------------------------------------------- Question: What is meant by the "purity level" of a package? Answer: the extent to which the package is free from adverse database side effects -------------------------------------------------------------------------------- Question: Which types of programming constructs can be included in a package? Answer: cursors, variables, types, exceptions, procedures, and functions -------------------------------------------------------------------------------- Question: Which elements are included in a package specification? Answer: the package name, public declarations, and declarations of public PL/SQL subprograms included in the package body -------------------------------------------------------------------------------- Question: From where can public variables within a package be referenced? Answer: from inside and outside of the package -------------------------------------------------------------------------------- Question: Of which type are variables declared within the declaration section of a package body? Answer: private -------------------------------------------------------------------------------- Question: In a package, must all constructs be declared in the body? Answer: Yes, all constructs must be declared in the package body if a package body is required -------------------------------------------------------------------------------- Question: Of which type are variables declared in the package specification? Answer: public -------------------------------------------------------------------------------- Question: Which elements are included in a package body? Answer: the package name, private declarations, and public and private PL/SQL subprograms -------------------------------------------------------------------------------- Question: Which four purity levels can be specified in a PRAGMA RESTRICT_REFERENCES statement? Answer: WNDS - Writes no database state RNDS - Reads no database state WNPS - Writes no package state RNPS - Reads no package state -------------------------------------------------------------------------------- Question: What is the syntax for creating a package body? Answer: CREATE [OR REPLACE] PACKAGE BODY package_name IS AS ... END package_name -------------------------------------------------------------------------------- Question: Must all packages have a specification and a body? Answer: No, packages that do not contain procedures or functions do not require a body -------------------------------------------------------------------------------- Question: What is a group of logically-related subprograms and constructs called? Answer: a package -------------------------------------------------------------------------------- Question: Within a package, from where can private variables be referenced? Answer: from within any construct of the package -------------------------------------------------------------------------------- Question: When executing a procedure using the EXECUTE command, how must you reference procedures that are defined within a package? Answer: using the package name as a prefix or package_name.procedure_name (arguments) -------------------------------------------------------------------------------- Question: Which statement permanently removes a package specification and body from the database? Answer: DROP PACKAGE package_name -------------------------------------------------------------------------------- Question: Which statement permanently removes a package body from the database without affecting the package's specification? Answer: DROP PACKAGE BODY package_name; -------------------------------------------------------------------------------- Question: a package contains more than one subprogram and a variable is declared in the package body before any of the subprograms, where is the variable visible? Answer: in all of the package's subprograms, but not outside the package -------------------------------------------------------------------------------- Question: In a package, where are private constructs declared? Answer: in the package body only -------------------------------------------------------------------------------- Question: When is a package loaded into memory? Answer: when any construct within the package is invoked -------------------------------------------------------------------------------- Question: Which compiler directive indicates that the package body should not compile correctly if it fails one of its references? Answer: PRAGMA RESTRICT_REFERENCES -------------------------------------------------------------------------------- Question: When is the order of declaration of constructs in a package important? Answer: when the constructs reference each other, otherwise order is irrelevant -------------------------------------------------------------------------------- Question: Why would you use a PRAGMA statement in a PL/SQL program unit? Answer: to pass information to the PL/SQL compiler -------------------------------------------------------------------------------- Question: Is there a defined limit on the number of subprograms that can be defined in a package? Answer: No -------------------------------------------------------------------------------- Question: Why would you define a package specification without a corresponding package body? Answer: to define public variables -------------------------------------------------------------------------------- Question: What are the two components of a database package? Answer: a specification and a body -------------------------------------------------------------------------------- Question: Which part of a package, the specification or the body, is required? Answer: the specification -------------------------------------------------------------------------------- Question: Which SQL*Plus command should you use to invoke a procedure? Answer: EXECUTE -------------------------------------------------------------------------------- Question: Which compiler directive would you include in the declaration section of a PL/SQL stored procedure to associate an error code with a user-defined exception? Answer: PRAGMA EXCEPTION_INIT (exception_name, number); -------------------------------------------------------------------------------- Question: In a named procedure, do you use the DECLARE statement to declare local variables? Answer: No, you use the DECLARE statement only in anonymous blocks. -------------------------------------------------------------------------------- Question: What are the parameters passed into a procedure at invocation called? Answer: actual parameters -------------------------------------------------------------------------------- Question: When calling a procedure, which method of passing parameters associates actual parameters with formal parameters based on the order in which the parameters were declared? Answer: positional -------------------------------------------------------------------------------- Question: Where is the declarative section of a procedure located? Answer: between the IS or AS keyword and the BEGIN keyword -------------------------------------------------------------------------------- Question: When passing a parameter to a procedure, which parameter mode should you use if the value will only be read and NOT modified? Answer: IN -------------------------------------------------------------------------------- Question: When would you use a local subprogram? Answer: when only the existing PL/SQL block needs to reference the code -------------------------------------------------------------------------------- Question: Can you use both named and positional notation within the same subprogram call? Answer: Yes -------------------------------------------------------------------------------- Question: When creating a procedure using a CREATE OR REPLACE PROCEDURE statement, where is the source code of the procedure stored? Answer: in the data dictionary -------------------------------------------------------------------------------- Question: Which statement would you use to remove a procedure from the database? Answer: DROP PROCEDURE -------------------------------------------------------------------------------- Question: When defining a parameter in a procedure's formal parameter list, how can you specify the data type of the parameter? Answer: by specifying a valid Oracle data type or by using %TYPE or %ROWTYPE -------------------------------------------------------------------------------- Question: What is a named PL/SQL procedure stored on the Oracle server called? Answer: a server-side procedure -------------------------------------------------------------------------------- Question: Which two actions occur when a server-side procedure terminates abnormally? Answer: A rollback occurs, and the raised exception is passed back to the calling environment. -------------------------------------------------------------------------------- Question: When defining a procedure, what are the three parameter modes allowed for formal parameters? Answer: IN, OUT, and IN OUT -------------------------------------------------------------------------------- Question: Which keywords can be included in a CREATE PROCEDURE statement to drop and re-create an already existing stored procedure? Answer: OR REPLACE -------------------------------------------------------------------------------- Question: What is a subprogram defined in the declarative section of another PL/SQL block called? Answer: a local subprogram -------------------------------------------------------------------------------- Question: If no mode is specified for a formal parameter in a procedure declaration, to which mode does the parameter default? Answer: IN -------------------------------------------------------------------------------- Question: What should you do to handle an unexpected run-time error in a PL/SQL stored procedure? Answer: Declare an exception, associate an error code, and include an EXCEPTION block to handle the error -------------------------------------------------------------------------------- Question: If a server-side procedure encounters an error for which there is no explicit error-handling logic, what happens to the raised exception? Answer: It is returned to the calling procedure or the calling environment -------------------------------------------------------------------------------- Question: From which underlying data dictionary view does the SHOW ERRORS command retrieve information about procedure compilation errors? Answer: USER_ERRORS -------------------------------------------------------------------------------- Question: When defining parameters in a procedure's formal parameter list, which keyword can you include to have the parameter automatically assigned a value if no value is explicitly passed to the procedure? Answer: DEFAULT -------------------------------------------------------------------------------- Question: When calling a procedure, how do you specify the passed parameters using named notation? Answer: by passing each parameter including the parameter name and the value assignment with the =>operator between the parameter name and value -------------------------------------------------------------------------------- Question: When declaring procedure parameters in a formal parameter list, which four pieces of information can be declared for each parameter? Answer: name, mode, data type, and default value -------------------------------------------------------------------------------- Question: In a procedure declaration, where is the formal parameter list specified? Answer: after the procedure name and before the IS or AS keyword -------------------------------------------------------------------------------- Question: Which type of named subprogram would you usually create to perform an action without returning a value? Answer: procedure -------------------------------------------------------------------------------- Question: How do you declare a user-defined exception within a PL/SQL stored procedure? Answer: Declare a local variable of type EXCEPTION. -------------------------------------------------------------------------------- Question: Which keywords surround the executable section of a stored procedure? Answer: BEGIN and END, or BEGIN and EXCEPTION if the procedure contains an exception section -------------------------------------------------------------------------------- Question: Which two parameter modes allow you to return values to the calling environment? Answer: OUT and IN OUT -------------------------------------------------------------------------------- Question: What is the syntax for creating a procedure? Answer: CREATE [OR REPLACE] PROCEDURE procedure_name [(parameter1 [mode1] data type, parameter2 [mode2] data type, ...)] IS AS ... BEGIN ... ]EXCEPTION] ... END [procedure_name] -------------------------------------------------------------------------------- Question: Can you roll back a DROP PROCEDURE statement? Answer: No, the DROP PROCEDURE statement is a DDL command and is, therefore, auto-committing -------------------------------------------------------------------------------- Question: In a procedure definition, where are local variables declared? Answer: after the IS or AS keyword, but before the BEGIN keyword -------------------------------------------------------------------------------- Question: What are the parameters in the procedure declaration known as? Answer: formal parameters -------------------------------------------------------------------------------- Question: When calling a procedure, how do you specify the passed parameters using positional notation? Answer: passing only the parameter values separated by commas -------------------------------------------------------------------------------- Question: If you have defined a variable using the SQL*Plus VARIABLE command, how must you reference that variable if you pass it as a procedure parameter in an EXECUTE command? Answer: as a host bind variable -------------------------------------------------------------------------------- Question: Which SQL*Plus command can you use to display compilation errors generated as a result of issuing a CREATE OR REPLACE PROCEDURE statement? Answer: SHOW ERRORS -------------------------------------------------------------------------------- Question: Which two data dictionary views can you query to retrieve the source code of a procedure that you created? Answer: ALL_SOURCE and USER_SOURCE -------------------------------------------------------------------------------- Question: In a PL/SQL stored procedure, where must any local subprograms be declared? Answer: between the IS or AS keyword and the BEGIN statement, after all local variable declarations -------------------------------------------------------------------------------- Question: Which section of a stored procedure body is the only section that is required? Answer: executable section -------------------------------------------------------------------------------- Question: Which SQL*Plus command should you use to create a variable that will hold a return value from a called procedure? Answer: VARIABLE -------------------------------------------------------------------------------- Question: Which data dictionary view can you query to display compilation errors that you encountered when creating a procedure or function? Answer: USER_ERRORS. These errors are also visible in ALL_ERRORS and DBA_ERRORS -------------------------------------------------------------------------------- Question: Which parameter mode must be used for parameters that will be passed into a procedure,modified by the procedure, and passed back to the calling program? Answer: IN OUT -------------------------------------------------------------------------------- Question: Where is a local subprogram visible? Answer: only from within the procedure in which it is defined -------------------------------------------------------------------------------- Question: Which parameter mode would you use for a formal parameter that needed to be read-only? Answer: IN -------------------------------------------------------------------------------- Question: Name the four sections of a PL/SQL stored procedure. Answer: header, declaration, executable, and exception -------------------------------------------------------------------------------- Question: How can you constrain a formal parameter of a procedure to a data type and precision from an underlying scalar database column? Answer: Use the %TYPE attribute. -------------------------------------------------------------------------------- Question: When running a procedure using the SQL*Plus EXECUTE command, how must the parameter list passed to the procedure be offset? Answer: using parentheses -------------------------------------------------------------------------------- Question: Which piece of information can you optionally include with the END statement of a procedure? Answer: the name of the procedure -------------------------------------------------------------------------------- Question: Can a procedure be called from within a SQL statement? Answer: No, procedures cannot be called from within a SQL statement, but rather are executed as a PL/SQL statement -------------------------------------------------------------------------------- Question: Which statement would you use to re-create a procedure that already exists in the database? Answer: CREATE OR REPLACE PROCEDURE -------------------------------------------------------------------------------- Question: How can a procedure return a value? Answer: by including an OUT parameter in the procedure's formal parameter list -------------------------------------------------------------------------------- Question: Which additional clause(s) can be included within the exception block of a PL/SQL subprogram to execute different logic for different user-defined exceptions? Answer: WHEN exception_name THEN -------------------------------------------------------------------------------- Question: Can a formal parameter defined with a mode of OUT be placed on the right-hand side of an assignment operator? Answer: No, it can only be placed on the left-hand side of an assignment operator because an OUT argument cannot be read. -------------------------------------------------------------------------------- Question: Which method of passing parameters must be used when NOT all arguments are specified or when arguments are specified in a different order than the declaration? Answer: named -------------------------------------------------------------------------------- Question: When would you use %ROWTYPE in an argument list? Answer: when passing a record argument to or from a procedure or function -------------------------------------------------------------------------------- Question: When a formal parameter is declared with a DEFAULT clause, can the procedure be called without passing this parameter at invocation? Answer: Yes, the parameter is assigned the value specified in the DEFAULT clause -------------------------------------------------------------------------------- Question: Must a procedure return a value? Answer: No. Procedures may return values using OUT arguments, but this is not required. -------------------------------------------------------------------------------- Question: Can formal parameters in a procedure declaration be constrained by explicitly specifying a length? Answer: No, only by data type. However, you can use %TYPE and %ROWTYPE -------------------------------------------------------------------------------- Question: Which formal parameter list would you use to pass a numeric value, v1, into the procedure, but allow the value to be optional, assuming the value of 1 if no value is passed? Answer: (v1 IN NUMBER DEFAULT 1) -------------------------------------------------------------------------------- Question: Where is the exception section of a PL/SQL stored procedure located? Answer: between the EXCEPTION and END keywords -------------------------------------------------------------------------------- Question: When calling a procedure, which method of passing parameters allows you to specify parameters in a different order than the order in which they were originally declared? Answer: named

Saturday

PL/SQL Quick References and Questions..

PL/SQL PROGRAMING (1Z0-147) 1. Examine this procedure: CREATE OR REPLACE PROCEDURE DELETE_PLAYER (V_IDIN NUMBER) IS BEGIN DELETE FROM PLAYER WHERE ID = V_ID EXCEPTION WHEN STATS_EXITS_EXCEPTION THEN DBMS_OUTPUT.PUT_LINE (Cannot Delete this player, child records exist in PLAYER_BAT_STAT table); END; What prevents this procedure from being created successfully? A. A comma has been left after the STATS_EXI ST_EXCEPTI ON exception. B. The STATS_EXIST_EXCEPTI ON has not been declared as a number. C. The STATS_EXIST_EXCEPTI ON has not been declared as an exception. D. Only predefined exceptions are allowed in the EXCEPTI ON section. Answer(s) C 2. Under which two circumstances do you design database triggers? (Choose two) A. To duplicate the functionality of other triggers. B. To replicate built-in constraints in the Oracle server such as primary key and foreign key. C. To guarantee that when a specific operation is performed, related actions are performed. D. For centralized, global operations that should be fired for the triggering statement, regardless of which user or application issues the statement. Answer(s) C,D 3. Local procedure A calls remote procedure B. Procedure B was compiled at 8 A.M. Procedure A was modified and recompiled at 9 A.M. Remote procedure B was later modified and recompiled at 11 A.M. The dependency mode is set to TI MESTAMP. What happens when procedure A is invoked at 1 P.M? A. There is no affect on procedure A and it runs successfully. B. Procedure B is invalidated and recompiles when invoked. C. Procedure A is invalidated and recompiles for the first time it is invoked. D. Procedure A is invalidated and recompiles for the second time it is invoked. Answer(s) D 4. What is a condition predicate in a DML trigger? A. A conditional predicate allows you to specify a WHEN-LOGGING-ON condition in the trigger body. B. A conditional predicate means you use the NEW and OLD qualifiers in the trigger body as a condition. C. A conditional predicate allows you to combine several DBM triggering events into one in the trigger body. D. A conditional predicate allows you to specify a SHUTDOWN or STARTUP condition in the trigger body. Answer(s) C You choose correct 5. This statement fails when executed: CREATE OR REPLACE TRIGGER CALC_TEAM_AVG AFTER INSERT ON PLAYER BEGIN INSERT INTO PLAYER_BATSTAT (PLAYER_ID, SEASON_YEAR, AT_BATS, HITS) VALUES (:NEW.ID, 1997, 0, 0) ; END; To which type must you convert the trigger to correct the error? A. Row B. Statement C. ORACLE FORM trigger D. Be f o r e Answer(s) A 6. An internal LOB is _____. A. A table. B. A column that is a primary key. C. Stored in the database. D. A file stored outside of the database, with an internal pointer to it from a database column. Answer(s) C 7. You need to disable all triggers on the EMPLOYEES table. Which command accomplishes this? A. None of these commands; you cannot disable multiple triggers on a table in one command. B. ALTER TRI GGERS ON TABLE e mp l o y e e s DI SABLE; C. ALTER e mp l o y e e s DI SABLE ALL TRI GGERS; D. ALTER TABLE employees DISABLE ALL TRIGGERS; Answer(s) D 8. You have a row level BEFORE UPDATE trigger on the EMP table. This trigger contains a SELECT statement on the EMP table to ensure that the new salary value falls within the minimum and maximum salary for a given job title. What happens when you try to update a salary value in the EMP table? A. The trigger fires successfully. B. The trigger fails because it needs to be a row level AFTER UPDATE trigger. C. The trigger fails because a SELECT statement on the table being updated is not allowed. D. The trigger fails because you cannot use the minimum and maximum functions in a BEFORE UPDATE trigger. Answer(s) C 9. You need to implement a virtual private database (vpd). In order to have the vpd functionality, a trigger is required to fire when every user initiates a session in the database. What type of trigger needs to be created? A. DML trigger B. System event trigger C. INSTEAD OF trigger D. Application trigger Answer(s) B 10. Which two program declarations are correct for a stored program unit? (Choose two) A. CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER B. CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER) RETURN NUMBER C. CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER) D. CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER(10,2) E. CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER(10, 2)) Answer(s) a,c 11. The creation of which four database objects will cause a DDL trigger to fire? (Choose four) A. Index B. Cluster C. Package D. Function E. Synonyms F. Dimensions G. Database links Answer(s) ABCD 12. Examine this code: CREATE OR REPLACE PROCEDURE insert_dept (p_location_id NUMBER) IS v_dept_id NUMBER(4); BEGIN INSERT INTO departments VALUES (5, .Education., 150, p_location_id); SELECT department_id INTO v_dept_id FROM employees WHERE employee_id=99999; END insert_dept; / CREATE OR REPLACE PROCEDURE insert_location ( p_location_id NUMBER, p_city VARCHAR2) IS BEGIN INSERT INTO locations(location_id, city) VALUES (p_location_id, p_city); insert_dept(p_location_id); END insert_location; / You just created the departments, the locations, and the employees table. You did not insert any rows. Next you created both procedures. You new invoke the insert_location procedure using the following command: EXECUTE insert_location (19, .San Francisco .) What is the result in this EXECUTE command? A. The locations, departments, and employees tables are empty. B. The departments table has one row. The locations and the employees tables are empty. C. The location table has one row. The departments and the employees tables are empty. D. The locations table and the departments table both have one row. The employees table is empty. Answer(s) D 13. What is true about stored procedures? A. A stored procedure uses the DELCLARE keyword in the procedure specification to declare formal parameters. B. A stored procedure is named PL/SQL block with at least one parameter declaration in the procedure specification. C. A stored procedure must have at least one executable statement in the procedure body. D. A stored procedure uses the DECLARE keyword in the procedure body to declare formal parameters. Answer(s) C 14. Examine the trigger: CREATE OR REPLACE TRIGGER Emp_count AFTER DELETE ON Emp_tab FOR EACH ROW DELCARE n INTEGER; BEGIN SELECT COUNT(*) INTO n FROM Emp_tab; DMBS_OUTPUT.PUT_LINE( ‘There are now’ || a || ‘employees’); END; This trigger results in an error after this SQL statement is entered: DELETE FROM Emp_tab WHERE Empno = 7499; How do you correct the error? A. Change the trigger type to a BEFORE DELETE. B. Take out the COUNT function because it is not allowed in a trigger. C. Remove the DBMS_OUTPUT statement because it is not allowed in a trigger. D. Change the trigger to a statement-level trigger by removing FOR EACH ROW. Answer(s) D 15. The OLD and NEW qualifiers can be used in which type of trigger? A. Row level DML trigger B. Row level system trigger C. Statement level DML trigger D. Row level application trigger E. Statement level system trigger F. Statement level application trigger Answer(s) A 16. Which view displays indirect dependencies, indenting each dependency? A. DEPTREE B. IDEPTREE C. INDENT_TREE D. I_DEPT_TREE Answer(s) B 17. Examine this code: CREATE OR REPLACE PROCEDURE audit_action (p_who VARCHAR2)AS BEGIN INSERT INTO audit(schema_user) VALUES(p_who); END audit_action; / CREATE OR REPLACE TRIGGER watch_it AFTER LOGON ON DATABASE CALL audit_action(ora_login_user) / What does this trigger do? A. The trigger records an audit trail when a user makes changes to the database. B. The trigger marks the user as logged on to the database before an audit statement is issued. C. The trigger invoked the procedure audit_action each time a user logs on to his/her schema and adds the username to the audit table. D. The trigger invokes the procedure audit_action each time a user logs on to the database and adds the username to the audit table. Answer(s) D 18. Examine this procedure: CREATE OR REPLACE PROCEDURE UPD_BAT_STAT (V_ID IN NUMBER DEFAULT 10, V_AB IN NUMBER DEFAULT 4) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB WHERE PLAYER_ID = V_ID; COMMIT; END; Which two statements will successfully invoke this procedure in SQL *Plus? (Choose two) A. EXECUTE UPD_BAT_STAT; B. EXECUTE UPD_BAT_STAT(V_AB=>10, V_ID=>31); C. EXECUTE UPD_BAT_STAT(31, .FOUR., .TWO.); D. UPD_BAT_STAT(V_AB=>10, V_ID=>31); E. RUN UPD_BAT_STAT; Answer(s) A,B 19. Examine this code: CREATE OR REPLACE FUNCTION gen_email_name (p_first_name VARCHAR2, p_last_name VARCHAR2, p_id NUMBER) RETURN VARCHAR2 IS v_email_name VARCHAR2(19); BEGIN v_email_name := SUBSTR(p_first_name, 1, 1) || SUBSTR(p_last_name, 1, 7) || .@Oracle.com .; UPDATE employees SET email = v_email_name WHERE employee_id = p_id; RETURN v_email_name; END; Which statement removes the function? A. DROP gen_email_name; B. REMOVE gen_email_name; C. DELETE gen_email_name; D. DROP FUNCTION gen_eamil_name; Answer(s) D 20. Examine this code: CREATE OR REPLACE PACKAGE comm_package IS g_comm NUMBER := 10; PROCEDURE reset_comm(p_comm IN NUMBER); END comm_package; / User Jones executes the following code at 9:01am: EXECUTE comm_package.g_comm := 15 User Smith executes the following code at 9:05am: EXECUTE comm_paclage.g_comm := 20 which statement is true? A. g_ comm has a value of 15 at 9:06am for Smith. B. g_ comm has a value of 15 at 9:06am for Jones. C. g_comm has a value of 20 at 9:06am for both Jones and Smith. D. g_comm has a value of 15 at 9:03 am for both Jones and Smith. E. g_comm has a value of 10 at 9:06am for both Jones and Smith. F. g_comm has a value of 10 at 9:03am for both Jones and Smith Answer(s) B 21. Examine this package: CREATE OR REPLACE PACKAGE BB_PACK IS V_MAX_TEAM_SALARY NUMBER(12,2); PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER); END BB_PACK; / CREATE OR REPLACE PACKAGE BODY BB_PACK IS V_PLAYER_AVG NUMBER(4,3); PROCEDURE UPD_PLAYER_STAT(V_ID IN NUMBER, V_AB IN NUMBER DEFAULT 4, V_HITS IN NUMBER) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB, HITS = HITS + V_HITS WHERE PLAYER_ID = V_ID; COMMIT; VALIDATE_PLAYER_STAT(V_ID); END UPD_PLAYER_STAT; PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER)IS BEGIN INSERT INTO PLAYER(ID,LAST_NAME,SALARY) VALUES (V_ID, V_LAST_NAME, V_SALARY); UPD_PLAYER_STAT(V_ID,0,0); END ADD_PLAYER; END BB_PACK / Which statement will successfully assign .333 to the V_PLAYER_AVG variable from a procedure outside the package? A. V_PLAYER_AVG := .333; B. BB_PACK.UPD_PLAYER_STAT.V_PLAYER_AVG := .333; C. BB_PACK.V_PLAYER_AVG := .333; D. This variable cannot be assigned a value from outside of the package. Answer(s) D 22. What can you do with the DBMS_LOB package? A. Use the DBMS_LOB.WRITE procedure to write data to a BFILE. B. Use the DBMS_LOB.BFILENAME function to locate an external BFILE. C. Use the DBMS_LOB.FILEEXISTS function to find the location of a BFILE. D. Use the DBMS_LOB.FILECLOSE procedure to close the file being accessed. Answer(s) D 23. Examine this package: CREATE OR REPLACE PACKAGE manage_emps IS tax_rate CONSTANT NUMBER(5,2) := .28; v_id NUMBER; PROCEDURE insert_emp (p_deptno NUMBER, p_sal NUMBER); PROCEDURE delete_emp; PROCEDURE update_emp; FUNCTION calc_tax (p_sal NUMBER) RETURN NUMBER; END manage_emps; / CREATE OR REPLACE PACKAGE BODY manage_emps IS PROCEDURE update_sal (p_raise_amt NUMBER) IS BEGIN UPDATE emp SET sal = (sal * p_raise_emt) + sal WHERE empno = v_id; END; PROCEDURE insert_emp (p_deptno NUMBER, p_sal NUMBER) IS BEGIN INSERT INTO emp(empno, deptno, sal) VALYES (v_id, p_depntno, p_sal); END insert_emp; PROCEDURE delete_emp IS BEGIN DELETE FROM emp WHERE empno = v_id; END delete_emp; PROCEDURE update_emp IS v_sal NUMBER(10,2); v_raise NUMBER(10, 2); BEGIN SELECT sal INTO v_sal FROM emp WHERE empno = v_id; IF v_sal < 500 THEN v_raise := .05; ELSIP v_sal < 1000 THEN v_raise := .07; ELSE v_raise := .04; END IF; update_sal(v_raise); END update_emp; FUNCTION calc_tax (p_sal NUMBER)RETURN NUMBER IS BEGIN RETURN p_sal * tax_rate; END calc_tax; END manage_emps; / What is the name of the private procedure in this package? A. CALC_TAX B. INSERT_EMP C. UPDATE_SAL D. DELETE_EMP E. UPDATE_EMP F. MANAGE_EMPS Answer(s) C 24. Which two dopes the INSTEAD OF clause in a trigger identify? (Choose two) A. The view associated with the trigger. B. The table associated with the trigger. C. The event associated with the trigger. D. The package associated with the trigger. E. The statement level or for each row association to the trigger. Answer(s) A,E 25. Which three are valid ways to minimize dependency failure? (Choose three) A. Querying with the SELECT * notification. B. Declaring variables with the %TYPE attribute. C. Specifying schema names when referencing objects. D. Declaring records by using the %ROWTYPE attribute. E. Specifying package.procedure notation while executing procedures. Answer(s) A,B,D 26. Examine this code: CREATE OR REPLACE PROCEDURE add_dept ( p_name departments.department_name%TYPE DEFAULT ‘unknown‘, p_loc departments.location_id%TYPE DEFAULT 1700) IS BEGIN INSERT INTO departments(department_id, department_name, loclation_id) VALUES (dept_seq.NEXTVAL,p_name, p_loc); END add_dept; / You created the add_dept procedure above, and you now invoke the procedure in SQL *Plus. Which four are valid invocations? (Choose four) A. EXECUTE add_dept(p_loc=>2500) B. EXECUTE add_dept( ‘Education’, 2500) C. EXECUTE add_dept( .2500 , p_loc =>2500) D. EXECUTE add_dept(p_name=> ‘Education’, 2500) E. EXECUTE add_dept(p_loc=>2500, p_name=> ‘Education’) Answer(s) A, B, C,E 27. Which two describe a stored procedure? (Choose two) A. A stored procedure is typically written in SQL. B. A stored procedure is a named PL/SQL block that can accept parameters. C. A stored procedure is a type of PL/SQL subprogram that performs an action. D. A stored procedure has three parts: the specification, the body, and the exception handler part. E. The executable section of a stored procedure contains statements that assigns values, control execution, and return values to the calling environment. Answer(s) B,C 28. To be callable from a SQL expression, a user-defined function must do what? A. Be stored only in the database. B. Have both IN and OUT parameters. C. Use the positional notation for parameters. D. Return a BOOLEAN or VARCHAR2 data type. Answer(s) A 29. Examine this procedure: CREATE OR REPLACE PROCEDURE INSERT_TEAM (V_ID in NUMBER, V_CITY in VARCHAR2 DEFAULT ‘AUSTIN’, V_NAME in VARCHAR2) IS BEGIN INSERT INTO TEAM (id, city, name) VALUES (v_id, v_city, v_name); COMMIT; END which two statements will successfully invoke this procedure in SQL *Plus? (Choose two) A. EXECUTE INSERT_TEAM; B. EXECUTE INSERT_TEAM(3, V_NAME=> ‘LONGHORNS’, V_CITY=> ‘AUSTIN’); C. EXECUTE INSERT_TEAM(3, ‘AUSTIN’, ‘LONGHORNS’); D. EXECUTE INSERT_TEAM (V_ID:= V_NAME:=‘LONGHORNS’, V_CITY := ‘AUSTIN’); E. EXECUTE INSERT_TEAM (3, ‘LONGHORNS’); Answer(s) B,C 30. How can you migrate from a LONG to a LOB data type for a column? A. Use the DBMS_MANAGE_LOB.MIGRATE procedure. B. Use the UTL_MANAGE_LOB.MIGRATE procedure. C. Use the DBMS_LOB.MIGRATE procedure. D. Use the ALTER TABLE command. E. You cannot migrate from a LONG to a LOB date type for a column. Answer(s) D 31. You need to remove the database trigger BUSINESS_HOUR . Which command do you use to remove the trigger in the SQL *Plus environment? A. DROP TRIGGER business_hour; B. DELETE TRIGGER business_hour; C. REMOVE TRIGGER business_hour; D. ALTER TRIGGER business_hour REMOVE; E. DELETE FROM USER_TRIGGERS WHERE TRIGGER_NAME = .BUSINESS_HOUR .; Answer(s) A 32. A CALL statement inside the trigger body enables you to call _____. A. A package. B. A stored function. C. A stored procedure. D. Another database trigger. Answer(s) C 33. You are about to change the arguments of the CALC_TEAM_AVG function. Which dictionary view can you query to determine the names of the procedures and functions that invoke the CALC_TEAM_AVG function? A. USER_PROC_DEPENDS B. USER_DEPENDENCIES C. USER_REFERENCES D. USER_SOURCE Answer(s) B 34. You create a DML trigger. For the timing information, which is valid with a DML trigger? A. DURING B. INSTEAD OF C. ON SHUTDOWN D. BEFORE E. ON STATEMENT EXECUTION Answer(s) B 35. Which type of argument passes a value from a procedure to the calling environment? A. VARCHAR2 B. BOOLEAN C. OUT D. IN Answer(s) C 36. You want to create a PL/SQL block of code that calculates discounts on customer orders. This code will be invoked from several places, but only within the program unit ORDERTOTAL. What is the most appropriate location to store the code that calculates the discounts? A. A stored procedure on the server. B. A block of code in a PL/SQL library. C. A standalone procedure on the client machine. D. A block of code in the body of the program unit ORDERTOTAL. E. A local subprogram defined within the program unit ORDERTOTAL. Answer(s) A 37. Which statement about triggers is true? A. You use an application trigger to fire when a DELETE statement occurs. B. You use a database trigger to fire when an INSERT statement occurs. C. You use a system event trigger to fire when an UPDATE statement occurs. D. You use INSTEAD OF trigger to fire when a SELECT statement occurs. Answer(s) B 38. Examine this procedure: CREATE OR REPLACE PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2) IS BEGIN INSERT INTO PLAYER (ID,LAST_NAME) VALUES (V_ID, V_LAST_NAME); COMMIT; END; This procedure must invoke the APD_BAT_STAT procedure and pass a parameter. Which statement, when added to the above procedure will successfully invoke the UPD_BAT_STAT procedure? A. EXECUTE UPD_BAT_STAT(V_ID); B. UPD_BAT_STAT(V_ID); C. RUN UPD_BAT_STAT(V_ID); D. START UPD_BAT_STAT(V_ID); Answer(s) B 39. Which four triggering events can cause a trigger to fire? (Choose four) A. A specific error or any errors occurs. B. A database is shut down or started up. C. A specific user or any user logs on or off. D. A user executes a CREATE or an ALTER table statement. E. A user executes a SELECT statement with an ORDER BY clause. F. A user executes a JOIN statement that uses four or more tables. Answer(s) A,B,C,D 40. When creating a function in SQL *Plus, you receive this message: .Warning: Function created with compilation errors.. Which command can you issue to see the actual error message? A. SHOW FUNCTION_ERROR B. SHOW USER_ERRORS C. SHOW ERRORS D. SHOW ALL_ERRORS Answer(s) C 41. There is a CUSTOMER table in a schema that has a public synonym CUSTOMER and you are granted all object privileges on it. You have a procedure PROCESS_CUSTOMER that processes customer information that is in the public synonym CUSTOMER table. You have just created a new table called CUSTOMER within your schema. Which statement is true? A. Creating the table has no effect and procedure PROCESS_CUSTOMER still accesses data from public synonym CUSTOMER table. B. If the structure of your CUSTOMER table is the same as the public synonym CUSTOMER table then the procedure PROCESS_CUSTOMER is invalidated and gives compilation errors. C. If the structure of your CUSTOMER table is entirely different from the public synonym CUSTOMER table then the procedure PROCESS_CUSTOMER successfully recompiles and accesses your CUSTOMER table. D. If the structure of your CUSTOMER table is the same as the public synonym CUSTOMER table then the procedure PROCESS_CUSTOMER successfully recompiles when invoked and accesses your CUSTOMER table. Answer(s) D 42. Examine this package: CREATE OR REPLACE PACKAGE BB_PACK IS V_MAX_TEAM_SALARY NUMBER(12,2); PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY_NUMBER; END BB_PACK; / CREATE OR REPLACE PACKAGE BODY BB_PACK IS PROCEDURE UPD_PLAYER_STAT (V_ID IN NUMBER, V_AB IN NUMBER DEFAULT 4, V_HITS IN NUMBER) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB, HITS = HITS + V_HITS WHERE PLAYER_ID = V_ID) COMMIT; END UPD_PLAYER_STAT; PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER) IS BEGIN INSERT INTO PLAYER(ID,LAST_NAME,SALARY) VALUES (V_ID, V_LAST_NAME, V_SALARY); UPD_PLAYER_STAT(V_ID,0.0); END ADD_PLAYER; END BB_PACK; Which statement will successfully assign $75,000,000 to the V_MAX_TEAM_SALARY variable from within a stand-alone procedure? A. V_MAX_TEAM_SALARY := 7500000; B. BB_PACK.ADD_PLAYER.V_MAX_TEAM_SALARY := 75000000; C. BB_PACK.V_MAX_TEAM_SALARY := 75000000; D. This variable cannot be assigned a value from outside the package. Answer(s) C 43. Examine this code: CREATE OR REPLACE TRIGGER update_emp AFTER UPDATE ON emp BEGIN INSERT INTO audit_table (who, dated) VALUES (USER, SYSDATE); END; You issue an UPDATE command in the EMP table that results in changing 10 rows. How many rows are inserted into the AUDIT_TABLE ? A. 1 B. 10 C. None D. A value equal to the number of rows in the EMP table. Answer(s) A 44. Examine this package: CREATE OR REPLACE PACKAGE discounts IS g_id NUMBER := 7829; discount_rate NUMBER := 0.00; PROCEDURE display_price (p_price NUMBER); END discounts; / CREATE OR REPLACE PACKAGE BODY discounts IS PROCEDURE display_price (p_price NUMBER) IS BEGIN DBMS_OUTPUT.PUT_LINE( .Discounted .|| TO_CHAR(p_price*NVL(discount_rate, 1))); END display_price; BEGIN discount_rate :=0.10; END discounts; / Which statement is true? A. The value of DISCOUNT_RATE always remains 0.00 in a session. B. The value of DISCOUNT_RATE is set to 0.10 each time the package is invoked in a session. C. The value of DISCOUNT_RATE is set to 1.00 each time the procedure DISPLAY_PRICE is invoked. D. The value of DISCOUNT_RATE is set to 0.10 when the package is invoked for the first time in a session. Answer(s) D 45. Examine this code: CREATE OR REPLACE TRIGGER secure_emp BEFORE LOGON ON employees BEGIN IF (TO_CHAR(SYSDATE, .DY.) IN ( .SAT., .SUN.)) OR (TO_CHAR(SYSDATE, .HH24:MI .) NOT BETWEEN .08:00 AND .18:00 )THEN RAISE_APPLICATION_ERROR (-20500, .You may insert into the EMPLOYEES table only during business hours. .); END IF; END; What type of trigger is it? A. DML trigger B. INSTEAD OF trigger C. Application trigger D. System event trigger E. This is an invalid trigger. Answer(s) D 46. Which table should you query to determine when your procedure was last compiled? A. USER_PROCEDURES B. USER_PROCS C. USER_OBJECTS D. USER_PLSQL_UNITS Answer(s) C 47. Examine this code: CREATE OR REPLACE FUNCTION gen_email_name (p_first_name VARCHAR2, p_last_name VARCHAR2, p_id NUMBER) RETURN VARCHAR2 is v_email_name VARCHAR2(19); BEGIN v_email_home := SUBSTR(p_first_name, 1, 1) || SUBSTR(p_last_name, 1, 7) ||.@Oracle.com .; UPDATE employees SET email = v_email_name WHERE employee_id = p_id; RETURN v_email_name; END; You run this SELECT statement: SELECT first_name, last_name gen_email_name(first_name, last_name, 108) EMAIL FROM employees; What occurs? A. Employee 108 has his email name updated based on the return result of the function. B. The statement fails because functions called from SQL expressions cannot perform DML. C. The statement fails because the functions does not contain code to end the transaction. D. The SQL statement executes successfully, because UPDATE and DELETE statements are ignoring in stored functions called from SQL Expressions. E. The SQL statement executes successfully and control is passed to the calling environment. Answer(s) B 48. What part of a database trigger determines the number of times the trigger body executes? A. Trigger type B. Trigger body C. Trigger event D. Trigger timing Answer(s) C 49. What happens during the execute phase with dynamic SQL for INSERT, UPDATE, and DELETE operations? A. The rows are selected and ordered. B. The validity of the SQL statement is established. C. An area of memory is established to process the SQL statement. D. The SQL statement is run and the number of rows processed is returned. E. The area of memory established to process the SQL statement is released. Answer(s) D 50. Given a function CALCTAX : CREATE OR REPLACE FUNCTION calc tax (sal NUMBER) RETURN NUMBER IS BEGIN RETURN (sal * 0.05); END; If you want to run the above function from the SQL *Plus prompt, which statement is true? A. You need to execute the command CALCTAX(1000); . B. You need to execute the command EXECUTE FUNCTION calc tax; . C. You need to create a SQL *Plus environment variable X and issue the command :X := CALCTAX(1000); . D. You need to create a SQL *Plus environment variable X and issue the command EXECUTE :X := CALCTAX; E. You need to create a SQL *Plus environment variable X and issue the command EXECUTE :X := CALCTAX(1000); Answer(s) E 51. Which two dictionary views track dependencies? (Choose two) A. USER_SOURCE B. UTL_DEPTREE C. USER_OBJECTS D. DEPTREE_TEMPTAB E. USER_DEPENDENCIES F. DBA_DEPENDENT_OBJECTS Answer(s) D,E 52. Which statements are true? (Choose all that apply) A. If errors occur during the compilation of a trigger, the trigger is still created. B. If errors occur during the compilation of a trigger you can go into SQL *Plus and query the USER_TRIGGERS data dictionary view to see the compilation errors. C. If errors occur during the compilation of a trigger you can use the SHOW ERRORS command within iSQL *Plus to see the compilation errors. D. If errors occur during the compilation of a trigger you can go into SQL *Plus and query the USER_ERRORS data dictionary view to see compilation errors. Answer(s) A, C,D 53. You need to create a trigger on the EMP table that monitors every row that is changed and places this information into the AUDIT_TABLE . What type of trigger do you create? A. FOR EACH ROW trigger on the EMP table. B. Statement-level trigger on the EMP table. C. FOR EACH ROW trigger on the AUDIT_TABLE table. D. Statement-level trigger on the AUDIT_TABLE table. E. FOR EACH ROW statement-level trigger on the EMP table. Answer(s) A 54. Examine this package: CREATE OR REPLACE PACKAGE BB:PACK IS V_MAX_TEAM:SALAR NUMBER(12,2); PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER); END BB_PACK; / CREATE OR REPLACE PACKAGE BODY BB_PACK IS PROCEDURE UPD_PLAYER_STAT (V_ID IN NUMBER, V_AB IN NUMBER DEFAULT 4, V_HITS IN NUMBER) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB, HITS = HITS + V_HITS WHERE PLAYER_ID = V_ID; COMMIT; END UPD_PLAYER_STAT; PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER) IS BEGIN INSERT INTO PLAYER(ID,LAST_NAME,SALARY) VALUES (V_ID, V_LAST_NAME, V_SALARY); UPD_PLAYER_STAT(V_ID,0,0); END ADD_PLAYER; END BB_PACK; You make a change to the body of the BB_PACK package. The BB_PACK body is recompiled. What happens if the stand-alone procedure VALIDATE_PLAYER_STAT references this package? A. VALIDATE_PLAYER_STAT cannot recompile and must be recreated. B. VALIDATE_PLAYER_STAT is not invalidated. C. VALDIATE_PLAYER_STAT is invalidated. D. VALIDATE_PLAYER_STAT and BB_PACK are invalidated. Answer(s) B 55. Which statement is valid when removing procedures? A. Use a drop procedure statement to drop a standalone procedure. B. Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package specification. C. Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package body. D. For faster removal and re-creation, do not use a drop procedure statement. Instead, recompile the procedure using the alter procedure statement with the REUSE SETTINGS clause. Answer(s) A 56. Examine this code: CREATE OR REPLACE PACKAGE bonus IS g_max_bonus NUMBER := .99; FUNCTION calc_bonus (p_emp_id NUMBER) RETURN NUMBER; FUNCTION calc_salary (p_emp_id NUMBER) RETURN NUMBER; END; / CREATE OR REPLACE PACKAGE BODY bonus IS v_salary employees.salary%TYPE; v_bonusemployees.commission_pct%TYPE; FUNCTION calc_bonus (p_emp_id NUMBER)RETURN NUMBER IS BEGIN SELECT salary, commission_pct INTO v_salary, v_bonus FROM employees WHERE employee_id = p_emp_id; RETURN v_bonus * v_salary; END calc_bonus FUNCTION calc_salary (p_emp_id NUMBER) RETURN NUMBER IS BEGIN SELECT salary, commission_pct INTO v_salary, v_bonus FROM employees WHERE employees RETURN v_bonus * v_salary + v_salary; END cacl_salary; END bonus; / Which statement is true? A. You can call the BONUS.CALC_SALARY packaged function from an INSERT command against the EMPLOYEES table. B. You can call the BONUS.CALC_SALARY packaged function from a SELECT command against the EMPLOYEES table. C. You can call the BONUS.CALC_SALARY packaged function form a DELETE command against the EMPLOYEES table. D. You can call the BONUS.CALC_SALARY packaged function from an UPDATE command against the EMPLOYEES table. Answer(s) B 57. Which code can you use to ensure that the salary is not increased by more than 10% at a time nor is it ever decreased? A. ALTER TABLE emp ADD CONSTRAINT ck_sal CHECK (sal BETWEEN sal AND sal*1.1); B. CREATE OR REPLACE TRIGGER check_sal BEFORE UPDATE OF sal ON emp FOR EACH ROW WHEN (new.sal < old.sal OR new.sal > old.sal * 1.1) BEGIN RAISE_APPLICATION_ERROR ( - 20508, . Do not decrease salary not increase by more than 10% ); END; C. CREATE OR REPLACE TRIGGER check_sal BEFORE UPDATE OF sal ON emp WHEN (new.sal < old.sal OR new.sal > old.sal * 1.1) BEGIN RAISE_APPLICATION_ERROR ( - 20508, .Do not decrease salary not increase by more than 10% ); END; D. CREATE OR REPLACE TRIGGER check_sal AFTER UPDATE OR sal ON emp WHEN (new.sal < old.sal OR -new.sal > old.sal * 1.1) BEGIN RAISE_APPLICATION_ERROR ( - 20508, .Do not decrease salary not increase by more than 10% ); END; Answer(s) B 58. Which two statements describe the state of a package variable after executing the package in which it is declared? (Choose two) A. It persists across transactions within a session. B. It persists from session to session for the same user. C. It does not persist across transaction within a session. D. It persists from user to user when the package is invoked. E. It does not persist from session to session for the same user. Answer(s) A,E 59. Which two programming constructs can be grouped within a package? (Choose two) A. Cursor B. Constant C. Trigger D. Sequence E. View Answer(s) A,B 60. Which two statements about packages are true? (Choose two) A. Packages can be nested. B. You can pass parameters to packages. C. A package is loaded into memory each time it is invoked. D. The contents of packages can be shared by many applications. E. You can achieve information hiding by making package constructs private. Answer(s) D,E 61. Examine this code: CREATE OR REPLACE PRODECURE add_dept (p_dept_name VARCHAR2 DEFAULT .placeholder ., p_location VARCHAR2 DEFAULT .Boston .) IS BEGIN INSERT INTO departments VALUES (dept_id_seq.NEXTVAL, p_dept_name, p_location); END add_dept; / Which three are valid calls to the add_dep procedure ? (Choose three) A. add_dept; B. add_dept( .Accounting .); C. add_dept(, .New York .); D. add_dept(p_location=> .New York .); Answer(s) A,B,D 62. You have created a stored procedure DELETE_TEMP_TABLE that uses dynamic SQL to remove a table in your schema. You have granted the EXECUTE privilege to user A on this procedure. When user A executes the DELETE_TEMP_TABLE procedure, under whose privileges are the operations performed by default? A. SYS privileges B. Your privileges C. Public privileges D. User A.s privileges E. User A cannot execute your procedure that has dynamic SQL. Answer(s) D 63. Which three are true statements about dependent objects? (Choose three) A. Invalid objects cannot be described. B. An object with status of invalid cannot be a referenced object. C. The Oracle server automatically records dependencies among objects. D. All schema objects have a status that is recorded in the data dictionary. E. You can view whether an object is valid or invalid in the USER_STATUS data dictionary view. F. You can view whether an object is valid or invalid in the USER_OBJECTS data dictionary view. Answer(s) C,D,F 64. Examine this function: CREATE OR REPLACE FUNCTION CALC_PLAYER_AVG (V_ID in PLAYER_BAT_STAT.PLAYER_ID%TYPE) RETURN NUMBER IS V_AVG NUMBER; BEGIN SELECT HITS / AT_BATS INTO V_AVG FROM PLAYER_BAT_STAT WHERE PLAYER_ID = V_ID; RETURN (V_AVG); END; Which statement will successfully invoke this function in SQL *Plus? A. SELECT CALC_PLAYER_AVG(PLAYER_ID) FROM PLAYER_BAT_STAT; B. EXECUTE CALC_PLAYER_AVG(31); C. CALC_PLAYER(.RUTH.); D. CALC_PLAYER_AVG(31); E. START CALC_PLAYER_AVG(31) Answer(s) A

Tuesday

Ascential Data Stage FAQ's

Q. What is the architecture of Data Stage A. Client Server Architecture Q. What are the components of Client and explain them? A.Designer, Director, Manager, Administrator Q.What is the difference between ODBC Stage and OCI Stage A. In ODBC Stage user can connect to any data base and through OCI Stage user can connect to Oracle Database only. If user uses ODBC Stage than DSN name should be create in Data Source. Q.What is a Passive and Active Stage? Give Example A. If the data changes from in put to out put than it is an active stage else it is a passive stage. Transformer Stage is an Active stage while Hash Stage is a passive stage. Q.How to find the length of a String? A. By using Len function user can find out the length of the sting. Q.What is the format for if-Else Block A. If Column1 > 100 Then "A" Else "B" Q.How do u concatenates two values. A. The concatenation operator is “:” Q.Where you define the job parameter. A. The job parameter is defined in the job->Edit->job Properties. Than click the Job Parameter Menu. Q.How to use the parameter in a job? A. To use the defined job parameters, you must specify them when you edit a stage. When you edit any of the fields for which you wish to use a parameter, enter #Param#, where Param is the name of the job parameter. Q.How to convert the string into uppercase. A. To convert the string into uppercase we need to use UPCASE function E.g. String a=My Value; UPCASE (a) =MYVALUE; Q.But how to convert lower case? A. DOWNCASE (a) =my value; Q.How to get a substring from a string. A. String a=My Value; If user wants first three character than the function is Substrings (a, 1, 3); Q.How do u schedules a job? Q.How to create a sequence in Data stage job? A. By using the KeyMgtGetNextValue.This is present in the category SDK/KeyMgt Q.How many number of input link will be used in transformer stage? A. Transformer stages in server jobs can have one primary input link, but there can be any number of reference inputs. Q.What is the use of Transformer Stage? A. Transformer stages do not extract data or write data to a target database. They are used to handle extracted data, perform any conversions required, and pass data to another Transformer stage or a stage that writes data to a target data table. Q.Where user can write custom routine? A. The user can write custom routine in Manager. Q.Have ever writes any routine? If yes explain. Q.What is the difference between Stage Variable and System Variable? A.DataStage provides a set of variables containing useful system information that you can access from a transform or routine. System variables are read-only. All System Variable starts with @.Some of the System variables are @DATE the internal date when the program started. See the Date function. @DAY The day of the month extracted from the value in @DATE. @FALSE The compiler replaces the value with 0. @INROWNUM Input row counter. For use in constrains and derivations in Transformer stages. @OUTROWNUM Output row counter (per link). For use in derivations in Transformer stages. @LOGNAME The user login name. @MONTH The current extracted from the value in @DATE. @NULL the null value. @NULL.STR The internal representation of the null value, Char (128). @NUMPARTITIONS In a parallel Transformer stage output derivation gives the total number of partitions for the stage. @PARTITIONNUM In a parallel Transformer stage output derivation gives the partition number for the particular instance. @PATH The pathname of the current Data Stage project. @SCHEMA The schema name of the current Data Stage project. @SM A sub value mark (a delimiter used in UniVerse files), Char(252). @SYSTEM.RETURN.CODE Status codes returned by system processes or commands. @TIME The internal time when the program started. See the Time function. @TM A text mark (a delimiter used in UniVerse files), Char(251). @TRUE The compiler replaces the value with 1. @USERNO The user number. @VM A value mark (a delimiter used in UniVerse files), Char(253). @WHO The name of the current DataStage project directory. @YEAR The current year extracted from @DATE. But Stage variables created by the user. It executes first while running.It is defined inside the transformer stage. In this user will see the stage varaible window and he can defines there.

Sunday

Unix commands(p-z)

Unix Commands from p to z: passwd: Allows changing your login password ps : Lists all of current user's live processes ps -ef : List all users processes that are executing pwd: Displays current working directory you are in rcp filename1 hostb:/usr/local/bin : Copies filename1 from current host system to hostb, and places it in the /usr/local/bin directory; The .rhosts or hosts.equiv files must be setup to allow action rksh: Starts restricted Korn Shell session rlogin hostb : Logs into remote host name hostb rm filename1 : Deletes filename1 from the disk without recourse rm -i filename1 : Deletes filename1 after prompting for verification rmdir dirx : Deletes directory dirx rmdir -r dirx: Deletes directory and all contents rsh: Restricted version of Bourne Shell for security sar : System Activity Reporter sh : Bourne Shell command interpreter; Alternative to Korn Shell and C shell but is the default on most systems; Older version that is losing popularity sleep 3 : Pauses for 3 seconds and continues stty sane: Attempts to restore terminal settings after they are hosed; Use CTRL-J with this command stty erase ^H : Use to reset backspace/delete; ^H is the key you may want to use for backspace/delete; su sam: Log on as user sam su - sam: Log on as sam, and execute his profile too tail filename1 : Display last few lines of filename1 tail -50 filename1 : Display last fifty lines of filename1 tail -f : Continually reads updating file; Great for monitoring a log file while being written tar -cvf /dev/rmt/0c /usr/bin/* : Tape archive utility; Copies all files in /usr/bin directory to tape device /dev/rmt/ tar -xvf /dev/rmt/0 /usr/bin/ : Extracts all files from tape device /dev/rmt/0 and writes them to /usr/bin/ tar -tvf /dev/rmt/0c : Read tape on device /dev/rmt/0c and lists contents in verbose mode tee: Used in scripts to split output to two outputs. Usually used with a pipe command (|) tee -a /tmp/filename1: Append the output to filename1 without overwriting its original content telnet hostb: Create a remote terminal on hostb touch filename1 : Creates an empty file named filename1; Changes modification time to current time if the file already exists uname -a: Lists 0/S revision, host name, hardware uncompress filename1 : Uncompresses file with .Zsuffix, created by compress command previously uptime : Displays current time, time logged-in,number of users etc users: Displays current logged-in users in a listing uucp : UNIX-to-UNIX copy utility; See man pages view filename1: A read only version of vi editor w : Combination of uptime, who and ps -a commands wall : Write to all; Allows entry of message to be sent to line 25 of all terminals; End message with a CTRLD command wc -l filename1: Utility that counts the number of lines in filename1 wc -c filename1 : Utility that counts the number of bytes in filename1; -m provides number of characters wc -w filename1 : Utility that counts the number of the words in filename1 whence filename2: Prints path name location of executable filename2 which filename2 : Similar to whence command who – Displays login name, terminal name, date, and time of login, of users currently logged in who am i : Displays effective user id of user who -b : Displays date/time of last reboot who -r : Displays current system run level

Monday

Unix commands(f-n)

The unix commands from f-p: =========================== file filename1 : Determines and displays type of file for filename1 (text, data, executable, directory, symbolic link...etc...) find /usr/opt/bin -name "filename1*" -print : Starts searching in /usr/opt/bin for files starting with filename1, If found prints the full file names and continues searching subdirectories find . -type f -print | xargs grep -i [PATTERN] : Recursive grep for a pattern in a file (searches through files in subdirectories) find . ! -mtime - | /usr/bin/xargs rm -rf : Finds and removes files older than specified finger sam : Displays data about user session for sam ftp solar : Establishes a File Transfer Protocol session over the network between current host and a host named solar; See man pages for additional ftp commands grep jdoe /etc/passwd : Searches the file /etc/passwd searching for string "jdoe"; If found, displays grep -i Sam filename1: Search filename1 for upper or lower case string of Sam and display lines found groups sam : List groups that sam is a member of head filename1 : Display first few lines of filename1 head -50 filename1: Display first fifty lines of filename1 id : List current user id and any group ids kill -9 1351 : Terminate process number 1351 ksh: Start Korn Shell command interpreter; See man pages; Preferred shell for most users ln -s filename1 /usr/opt/filename2 : Create a symbolic link named /usr/opt/filename2 that points to filename1; See man pages lp -d lp1 filename1 : Print filename1 on destination printer lp1 lpstat -d : Displays name of default printer, if any lpstat -a : Lists printers accepting print requests lpstat -s : Displays most everything regarding printing lpstat -u sam : Displays status of sam's print jobs ls -al : Displays all files in wide listing ls -al *.doc : Displays files ending with .doc ls -al /bin/k*: Displays files starting with k in /bin directory mail sam : Starts mail message to sam mailx sam : Nicer looking mail utility mkdir -p /usr/opt/dirx: Creates dirx below /usr/opt make: Code compilation utility mkdir dirx: Creates directory dirx more filename1 : Displays single pages from filename1 pausing after each page.for many options see man pages mv filename1 /usr/opt/ : Moves filename1 to directory /usr/opt; Unlike the cp (copy) command, mv removes file from origin netstat -i: Show the TCP/IP network interfaces netstat -r: Show network route table netstat -rn: Displays routing information but bypasses hostname lookup netstat -a | more : Show the state of all sockets newgrp group1 : Changes current group to group 1 news : Displays unread files from /usr/news or /var/news nice/renice : Adjusts process’ execution priority