0% found this document useful (0 votes)
134 views

PLSQL Urgent

Pragma is a PL/SQL keyword used to provide compiler instructions. Types include AUTONOMOUS_TRANSACTION and RESTRICT_REFERENCES. Views and materialized views allow querying of remote data locally. Collections include index-by tables, nested tables, and varrays. DBMS_JOB allows scheduling jobs. High water mark tracks maximum block usage. PCTFREE and PCTUSED control block space usage for updates. Explicit cursors handle multiple rows while implicit cursors handle single rows. REF cursors provide flexibility in associating queries. RAC allows shared database access across instances. Triggers automatically execute on events. Exceptions handle errors during execution.

Uploaded by

tota111
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views

PLSQL Urgent

Pragma is a PL/SQL keyword used to provide compiler instructions. Types include AUTONOMOUS_TRANSACTION and RESTRICT_REFERENCES. Views and materialized views allow querying of remote data locally. Collections include index-by tables, nested tables, and varrays. DBMS_JOB allows scheduling jobs. High water mark tracks maximum block usage. PCTFREE and PCTUSED control block space usage for updates. Explicit cursors handle multiple rows while implicit cursors handle single rows. REF cursors provide flexibility in associating queries. RAC allows shared database access across instances. Triggers automatically execute on events. Exceptions handle errors during execution.

Uploaded by

tota111
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Pragma: Pragma is a keyword in Oracle PL/SQL that is used to provide an instruction to the compiler.

Pragmas are defined in the declarative section in PL/SQL. Types: AUTONOMOUS_TRANSACTION, EXCEPTION_INIT, RESTRICT_REFERENCES, SERIALLY_REUSABLE Autonomous Transaction: an autonomous transaction is an independent transaction that is initiated by another transaction. It must contain at least one SQL statement. The autonomous transaction must commit or roll back before it returns control to the calling transaction. Stored, local and Package procedure and function. View & Materialized View: A view is a virtual table representing the result of a database query. A materialized view is a database object that contains the results of a query. They are local copies of data located remotely or are used to create summary tables based on aggregations of a table's data. The materialized view is a table whose contents are periodically refreshed using a query against a remote table. Collections: Index-By Table, Nested Table and Varray.

PLSQL Table: A PL/SQL table is a one-dimensional, unbounded, sparse collection of homogenous elements, indexed by integers DBMS_JOB allows a user to schedule a job to run at a specified time. A job is submitted to a job queue and runs at the specified time.
DBMS-JOB: DBMS_JOB.SUBMIT ( job OUT BINARY_INTEGER, what IN VARCHAR2, next_date IN DATE DEFAULT sysdate, interval IN VARCHAR2 DEFAULT 'null',); High Water Mark: High water mark is the maximum amount of database blocks used so far by a segment. This mark cannot be reset by delete operations. TRUNCATE will reset HWM. PCTFREE & PCTUSED- This parameter is used to specify how much space should be left in the block for updates. e.g. PCTUSED as 40 %. And PCTFREE as 20 %. 1. Oracle will keep on inserting new rows till the space is 80 % used. It will reserve the remaining 20% for future updates. 2. To start adding new rows again to the block, Oracle will check the space in the Block and the PCTUSED parameter. 3. When the space falls below 40 %, Oracle will start adding new rows to the block. Inline View: An inline view is a SELECT statement in the FROM-clause of another SELECT statement External Table: External tables allow Oracle to query data that is stored outside the database in flat files. No DML can be performed on external tables but they can be used for query, join and sort operations. Views and synonyms can be created against external tables. Cursor: For every SQL statement execution certain area in memory is allocated. This private SQL area is called context area or cursor. A cursor acts as a handle or pointer into the context area. A PL/SQL program controls the context area using the cursor. Explicit Cursors: Explicit cursors are used in queries that return multiple rows. The set of rows fetched by a query is called active set. The size of the active set meets the search criteria in the select statement. Explicit cursor is declared in the DECLARE section of PL/SQL program. Implicit cursors: For SQL queries returning single row PL/SQL declares implicit cursors. Implicit cursors are simple SELECT statements and are written in the BEGIN block (executable section) of the PL/SQL. Implicit cursors are easy to code, and they retrieve exactly one row. PL/SQL implicitly declares cursors for all DML statements. Difference: Implicit Cursor are declared and used by the oracle internally. Whereas the explicit cursors are declared and used by the user. More over implicitly cursors are no need to declare oracle creates and process and closes automatically. The explicit cursor should be declared and closed by the user. Implicit cursor can be used to handle single record (i.e.) the select query used should not yield more than one row. if u have handle more than one record then Explicit cursor should be used. Cursor Attributes: %NOTFOUND, %FOUND, %ROWCOUNT, %ISOPEN.

