Q: What is the difference between Org_id and Oraganization_id?

A: ORG_ID differentiates between one org and another in the context of multiorg, which is something of a financial classification. If you have access to MetaLink, click here for clarification. On the other hand, ORGANIZATION_ID is an Oracle Human Resources Management System concept, something to which an assignment is attached. HR organizations can belong to a hierarchy, and apply in different contexts. Here is a link to organization from MetaLink's HRMS Glossary of Terms. Q) Differentiate between TRUNCATE and DELETE. A) The Delete command will log the data changes in the log file where as the truncate will simply remove the data without it. Hence Data removed by Delete command can be rolled back but not the data removed by TRUNCATE. Truncate is a DDL statement whereas DELETE is a DML statement. Q) What is the maximum buffer size that can be specified using the DBMS_OUTPUT.ENABLE function? A) 1000000 Q) Can you use a commit statement within a database trigger? A) Yes, if you are using autonomous transactions in the Database triggers. Q)What is an UTL_FILE? What are different procedures and functions associated with it? A)The UTL_FILE package lets your PL/SQL programs read and write operating system (OS) text files. It provides a restricted version of standard OS stream file input/output (I/O). Subprogram -Description FOPEN function-Opens a file for input or output with the default line size. IS_OPEN function -Determines if a file handle refers to an open file. FCLOSE procedure -Closes a file. FCLOSE_ALL procedure -Closes all open file handles. GET_LINE procedure -Reads a line of text from an open file. PUT procedure-Writes a line to a file. This does not append a line terminator. NEW_LINE procedure-Writes one or more OS-specific line terminators to a file. PUT_LINE procedure -Writes a line to a file. This appends an OS-specific line terminator. PUTF procedure -A PUT procedure with formatting. FFLUSH procedure-Physically writes all pending output to a file. FOPEN function -Opens a file with the maximum line size specified. Q) Difference between database triggers and form triggers? A) Database triggers are fired whenever any database action like INSERT, UPATE, DELETE, LOGON LOGOFF etc occurs. Form triggers on the other hand are fired in response to any event that takes place while working with the forms, say like navigating from one field to another or one block to another and so on.

Q) What is OCI. What are its uses? A) OCI is Oracle Call Interface. When applications developers demand the most powerful interface to the Oracle Database Server, they call upon the Oracle Call Interface (OCI). OCI provides the most comprehensive access to all of the Oracle Database functionality. The newest performance, scalability, and security features appear first in the OCI API. If you write applications for the Oracle Database, you likely already depend on OCI. Some types of applications that depend upon OCI are: · PL/SQL applications executing SQL · C++ applications using OCCI · Java applications using the OCI-based JDBC driver · C applications using the ODBC driver · VB applications using the OLEDB driver · Pro*C applications · Distributed SQL Q) What are ORACLE PRECOMPILERS? A) A precompiler is a tool that allows programmers to embed SQL statements in high-level source programs like C, C++, COBOL, etc. The precompiler accepts the source program as input, translates the embedded SQL statements into standard Oracle runtime library calls, and generates a modified source program that one can compile, link, and execute in the usual way. Examples are the Pro*C Precompiler for C, Pro*Cobol for Cobol, SQLJ for Java etc. Q) What is syntax for dropping a procedure and a function? Are these operations possible? A) Drop Procedure/Function ; yes, if they are standalone procedures or functions. If they are a part of a package then one have to remove it from the package definition and body and recompile the package. Q) Can a function take OUT parameters. If not why? A) yes, IN, OUT or IN OUT. Q) Can the default values be assigned to actual parameters? A) Yes. In such case you don’t need to specify any value and the actual parameter will take the default value provided in the function definition. Q) What is difference between a formal and an actual parameter? A) The formal parameters are the names that are declared in the parameter list of the header of a module. The actual parameters are the values or expressions placed in the parameter list of the actual call to the module. Q) What are different modes of parameters used in functions and procedures? A) There are three different modes of parameters: IN, OUT, and IN OUT. IN - The IN parameter allows you to pass values in to the module, but will not pass anything out of the module and back to the calling PL/SQL block. In other words, for the

