Professional Documents
Culture Documents
Fundamental SQL PL - SQL
Fundamental SQL PL - SQL
Q1.
ans.
A. a. b. c. d.
B. a.
b.
Operator Precedence The operations within an expression are evaluated in order of precedence. Operator precedence from highest to lowest order.
c. d.
You can use parentheses to control the order of evaluation and to improve readability. E.g.
Fundamental of PL/SQL
II. Pl/SQL Comparison; 1. Comparison operators compare one expression to another. 2. The result is always either TRUE, FALSE, OR NULL. 3. You use comparison operators in conditional control statements and in the WHERE clauses of SQL data manipulation statements. 4. The comparison operators :
RELATIONAL operators IS NULL Operator LIKE Operator BETWEEN Operator IN Operator
5.
RELATIONAL operators
6.
7.
IS NULL Operator : a. The IS NULL operator returns the BOOLEAN value ; TRUE; if its operand is NULL or FALSE; if it is not NULL. b. In Comparisons, NULL values always produce NULL. LIKE Operator :a. The LIKE operator compares a ; character, string, or CLOB value to a pattern and returns; TRUE if the value matches the pattern FALSE if it does not. b. E.g. Like operator;
8.
c.
d.
To search the percent sign or underscore, define an escape character and put it Before the percent sign or underscore.
note:- uses the backslash as the escape character, so that the percent sign in the string does not act as a wildcard.
Fundamental of PL/SQL
9. BETWEEN Operator :a. The BETWEEN operator tests whether a value lies in a specified range. b. x BETWEEN a AND b means that x >= a and x <= b. c. E.g. BETWEEN Operator;- invokes the print_boolean procedure of Q2.e(AND operator) to print values of some expressions that include the BETWEEN operator.
10. IN Operator:a. The IN operator tests set membership. b. x IN (set) means that x is equal to any member of set. c. E.g.; IN operator invokes the print_boolean procedure created in Q2.e(AND operator) to print values of some expressions that include the IN operator.
d.
Below E.g. shows what happens when set contains a NULL value. (This e.g. invokes the print_boolean procedure created in Q2.e(AND operator) )
d.
e.
Fundamental of PL/SQL
f. E.g. OR Operator
g.
Eg NOT Operator
a.
b.
c.
Fundamental of PL/SQL
Q4. CASE Expressions
Ans. 1. 2. There are two types of expressions used in CASE statements: Simple CASE Expression Searched CASE Expression Simple CASE Expression:a. In simple CASE expression, we create one or more alternative using WHEN clause. b. The CASE uses a Selector, that allow you to select a desired alternative and then result is return. c. If no match are found, then the ELSE clause is performed. d. If ELSE clause is not provided then expression returns null. e. E.g. ; WHEN Clause and Selector(grade) with a CASE Statement
3.
Searched CASE Expression:a. In searched CASE expression different conditions is tested, instead of comparing a single expression to various values. b. A searched CASE expression has no selector. c. Each WHEN clause contains a search condition that produces a BOOLEAN value. The BOOLEAN value of each search condition determines which WHEN clause is executed. d. If a search condition is; TRUE; its WHEN clause is executed. Executed WHEN clause search conditions are not evaluated. NOT TRUE; ELSE clause is executed. e. If ELSE clause is not used, then expression return NULL f. E.g. Using a Search Condition with a CASE Statement
g.
I.
d.
e. f. g. h. i. j. k.
A NUMBER variable can also represent 0. Oracle recommends using NUMBER literals and results of NUMBER computations That is within the specified range. Otherwise, the following happen: too small value become zero. too large literal value causes a compilation error. too large computation result that is undefined, cause unreliable results and run-time errors. A NUMBER value has both ; precision (total number of digits at left) scale (the number of digits to the right of the decimal point). Both precision and scale must be integer literals, not constants or variables. For precision, the maximum value is 38. The default value is 39 or 40. For scale, the minimum and maximum values are -84 and 127 respectively. The Default value is zero. The syntax for specifying a fixed-point NUMBER is: NUMBER (precision, scale) E.g.; NUMBER (8, 2) The syntax for specifying an integer NUMBER is: NUMBER(precision) E.g.; NUMBER (2) The syntax for specifying a floating-point NUMBER is: NUMBER Number Data Type In Short;
Fundamental of PL/SQL
II.