4. Elements of QUEL Statements : Operations : Assignment
 
Share this page                  
Assignment
An assignment operation is an operation which places a value in a column or variable. Assignment operations occur during the execution of append, replace, and retrieve statements.
When an assignment operation occurs, the data types of the assigned value and the receiving column or variable must either be the same or comparable. If they are not the same, the DBMS Server performs a default type conversion if the data types are comparable. If they are not comparable, you must convert the assignment value into a type which is the same or comparable with the receiving column or variable. For information about the type conversion functions, see Data Type Conversion Functions.
All character string types (char, varchar, c, and text) are comparable with one another. Dates are comparable with string types if the format of the value in the string corresponds to a valid date input format. For information about valid date input formats, see Absolute Date Input Formats.
All numeric types are comparable with one another. Money is comparable with all of the numeric and string types. For example, assuming that the following table is created:
create emp 
(name=char(20),
 salary=money not null,
 hiredate=date not null);
this append statement
append to emp (name="John Smith", salary=40000, 
hiredate="10/12/93")
assigns the varchar string literal, "John Smith", to the char column "name", the i4 literal 40000 to the money column "salary", and the varchar string literal "10/12/93" to the date column "hiredate".
The following assignment replaces an existing value in a table:
replace emp (name = "Mary Smith")
where name = "Mary Jones"
In the following embedded QUEL example, the value in the "name" column is assigned to the variable "name_var" for each row that fulfills the where clause.
retrieve (:name_var=emp.name)
where empno = 125
The following sections present guidelines for assigning values (including nulls) to each of the general data types. If you are assigning to a host language variable, see the Embedded QUEL Companion Guide for information about which host language data types are comparable with QUEL data types.