purposes of the program, its IN parameters function like constants. Just like constants, the value of the formal IN parameter cannot be changed within the program. You cannot assign values to the IN parameter or in any other way modify its value. IN is the default mode for parameters. IN parameters can be given default values in the program header. OUT - An OUT parameter is the opposite of the IN parameter. Use the OUT parameter to pass a value back from the program to the calling PL/SQL block. An OUT parameter is like the return value for a function, but it appears in the parameter list and you can, of course, have as many OUT parameters as you like. Inside the program, an OUT parameter acts like a variable that has not been initialised. In fact, the OUT parameter has no value at all until the program terminates successfully (without raising an exception, that is). During the execution of the program, any assignments to an OUT parameter are actually made to an internal copy of the OUT parameter. When the program terminates successfully and returns control to the calling block, the value in that local copy is then transferred to the actual OUT parameter. That value is then available in the calling PL/SQL block. IN OUT - With an IN OUT parameter, you can pass values into the program and return a value back to the calling program (either the original, unchanged value or a new value set within the program). The IN OUT parameter shares two restrictions with the OUT parameter: An IN OUT parameter cannot have a default value. An IN OUT actual parameter or argument must be a variable. It cannot be a constant, literal, or expression, since these formats do not provide a receptacle in which PL/SQL can place the outgoing value. Q) Difference between procedure and function. A) A function always returns a value, while a procedure does not. When you call a function you must always assign its value to a variable. Q) Can cursor variables be stored in PL/SQL tables. If yes how. If not why? A) Yes. Create a cursor type - REF CURSOR and declare a cursor variable of that type. DECLARE /* Create the cursor type. */ TYPE company_curtype IS REF CURSOR RETURN company%ROWTYPE; /* Declare a cursor variable of that type. */ company_curvar company_curtype; /* Declare a record with same structure as cursor variable. */ company_rec company%ROWTYPE; BEGIN /* Open the cursor variable, associating with it a SQL statement. */ OPEN company_curvar FOR SELECT * FROM company; /* Fetch from the cursor variable. */ FETCH company_curvar INTO company_rec;

/* Close the cursor object associated with variable. */ CLOSE company_curvar; END; Q) How do you pass cursor variables in PL/SQL? A) Pass a cursor variable as an argument to a procedure or function. You can, in essence, share the results of a cursor by passing the reference to that result set. Q) How do you open and close a cursor variable. Why it is required? A) Using OPEN cursor_name and CLOSE cursor_name commands. The cursor must be opened before using it in order to fetch the result set of the query it is associated with. The cursor needs to be closed so as to release resources earlier than end of transaction, or to free up the cursor variable to be opened again. Q) What should be the return type for a cursor variable. Can we use a scalar data type as return type? A) The return type of a cursor variable can be %ROWTYPE or record_name%TYPE or a record type or a ref cursor type. A scalar data type like number or varchar can’t be used but a record type may evaluate to a scalar value. Q) What is use of a cursor variable? How it is defined? A) Cursor variable is used to mark a work area where Oracle stores a multi-row query output for processing. It is like a pointer in C or Pascal. Because it is a TYPE, it is defined as TYPE REF CURSOR RETURN ; Q) What WHERE CURRENT OF clause does in a cursor? A) The Where Current Of statement allows you to update or delete the record that was last fetched by the cursor. Q) Difference between NO DATA FOUND and %NOTFOUND A) NO DATA FOUND is an exception which is raised when either an implicit query returns no data, or you attempt to reference a row in the PL/SQL table which is not yet defined. SQL%NOTFOUND, is a BOOLEAN attribute indicating whether the recent SQL statement does not match to any row. Q) What is a cursor for loop? A) A cursor FOR loop is a loop that is associated with (actually defined by) an explicit cursor or a SELECT statement incorporated directly within the loop boundary. Use the cursor FOR loop whenever (and only if) you need to fetch and process each and every record from a cursor, which is a high percentage of the time with cursors. Q) What are cursor attributes? A) Cursor attributes are used to get the information about the current status of your cursor. Both explicit and implicit cursors have four attributes, as shown: Name Description %FOUND Returns TRUE if record was fetched successfully, FALSE otherwise.

