PL/SQL Flashcards
What is the DECLARE keyword?
It is an optional section and defines all variables, cursors, subprograms, and other elements to be used in the program.
What is the keywords BEGIN and END?
keywords BEGIN and END and it is a
mandatory section. It consists of the executable PL/SQL statements of the
program. It should have at least one executable line of code, which may be just
a NULL command to indicate that nothing should be executed.
What is Scalar Datatype?
Single values with no internal components, such as a NUMBER, DATE, or BOOLEAN.
What is Numeric Datatype?
Data items that have internal components that can be accessed individually. For example, collections and records.
What is the VARCHAR2 Datatype?
Variable-length character string with maximum size of 32,767 bytes
What is a record?
A record is a data structure that can hold data items of different kinds. Records consist of different fields, similar to a row of a database table.
What is the context area for?
for processing an SQL statement, which contains all the
information needed for processing the statement; for example, the number of rows processed, etc.
A cursor is
A cursor is a pointer to this context area.
PL/SQL controls the context area through a
[Blank[
cursor.
A cursor holds the [Blank] (one or more) returned by a SQL statement.
rows
What is an Implicit Cursors?
Implicit cursors are automatically created by Oracle whenever an SQL statement is executed, when there is no explicit cursor for the statement. Programmers cannot control the implicit cursors and the information in it. Whenever a DML statement (INSERT, UPDATE and DELETE) is issued, an implicit cursor is
associated with this statement. For INSERT operations, the cursor holds the data that needs to be inserted. For UPDATE and DELETE operations, the cursor identifies the rows that would be affected.
What is an Explicit Cursors?
Explicit cursors are programmer-defined cursors for gaining more control over the context
area. An explicit cursor should be defined in the declaration section of the PL/SQL Block.
It is created on a SELECT Statement which returns more than one row.
CURSOR cursor_name IS select_statement;
What are Triggers?
Triggers are stored programs, which
are automatically executed or fired when some events occur. Triggers are, in fact, written
to be executed in response to any of the following events:
A database manipulation (DML) statement (DELETE, INSERT, or UPDATE).
A database definition (DDL) statement (CREATE, ALTER, or DROP).
A database operation (SERVERERROR, LOGON, LOGOFF, STARTUP, or
SHUTDOWN).
Triggers can be defined on the table, view, schema, or database with which the event is
associated.
How do you create a Trigger?
CREATE [OR REPLACE ] TRIGGER trigger_name {BEFORE | AFTER | INSTEAD OF } {INSERT [OR] | UPDATE [OR] | DELETE} [OF col_name] ON table_name [REFERENCING OLD AS o NEW AS n] [FOR EACH ROW] WHEN (condition) DECLARE Declaration-statements
What is a database TRANSACTION?
A database transaction is an atomic unit of work that may consist of one or more related SQL statements. It is called atomic because the database modifications brought about by the SQL statements that constitute a transaction can collectively be either committed, i.e., made permanent to the database or rolled back (undone) from the database