1 2 3 4 5 6 > >>   Sort: Rank

Define a Variable to Match Column Data Type in Oracle
How To Define a Variable to Match a Table Column Data Type in Oracle? If you have a table, and want to define some variables to have exactly the same data types as some columns in that table, you can use table_name.column_name%TYPE as data types to define those variables. The tutorial sample below s...
2018-08-14, 424👍, 0💬

Insert a RECORD into a Table in Oracle
How To Insert a RECORD into a Table in Oracle? If you have a RECORD variable with data fields matching a table structure, you can insert a row to this table with this RECORD variable using the INSERT statement as shown in the example below: CREATE TABLE emp_temp AS SELECT * FROM employees; CREATE OR...
2018-08-14, 383👍, 0💬

Update a Table Row with a RECORD in Oracle
How To Update a Table Row with a RECORD in Oracle? If you have a RECORD variable with data fields matching a table structure, you can update a row in this table with this RECORD variable using the UPDATE ... SET ROW statement as shown in the sample script below: CREATE TABLE emp_temp AS SELECT * FRO...
2018-08-14, 383👍, 0💬

Assign a Table Row to RECORD Variable in Oracle
How To Assign a Table Row to a RECORD Variable in Oracle? If you have a table, and want to assign a data row of that table to a RECORD variable, you need to define this RECORD variable to match the table column structure, then use the SELECT ... INTO statement to assign a data row that RECORD variab...
2018-08-14, 374👍, 0💬

Define a RECORD Variable for a Table Row in Oracle
How To Define a RECORD Variable to Store a Table Row in Oracle? If you have a table, and want to define a RECORD variable to store all the data elements of a row from that table, you can use table_name%ROWTYPE to define the RECORD variable as shown in the following sample script: CREATE TABLE studen...
2018-08-14, 308👍, 0💬

Logical Operations in PL/SQL in Oracle
What Are the Logical Operations in Oracle? PL/SQL supports 3 logical operations as shown in the following sample script: PROCEDURE proc_comparison AS x BOOLEAN := TRUE; y BOOLEAN := FALSE; res BOOLEAN; BEGIN res = x AND y; res = x OR y; res = NOT x; -- more statements END;   ⇒Understanding PL/SQL La...
2018-08-06, 449👍, 0💬

Arithmetic Operations in Pl/SQL in Oracle
What Are the Arithmetic Operations in Oracle? There are 4 basic arithmetic operations on numeric values as shown in the following sample script: PROCEDURE proc_arithmetic AS addition NUMBER; subtraction NUMBER; multiplication NUMBER; division NUMBER; BEGIN addition := 7 + 8; subtraction := addition ...
2018-08-06, 399👍, 0💬

Assign Values to Variables in Oracle
How To Assign Values to Variables in Oracle? You can use assignment statements to assign values to variables. An assignment statement contains an assignment operator ":=", which takes the value specified on the right to the variable on left. The script below show you some examples of assignment stat...
2018-08-06, 391👍, 0💬

Numeric Comparison Operations in Oracle
What Are the Numeric Comparison Operations in Oracle? PL/SQL supports 6 basic numeric comparison operations as shown in the following sample script: PROCEDURE proc_comparison AS res BOOLEAN; BEGIN res := 1 = 2; res := 1 < 2; res := 1 > 2; res := 1 <= 2; res := 1 >= 2; res...
2018-08-06, 382👍, 0💬

Initialize Variables with Default Values in Oracle
How To Initialize Variables with Default Values in Oracle? There are two ways to assign default values to variables at the time of declaration: Using key word DEFAULT - Appending "DEFAULT value" to the end of declaration statements. Using assignment operator - Appending ":= value" to the end of decl...
2018-08-06, 323👍, 0💬

Retrieve Data from an Explicit Cursor in Oracle
How To Retrieve Data from an Explicit Cursor in Oracle? If you have a cursor opened ready to use, you can use the FETCH ... INTO statement to retrieve data from the cursor into variables. FETCH statement will: Retrieve all the fields from the row pointed by the current cursor pointer and assign them...
2018-07-22, 433👍, 0💬

Retrieve Data from a Cursor to a RECORD in Oracle
How To Retrieve Data from a Cursor to a RECORD in Oracle? If you have a cursor opened ready to use, you can also use the FETCH statement to retrieve data from the cursor into a RECORD variable as shown in the tutorial exercise below: CREATE OR REPLACE PROCEDURE FYI_CENTER AS CURSOR t_list IS SELECT ...
2018-07-22, 420👍, 0💬