%NOTFOUND Returns TRUE if record was not fetched successfully, FALSE otherwise. %ROWCOUNT Returns number of records fetched from cursor at that point in time. %ISOPEN Returns TRUE if cursor is open, FALSE otherwise. Q) Difference between an implicit & an explicit cursor. A) The implicit cursor is used by Oracle server to test and parse the SQL statements and the explicit cursors are declared by the programmers. Q) What is a cursor? A) A cursor is a mechanism by which you can assign a name to a “select statement” and manipulate the information within that SQL statement. Q) What is the purpose of a cluster? A) A cluster provides an optional method of storing table data. A cluster is comprised of a group of tables that share the same data blocks, which are grouped together because they share common columns and are often used together. For example, the EMP and DEPT table share the DEPTNO column. When you cluster the EMP and DEPT, Oracle physically stores all rows for each department from both the EMP and DEPT tables in the same data blocks. You should not use clusters for tables that are frequently accessed individually. Q) How do you find the number of rows in a Table ? A) select count(*) from table, or from NUM_ROWS column of user_tables if the table statistics has been collected. Q) Display the number value in Words? A) Q) What is a pseudo column. Give some examples? A) Information such as row numbers and row descriptions are automatically stored by Oracle and is directly accessible, ie. not through tables. This information is contained within pseudo columns. These pseudo columns can be retrieved in queries. These pseudo columns can be included in queries which select data from tables. Available Pseudo Columns · ROWNUM - row number. Order number in which a row value is retrieved. · ROWID - physical row (memory or disk address) location, ie. unique row identification. · SYSDATE - system or today’s date. · UID - user identification number indicating the current user. · USER - name of currently logged in user. Q) How you will avoid your query from using indexes? A) By changing the order of the columns that are used in the index, in the Where condition, or by concatenating the columns with some constant values. Q) What is a OUTER JOIN? A) An OUTER JOIN returns all rows that satisfy the join condition and also returns some

or all of those rows from one table for which no rows from the other satisfy the join condition. Q) Which is more faster - IN or EXISTS? A) Well, the two are processed very differently. Select * from T1 where x in ( select y from T2 ) is typically processed as: select * from t1, ( select distinct y from t2 ) t2 where t1.x = t2.y; The sub query is evaluated, distinct’ed, indexed (or hashed or sorted) and then joined to the original table — typically. As opposed to select * from t1 where exists ( select null from t2 where y = x ) That is processed more like: for x in ( select * from t1 ) loop if ( exists ( select null from t2 where y = x.x ) then OUTPUT THE RECORD end if end loop It always results in a full scan of T1 whereas the first query can make use of an index on T1(x). So, when is where exists appropriate and in appropriate? Lets say the result of the sub query ( select y from T2 ) is “huge” and takes a long time. But the table T1 is relatively small and executing ( select null from t2 where y = x.x ) is very fast (nice index on t2(y)). Then the exists will be faster as the time to full scan T1 and do the index probe into T2 could be less then the time to simply full scan T2 to build the sub query we need to distinct on. Lets say the result of the sub query is small — then IN is typically more appropriate. If both the sub query and the outer table are huge — either might work as well as the other — depends on the indexes and other factors. Q) When do you use WHERE clause and when do you use HAVING clause? A) The WHERE condition lets you restrict the rows selected to those that satisfy one or more conditions. Use the HAVING clause to restrict the groups of returned rows to those groups for which the specified condition is TRUE. Q) There is a % sign in one field of a column. What will be the query to find it? A) SELECT column_name FROM table_name WHERE column_name LIKE ‘%\%%’ ESCAPE ‘\’; Q) What is difference between SUBSTR and INSTR? A) INSTR function search string for sub-string and returns an integer indicating the position of the character in string that is the first character of this occurrence. SUBSTR function return a portion of string, beginning at character position, substring_length