Ref Cursor: The cursor declaration is not associated with any SQL query; it is associated with a query at a later stage this brings in a lot of flexibility as different SQL queries can be associated with the cursor (one at a time, off course) programmatically. REF Cursors also provide the feature of passing parameters

In an Oracle RAC environment, two or more computers (each with an instance) concurrently access a single database. This allows an application or user to connect to either computer and have access to a single coordinated set of data. Temporary Table: temp tables are used to store intermediately results and the data in the temp table is either a
RAC: truncation specifies of session specific. ON COMMIT DELETE ROWS; ON COMMIT PRESERVE ROWS. Instead of Triggers: INSTEAD OF triggers describe how to perform insert, update, and delete operations against views that
are too complex to support these operations natively. Using an INSTEAD OF trigger, the requested modify operation against the view gets replaced by the trigger logic, which performs the operation on behalf of the view.

Database Triggers: A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for keeping the integrity of the information on the database. DML, DDL, DCL, Mutating Table: A mutating table is a table that is currently being modified by an update, delete, or insert statement. When a trigger tries to reference a table that is in state of flux (being changed), it is considered "mutating", and raises an error since Oracle should never return inconsistent data. Here are a few more differences between a procedure and a function: A function MUST return a value,A procedure cannot return a value Procedures and functions can both return data in OUT and IN OUT parameters The return statement in a function returns control to the calling program and returns the results of the function The return statement of a procedure returns control to the calling program and cannot return a value Functions can be called from SQL, procedure cannot Functions are considered expressions, procedure are not
Use function output in select statement (like Select fnTest(), a from test a) Use function output in joins (like test a LEFT OUTER JOIN fnTest() b )

The Same procedure name is repeated with parameters of different data types and parameters in different positions, varying number of parameters is called overloading of procedures.
Packages: A package is a group of related procedures and functions, together with the cursors and variables they use, stored together in the database for continued use as a unit. Similar to standalone procedures and functions, packaged procedures and functions can be called explicitly by applications or users. Advantage:

Encapsulation of related procedures and variables Declaration of public and private procedures, variables, constants, and cursors Separation of the package specification and package body Better performance The entire package is loaded into memory when a procedure within the package is called for the first time. This load is completed in one operation, as opposed to the separate loads required for standalone procedures. Therefore, when calls to related packaged procedures occur, no disk I/O is necessary to execute the compiled code already in memory.

A package body can be replaced and recompiled without affecting the specification. As a result, objects that reference a package's constructs (always via the specification) never need to be recompiled unless the package specification is also replaced. By using packages, unnecessary recompilations can be minimized, resulting in less impact on overall database performance.

Execute Immediate: The EXECUTE IMMEDIATE statement executes a dynamic SQL statement or anonymous PL/SQL block. EXECUTE IMMEDIATE 'CREATE TABLE execute_table (col1 VARCHAR (10))';

Pseudo-column: A pseudo-column is an Oracle assigned value (pseudo-field) used in the same context as an Oracle Database column, but not stored on disk. Pseudocolumns are not actual columns in a table but they behave like columns. SYSDATE, SYSTIMESTAMP, ROWID, ROWNUM, UID, USER, LEVEL, CURRVAL, NEXTVAL, ORA_ROWSCN, etc. .Clusters: A cluster is a data structure that improves retrieval performance. A cluster is a way of storing related data
values together on disk. Oracle reads data a block at a time, so storing related values together reduces the number of I/O operations needed to retrieve related values, since a single data block will contain only related rows. A cluster is composed of one or more tables. The cluster includes a cluster index, which stores all the values for the corresponding cluster key. Exceptions: An Exception is an error situation, which arises during program execution. When an error occurs exception is raised, normal execution is stopped and control transfers to exception-handling part. Exception handlers are routines written to handle the exception. The exceptions can be internally defined (system-defined or pre-defined) or User-defined exception. Predefined exception: is raised automatically whenever there is a violation of Oracle coding rules. CURSOR_ALREADY_OPEN Raised when we try to open an already open cursor. DUP_VAL_ON_INDEX When you try to insert a duplicate value into a unique column INVALID_CURSOR It occurs when we try accessing an invalid cursor INVALID_NUMBER On usage of something other than number in place of number value. LOGIN_DENIED At the time when user login is denied TOO_MANY_ROWS When a select query returns more than one row and the destination variable can take only single value. VALUE_ERROR When an arithmetic, value conversion, truncation, or constraint error occurs. User-defined Exceptions: A User-defined exception has to be defined by the programmer. User-defined exceptions are declared in the declaration section with their type as exception. They must be raised explicitly using RAISE statement

SQLCODE returns the latest code of the error that has occurred. SQLERRM returns the relevant error message of the SQLCODE.

You might also like