You Can Use Parentheses to Override the Default Order of Operations.
Expressions
An expression is an arbitrarily complex combination of variables, constants, literals, operators, and function calls. The simplest expression is a unmarried variable.
The PL/SQL compiler determines the datatype of an expression from the types of the variables, constants, literals, and operators that contain the expression. Every time the expression is evaluated, a single value of that type results. For more information, encounter "PL/SQL Expressions and Comparisons".
Syntax
Description of the analogy expression.gif
Keyword and Parameter Description
Betwixt
This comparison operator tests whether a value lies in a specified range. It means "greater than or equal to low value and less than or equal to loftier value."
boolean_constant_name
A constant of type BOOLEAN
, which must be initialized to the value True
, Imitation
, or NULL
. Arithmetic operations on Boolean constants are not allowed.
boolean_expression
An expression that returns the Boolean value TRUE
, FALSE
, or NULL
.
boolean_function_call
Whatever function call that returns a Boolean value.
boolean_literal
The predefined values TRUE
, FALSE
, or NULL
(which stands for a missing, unknown, or inapplicable value). Y'all cannot insert the value TRUE
or FALSE
into a database column.
boolean_variable_name
A variable of type BOOLEAN
. Only the values True
, Fake
, and NULL
can be assigned to a BOOLEAN
variable. You cannot select or fetch column values into a BOOLEAN
variable. Also, arithmetic operations on BOOLEAN
variables are not allowed.
%BULK_ROWCOUNT
Designed for utilize with the FORALL
statement, this is a composite attribute of the implicit cursor SQL
. For more information, see "SQL Cursor".
character_constant_name
A previously alleged constant that stores a character value. It must exist initialized to a graphic symbol value or a value implicitly convertible to a grapheme value.
character_expression
An expression that returns a graphic symbol or character string.
character_function_call
A function call that returns a character value or a value implicitly convertible to a character value.
character_literal
A literal that represents a character value or a value implicitly convertible to a grapheme value.
character_variable_name
A previously declared variable that stores a character value.
collection_name
A collection (nested table, index-by tabular array, or varray) previously declared within the current telescopic.
cursor_name
An explicit cursor previously declared within the current scope.
cursor_variable_name
A PL/SQL cursor variable previously alleged within the current scope.
date_constant_name
A previously declared constant that stores a date value. It must be initialized to a date value or a value implicitly convertible to a date value.
date_expression
An expression that returns a appointment/time value.
date_function_call
A function phone call that returns a date value or a value implicitly convertible to a date value.
date_literal
A literal representing a appointment value or a value implicitly convertible to a date value.
date_variable_name
A previously declared variable that stores a date value.
EXISTS, COUNT, FIRST, LAST, LIMIT, Adjacent, PRIOR
Collection methods. When appended to the proper noun of a drove, these methods render useful information. For example, EXISTS(north)
returns True
if the n
th chemical element of a collection exists. Otherwise, EXISTS(n)
returns Faux
. For more than information, encounter "Collection Methods".
exponent
An expression that must return a numeric value.
%Plant, %ISOPEN, %NOTFOUND, %ROWCOUNT
Cursor attributes. When appended to the proper name of a cursor or cursor variable, these attributes return useful data about the execution of a multi-row query. You can besides append them to the implicit cursor SQL
.
host_cursor_variable_name
A cursor variable declared in a PL/SQL host environs and passed to PL/SQL as a bind variable. Host cursor variables must exist prefixed with a colon.
host_variable_name
A variable declared in a PL/SQL host environs and passed to PL/SQL as a bind variable. The datatype of the host variable must be implicitly convertible to the appropriate PL/SQL datatype. Also, host variables must be prefixed with a colon.
IN
Comparing operator that tests prepare membership. It means "equal to any member of." The set can contain nulls, only they are ignored. Also, expressions of the form
value NOT IN set
return Fake
if the ready contains a nada.
alphabetize
A numeric expression that must return a value of blazon BINARY_INTEGER
or a value implicitly convertible to that datatype.
indicator_name
An indicator variable declared in a PL/SQL host environment and passed to PL/SQL. Indicator variables must be prefixed with a colon. An indicator variable "indicates" the value or condition of its associated host variable. For example, in the Oracle Precompiler surroundings, indicator variables tin can detect nulls or truncated values in output host variables.
IS NULL
Comparison operator that returns the Boolean value True
if its operand is aught, or FALSE
if its operand is not null.
Like
Comparing operator that compares a character value to a design. Case is significant. Similar
returns the Boolean value TRUE
if the character patterns match, or Faux
if they do not match.
Not, AND, OR
Logical operators, which follow the tri-state logic of Table 2-2. AND
returns the value Truthful
but if both its operands are truthful. OR
returns the value Truthful
if either of its operands is truthful. Non
returns the reverse value (logical negation) of its operand. For more than data, meet "Logical Operators".
Cipher
Keyword that represents a zilch. Information technology stands for a missing, unknown, or extraneous value. When NULL
is used in a numeric or date expression, the result is a null.
numeric_constant_name
A previously alleged constant that stores a numeric value. It must exist initialized to a numeric value or a value implicitly convertible to a numeric value.
numeric_expression
An expression that returns an integer or real value.
numeric_function_call
A function call that returns a numeric value or a value implicitly convertible to a numeric value.
numeric_literal
A literal that represents a number or a value implicitly convertible to a number.
numeric_variable_name
A previously declared variable that stores a numeric value.
design
A graphic symbol string compared by the LIKE
operator to a specified string value. It tin can include two special-purpose characters chosen wildcards. An underscore (_) matches exactly one character; a percent sign (%) matches zero or more than characters. The pattern tin can be followed by ESCAPE '
character_literal
'
, which turns off wildcard expansion wherever the escape graphic symbol appears in the string followed by a percent sign or underscore.
relational_operator
Operator that compares expressions. For the meaning of each operator, run into "Comparison Operators".
SQL
A cursor opened implicitly by Oracle to process a SQL data manipulation statement. The implicit cursor SQL
always refers to the most recently executed SQL statement.
+, -, /, *, **
Symbols for the addition, subtraction, division, multiplication, and exponentiation operators.
||
The chain operator. Equally the post-obit example shows, the outcome of concatenating string1 with string2 is a grapheme string that contains string1 followed past string2:
'Good' || ' morning time!' = 'Good morning!'
The next instance shows that nulls accept no issue on the result of a concatenation:
'suit' || Zippo || 'case' = 'suitcase'
A null string (''
), which is zero characters in length, is treated similar a null.
Usage Notes
In a Boolean expression, you tin only compare values that have uniform datatypes. For more information, come across "Converting PL/SQL Datatypes".
In conditional control statements, if a Boolean expression returns True
, its associated sequence of statements is executed. Just, if the expression returns Simulated
or NULL
, its associated sequence of statements is not executed.
The relational operators tin be applied to operands of type BOOLEAN
. By definition, True
is greater than FALSE
. Comparisons involving nulls e'er render a zip. The value of a Boolean expression tin be assigned only to Boolean variables, not to host variables or database columns. Also, datatype conversion to or from type BOOLEAN
is not supported.
You tin can employ the addition and subtraction operators to increment or decrement a date value, as the post-obit examples show:
hire_date := '10-MAY-95'; hire_date := hire_date + 1; -- makes hire_date '11-MAY-95' hire_date := hire_date - five; -- makes hire_date '06-MAY-95'
When PL/SQL evaluates a boolean expression, Non
has the highest precedence, AND
has the next-highest precedence, and OR
has the lowest precedence. Notwithstanding, you tin can utilize parentheses to override the default operator precedence.
Within an expression, operations occur in their predefined social club of precedence. From start to last (summit to bottom), the default order of operations is
- parentheses
- exponents
- unary operators
- multiplication and division
- addition, subtraction, and concatenation
PL/SQL evaluates operators of equal precedence in no particular club. When parentheses enclose an expression that is part of a larger expression, PL/SQL evaluates the parenthesized expression showtime, and so uses the outcome in the larger expression. When parenthesized expressions are nested, PL/SQL evaluates the innermost expression showtime and the outermost expression last.
Examples
Several examples of expressions follow:
(a + b) > c -- Boolean expression NOT finished -- Boolean expression TO_CHAR(acct_no) -- character expression 'Fat ' || 'cats' -- character expression 'xv-November-95' -- date expression MONTHS_BETWEEN(d1, d2) -- date expression pi * r**2 -- numeric expression emp_cv%ROWCOUNT -- numeric expression
Related Topics
Assignment Statement, Constants and Variables, EXIT Statement, IF Statement, LOOP Statements
Source: https://docs.oracle.com/cd/B12037_01/appdev.101/b10807/13_elems019.htm
0 Response to "You Can Use Parentheses to Override the Default Order of Operations."
Post a Comment