characters long. SUBSTR calculates lengths using characters as defined by the input character set. Q) Which data type is used for storing graphics and images? A) Raw, Long Raw, and BLOB. Q) What is difference between SQL and SQL*PLUS? A) SQL is the query language to manipulate the data from the database. SQL*PLUS is the tool that lets to use SQL to fetch and display the data. Q) What is difference between UNIQUE and PRIMARY KEY constraints? A) An UNIQUE key can have NULL whereas PRIMARY key is always not NOT NULL. Both bears unique values. Q) What is difference between Rename and Alias? A) Rename is actually changing the name of an object whereas Alias is giving another name (additional name) to an existing object. Q) What are various joins used while writing SUBQUERIES? A) =, , IN, NOT IN, IN ANY, IN ALL, EXISTS, NOT EXISTS. Q: What is an UTL_FILE.What are different procedures and functions associated with it? A: UTL_FILE is a package you use for reading/writing a file located on an Oracle server. It cannot be used to access files locally, that is on the computer where the client is running. Q: There is a % sign in one field of a column. What will be the query to find it? A: To find out the % sign we should use a Escape in where clause. Using Escape we can find out the exact match of the wild card charasters. e.g. select percentage from commission where percentage like ‘0.99\%’ escape ‘\’; Q: What is difference between UNIQUE and PRIMARY KEY constraints? A: Both are Constraints and both creates an index on the specified columns. UNIQUE is a constraint which enforces distinct column values on a table column and can contain a NULL record also. PRIMARY KEY is a constraint similar to UNIQUE, however it cannot have a Null value for the column. Moreover a PRIMARY KEY can be the parent column for a Parent - Child relationship(Foreign Key). Some other questions: 1. Differentiate between TRUNCATE and DELETE

2. What is the maximum buffer size that can be specified using the DBMS_OUTPUT.ENABLE function? 3. Can you use a commit statement within a database trigger? 4. What is an UTL_FILE.What are different procedures and functions associated with it? 5. Difference between database triggers and form triggers? 6. What is OCI. What are its uses? 7. What are ORACLE PRECOMPILERS? 8. What is syntax for dropping a procedure and a function? Are these operations possible? 9. Can a function take OUT parameters. If not why? 10. Can the default values be assigned to actual parameters? 11. What is difference between a formal and an actual parameter? 12. What are different modes of parameters used in functions and procedures? 13. Difference between procedure and function. 14. Can cursor variables be stored in PL/SQL tables.If yes how. If not why? 15. How do you pass cursor variables in PL/SQL? 16. How do you open and close a cursor variable.Why it is required? 17. What should be the return type for a cursor variable.Can we use a scalar data type as return type? 18. What is use of a cursor variable? How it is defined? 19. What WHERE CURRENT OF clause does in a cursor? 20. Difference between NO DATA FOUND and %NOTFOUND 21. What is a cursor for loop? 22. What are cursor attributes? 23. Difference between an implicit & an explicit cursor. 24. What is a cursor? 25. What is the purpose of a cluster? 26. How do you find the numbert of rows in a Table ? 27. Display the number value in Words? 28. What is a pseudo column. Give some examples? 29. How you will avoid your query from using indexes? 30. What is a OUTER JOIN? 31. Which is more faster - IN or EXISTS? 32. When do you use WHERE clause and when do you use HAVING clause? 33. There is a % sign in one field of a column. What will be the query to find it? 34. What is difference between SUBSTR and INSTR? 35. Which datatype is used for storing graphics and images? 36. What is difference between SQL and SQL*PLUS? 37. What is difference between UNIQUE and PRIMARY KEY constraints? 38. What is difference between Rename and Alias? 39. What are various joins used while writing SUBQUERIES?

