Professional Documents
Culture Documents
more values using OUT & INOUT Parameters) or may not return a value. But a function has to return a single value and has the return clause in its definition. Function can be called in select statements but procedure can only be called in a pl/sql block. Procedure's parameters can have IN or OUT or INOUT parameters. But function's parameters can only have IN parameters.
string representing the address of a row.It gives the location in database where row is physically stored. ROWNUM: It gives a sequence number in which rows are retrieved from the database.
4. Difference b/w implicit cursor and explicit cursor? Implicit cursors are
automatically created by oracle for all its DML stmts. Examples of implicit cursors: SQL%FOUND, SQL%NOTFOUND, SQL%ROWCOUNT, SQL%ISOPEN; Explicit cursors are created by the users for multi row select stmts.
The above piece of code can be written In procedure and function DDL's can be used in function provided that function should be invoked in Begin-End block not from Select statement.
7. What is the purpose of FORUPDATE? Selecting in FOR UPDATE mode locks the
result set of rows in update mode, which means that row cannot be updated or deleted until a commit or rollback is issued which will release the row(s). If you plan on updating or deleting records that have been referenced by a Select For Update statement, you can use the Where Current Of statement.
procedure defined by Oracle that allows the developer to raise an exception and associate an error number and message with the procedure other than just Oracle errors. Raising an Application Error With raise_application_error
DECLARE num_tables NUMBER; BEGIN SELECT COUNT(*) INTO num_tables FROM USER_TABLES; IF num_tables < 1000 THEN /* Issue your own error code (ORA-20101) with your own error message. Note that you do not need to qualify raise_application_error with DBMS_STANDARD */ raise_application_error(-20101, 'Expecting at least 1000 tables');
9.
ELSE NULL; -- Do the rest of the processing (for the non-error case). END IF; END; /
The procedure RAISE_APPLICATION_ERROR lets you issue user-defined ORA- error messages from stored subprograms. That way, you can report errors to your application and avoid returning unhandled exceptions.
11. Can we make the trigger an autonomous transaction? This makes all the
difference because within the autonomous transaction (the trigger), Oracle will view the triggering table as it was before any changes occurredthat is to say that any changes are uncommitted and the autonomous transaction doesnt see them. So the potential confusion Oracle normally experiences in a mutating table conflict doesnt exist.
13. What is a REF Cursor? The REF CURSOR is a data type in the Oracle PL/SQL
language. It represents a cursor or a result set in Oracle Database.
14. What is the difference between ref cursors and normal pl/sql cursors?
Declare type rc is ref cursor; cursor c is select * from dual; l_cursor rc; begin if ( to_char(sysdate,'dd') = 30 ) then open l_cursor
for select * from elsif ( to_char(sysdate,'dd') = open l_cursor for select * from else open l_cursor for select * from end if; open c; end;
Given that block of code you see perhaps the most "salient" difference, no matter how many times you run that block The cursor C will always be select * from dual. The ref cursor can be anything.
15. Is Truncate a DDL or DML statement? And why? Truncate is a DDL statement.
Check the LAST_DDL_TIME on USER_OBJECTS after truncating your table. TRUNCATE will automatically commit, and it's not rollback able. This changes the storage definition of the object. That's why it is a DDL.
16. What are the actions you have to perform when you drop a package? If you
rename a package, the other packages that use it will have to be MODIFIED. A simple compilation of the new renamed package won't do. If you have toad, go to the "used by" tab that will show you the packages that call the package being renamed.
17. What is cascading triggers? When a trigger fires, a SQL statement within its
trigger action potentially can fire other triggers, resulting in cascading triggers. 18. What are materialized views? A materialized view is a database object that stores the results of a query (possibly from a remote database). Materialized views are sometimes referred to as snapshots.
19. Example
If the materialized view will access remote database objects, we need to start by creating a database link to the remote DB:
CREATE DATABASE LINK remotedb CONNECT TO scott IDENTIFIED BY tiger USING 'orcl';
Now we can create the materialized view to pull in data (in this example, across the database link):
CREATE MATERIALIZED VIEW items_summary_mv ON PREBUILT TABLE REFRESH FORCE AS SELECT a.PRD_ID, a.SITE_ID, a.TYPE_CODE, a.CATEG_ID, sum(a.GMS) sum(a.NET_REV) GMS, NET_REV,
sum(a.BOLD_FEE) BOLD_FEE, sum(a.BIN_PRICE) BIN_PRICE, sum(a.GLRY_FEE) GLRY_FEE, sum(a.QTY_SOLD) QTY_SOLD, count(a.ITEM_ID) UNITS FROM items@remotedb a GROUP BY a.PRD_ID, a.SITE_ID, a.TYPE_CODE, a.CATEG_ID;
Materialized view logs: Materialized view logs are used to track changes (insert, update and delete) to a table. Remote materialized views can use the log to speed-up data replication by only transferring changed records. Example: CREATE MATERIALIZED VIEW LOG ON items;
3. Width or margin is zero: When the repeating frame is not within proper frames 4. Not in proper group: When the repeating frame is not referred to proper group
21. What is the difference between Compile and Incremental Compile in oracle reports?
In Full compile all the PL/SQL within the reports are compiled but in incremental compile only the changed PL/SQL units are compiled. When compiling the report for the first time, we should do the full compilation and not the Incremental compile.