Define an Explicit Cursor in Oracle
How To Define an Explicit Cursor in Oracle? An explicit cursor must be defined in the declaration part of a procedure or function with the CURSOR ... IS statement as shown in the following sample script: DECLARE CURSOR c_list IS SELECT * FROM countries; CURSOR t_list IS SELECT * FROM employees WHERE...
2018-07-22, 384👍, 0💬

Loop through the Implicit Cursor in Oracle
How To Loop through Data Rows in the Implicit Curosr in Oracle? You use the FOR ... IN ... LOOP statement to loop through data rows in the implicit cursor as the following syntax: FOR row IN dml_statement LOOP (statement block with row.field) END LOOP; Here "row" is a local RECORD type variable with...
2018-07-22, 363👍, 0💬

Open and Close an Explicit Cursor in Oracle
How To Open and Close an Explicit Cursor in Oracle? An existing cursor can be opened or closed by the OPEN or CLOSE statement as shown in the following sample script: DECLARE CURSOR c_list IS SELECT * FROM countries; CURSOR t_list IS SELECT * FROM employees WHERE employee_id = 100; BEGIN OPEN c_list...
2018-07-22, 349👍, 0💬

Open a Cursor Variable in Oracle
How To Open a Cursor Variable in Oracle? A cursor variable must be opened with a specific query statement before you can fetch data fields from its data rows. To open a cursor variable, you can use the OPEN ... FOR statement as shown in the following tutorial exercise: CREATE OR REPLACE PROCEDURE FY...
2018-07-18, 455👍, 0💬

Loop through a Cursor Variable in Oracle
How To Loop through a Cursor Variable in Oracle? Once a cursor variable is opened with a query statement, it will have the same attributes as a normal cursor and it can be used in the same way a normal cursor too. The following sample script shows you how to loop through a cursor variable: CREATE OR...
2018-07-18, 418👍, 0💬

Define a Cursor Variable in Oracle
How To Define a Cursor Variable in Oracle? To define cursor variable, you must decide which REF CURSOR data type to use. There are 3 ways to select a REF CURSOR data type: Define your own specific REF CURSOR types using the TYPE ... RETURN statement. Define your own generic REF CURSOR type using the...
2018-07-18, 415👍, 0💬

Pass a Cursor Variable to a Procedure in Oracle
How To Pass a Cursor Variable to a Procedure in Oracle? A cursor variable can be passed into a procedure like a normal variable. The sample script below gives you a good example: CREATE OR REPLACE PROCEDURE FYI_CENTER AS sys_cur SYS_REFCURSOR; PROCEDURE emp_print(cur SYS_REFCURSOR) AS emp_rec employ...
2018-07-18, 397👍, 0💬

Pass a Parameter to a Cursor in Oracle
How To Pass a Parameter to a Cursor in Oracle? When you define a cursor, you can set a formal parameter in the cursor. The formal parameter will be replaced by an actual parameter in the OPEN cursor statement. Here is a good example of a cursor with two parameters: CREATE OR REPLACE PROCEDURE FYI_CE...
2018-07-18, 361👍, 0💬

What Is NULL in PL/SQL in Oracle
What Is NULL in PL/SQL in Oracle? NULL is a reserved key word and it stands for two things in PL/SQL: NULL is an executable statement, and means doing nothing. NULL is a data value, and means no value. The following sample script shows you examples of using NULL keyword: DECLARE next_task CHAR(80); ...
2018-07-13, 434👍, 0💬

Test NULL Values in Oracle
How To Test NULL Values in Oracle? There ate two special comparison operators you can use on NULL values: "variable IS NULL" - Returns TRUE if the variable value is NULL. "variable IS NOT NULL" - Return TRUE if the variable value is not NULL. The following sample script shows you examples of compari...
2018-07-13, 382👍, 0💬

Use "WHILE" Loop Statements in Oracle
How To Use "WHILE" Loop Statements in Oracle? If you have a block of codes to be executed repeatedly based a condition, you can use the "WHILE ... LOOP" statement. Here is a sample script on WHILE statements: DECLARE total NUMBER; BEGIN total := 0; WHILE total < 10 LOOP total := total+1; END ...
2018-07-13, 380👍, 0💬

Use "IF" Statements with Multiple Conditions in Oracle
How To Use "IF" Statements on Multiple Conditions in Oracle? If you have multiple blocks of codes to be executed based on different conditions, you can use the "IF ... ELSIF" statement. Here is a sample script on IF statements: DECLARE day VARCHAR2; BEGIN day := 'SUNDAY'; IF day = 'THURSDAY' THEN DB...
2018-07-13, 371👍, 0💬

1 2 3 4 5 6 > >>   Sort: Rank