1. Which of the following statements is true about implicit cursors?

2.

3.

4.

5.

6.

7.

8.

1. Implicit cursors are used for SQL statements that are not named. 2. Developers should use implicit cursors with great care. 3. Implicit cursors are used in cursor for loops to handle data processing. 4. Implicit cursors are no longer a feature in Oracle. Which of the following is not a feature of a cursor FOR loop? 1. Record type declaration. 2. Opening and parsing of SQL statements. 3. Fetches records from cursor. 4. Requires exit condition to be defined. A developer would like to use referential datatype declaration on a variable. The variable name is EMPLOYEE_LASTNAME, and the corresponding table and column is EMPLOYEE, and LNAME, respectively. How would the developer define this variable using referential datatypes? 1. Use employee.lname%type. 2. Use employee.lname%rowtype. 3. Look up datatype for EMPLOYEE column on LASTNAME table and use that. 4. Declare it to be type LONG. Which three of the following are implicit cursor attributes? 1. %found 2. %too_many_rows 3. %notfound 4. %rowcount 5. %rowtype If left out, which of the following would cause an infinite loop to occur in a simple loop? 1. LOOP 2. END LOOP 3. IF-THEN 4. EXIT Which line in the following statement will produce an error? 1. cursor action_cursor is 2. select name, rate, action 3. into action_record 4. from action_table; 5. There are no errors in this statement. The command used to open a CURSOR FOR loop is 1. open 2. fetch 3. parse 4. None, cursor for loops handle cursor opening implicitly. What happens when rows are found using a FETCH statement 1. It causes the cursor to close 2. It causes the cursor to open 3. It loads the current row values into variables 4. It creates the variables to hold the current row values

9. Read the following code: CREATE OR REPLACE PROCEDURE find_cpt (v_movie_id {Argument Mode} NUMBER, v_cost_per_ticket {argument mode} NUMBER) IS BEGIN IF v_cost_per_ticket > 8.5 THEN SELECT cost_per_ticket INTO v_cost_per_ticket FROM gross_receipt WHERE movie_id = v_movie_id; END IF; END; Which mode should be used for V_COST_PER_TICKET? 1. 2. 3. 4. IN OUT RETURN IN OUT

10. Read the following code: CREATE OR REPLACE TRIGGER update_show_gross {trigger information} BEGIN {additional code} END; The trigger code should only execute when the column, COST_PER_TICKET, is greater than $3. Which trigger information will you add? a. WHEN (new.cost_per_ticket > 3.75) b. WHEN (:new.cost_per_ticket > 3.75 c. WHERE (new.cost_per_ticket > 3.75) d. WHERE (:new.cost_per_ticket > 3.75) 11. What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs? a. Only one b. All that apply c. All referenced d. None 12. For which trigger timing can you reference the NEW and OLD qualifiers? a. Statement and Row b. Statement only c. Row only

d. Oracle Forms trigger 13. Read the following code: CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END; Which set of statements will successfully invoke this function within SQL*Plus? a. VARIABLE g_yearly_budget NUMBER EXECUTE g_yearly_budget := GET_BUDGET(11); b. VARIABLE g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11); c. VARIABLE :g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11); d. VARIABLE g_yearly_budget NUMBER :g_yearly_budget := GET_BUDGET(11); CREATE OR REPLACE PROCEDURE update_theater (v_name IN VARCHAR v_theater_id IN NUMBER) IS BEGIN UPDATE theater SET name = v_name WHERE id = v_theater_id; END update_theater; 14. When invoking this procedure, you encounter the error: ORA-000: Unique constraint(SCOTT.THEATER_NAME_UK) violated. How should you modify the function to handle this error? a. An user defined exception must be declared and associated with the error code and handled in the EXCEPTION section.

b. Handle the error in EXCEPTION section by referencing the error code directly. c. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception. d. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement. 15. Read the following code: CREATE OR REPLACE PROCEDURE calculate_budget IS v_budget studio.yearly_budget%TYPE; BEGIN v_budget := get_budget(11); IF v_budget < 30000 THEN set_budget(11,30000000); END IF; END; You are about to add an argument to CALCULATE_BUDGET. What effect will this have? a. The GET_BUDGET function will be marked invalid and must be recompiled before the next execution. b. The SET_BUDGET function will be marked invalid and must be recompiled before the next execution. c. Only the CALCULATE_BUDGET procedure needs to be recompiled. d. All three procedures are marked invalid and must be recompiled. 16. Which procedure can be used to create a customized error message? a. RAISE_ERROR b. SQLERRM c. RAISE_APPLICATION_ERROR d. RAISE_SERVER_ERROR 17. The CHECK_THEATER trigger of the THEATER table has been disabled. Which command can you issue to enable this trigger? a. ALTER TRIGGER check_theater ENABLE; b. ENABLE TRIGGER check_theater; c. ALTER TABLE check_theater ENABLE check_theater; d. ENABLE check_theater; 18. Examine this database trigger 19. CREATE OR REPLACE TRIGGER prevent_gross_modification 20. {additional trigger information} 21. BEGIN 22. IF TO_CHAR(sysdate, DY) = MON 23. THEN 24. RAISE_APPLICATION_ERROR(-20000,Gross receipts cannot be deleted on Monday);

25. END IF; 26. END; This trigger must fire before each DELETE of the GROSS_RECEIPT table. It should fire only once for the entire DELETE statement. What additional information must you add? a. BEFORE DELETE ON gross_receipt b. AFTER DELETE ON gross_receipt c. BEFORE (gross_receipt DELETE) d. FOR EACH ROW DELETED FROM gross_receipt 27. Examine this function: 28. CREATE OR REPLACE FUNCTION set_budget 29. (v_studio_id IN NUMBER, v_new_budget IN NUMBER) IS 30. BEGIN 31. UPDATE studio 32. SET yearly_budget = v_new_budget 33. WHERE id = v_studio_id; 34. 35. IF SQL%FOUND THEN 36. RETURN TRUEl; 37. ELSE 38. RETURN FALSE; 39. END IF; 40. 41. COMMIT; 42. END; Which code must be added to successfully compile this function? a. Add RETURN right before the IS keyword. b. Add RETURN number right before the IS keyword. c. Add RETURN boolean right after the IS keyword. d. Add RETURN boolean right before the IS keyword. 43. Under which circumstance must you recompile the package body after recompiling the package specification? a. Altering the argument list of one of the package constructs b. Any change made to one of the package constructs c. Any SQL statement change made to one of the package constructs d. Removing a local variable from the DECLARE section of one of the package constructs 44. Procedure and Functions are explicitly executed. This is different from a database trigger. When is a database trigger executed? a. When the transaction is committed b. During the data manipulation statement c. When an Oracle supplied package references the trigger

d. During a data manipulation statement and when the transaction is committed 45. Which Oracle supplied package can you use to output values and messages from database triggers, stored procedures and functions within SQL*Plus? a. DBMS_DISPLAY b. DBMS_OUTPUT c. DBMS_LIST d. DBMS_DESCRIBE 46. What occurs if a procedure or function terminates with failure without being handled? a. Any DML statements issued by the construct are still pending and can be committed or rolled back. b. Any DML statements issued by the construct are committed c. Unless a GOTO statement is used to continue processing within the BEGIN section, the construct terminates. d. The construct rolls back any DML statements issued and returns the unhandled exception to the calling environment. 47. Examine this code 48. BEGIN 49. theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year; 50. END; For this code to be successful, what must be true? a. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist only in the body of the THEATER_PCK package. b. Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package. c. Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package. d. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist in the specification of the THEATER_PCK package. 51. A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hard-coded and must be created dynamically when the function is executed. Which Oracle supplied package will enable this feature? a. DBMS_DDL b. DBMS_DML c. DBMS_SYN d. DBMS_SQL

Sign up to vote on this title
UsefulNot useful