COMPARE routine - Returns result of COMPARE of two input values
The COMPARE routine runs a COMPARE operation of the values in input1 against input2.
Syntax
Parameters
- input1
- An input argument of type VARBINARY(256) that specifies the FIRST value to be compared
- input2
- An input argument of type VARBINARY(256) that specifies the SECOND value to be compared
- pad
- An input argument of type VARBINARY(256) that right pads the shorter of two unequal length values, having a default value of bx’00’.
Authorization
EXECUTE privilege on the UTL_RAW module.
Examples
Example 1: The following example shows how to set up a table with a VARBINARY data
type:
db2 "create table sample(input1 VARBINARY(20) not null, input2 VARBINARY(20) not null)"
DB20000I The SQL command completed successfully.
Example 2: The following example shows how to insert data into a table that has a
VARBINARY data
type:
db2 "insert into sample(input1, input2) values (bx'3131',bx'32323232')"
DB20000I The SQL command completed successfully.
db2 "insert into sample(input1, input2) values (bx'3333',bx'34343434')"
DB20000I The SQL command completed successfully.
Example 3: The following example shows how to run a COMPARE
operation:
db2 "select sysibmadm.utl_raw.compare(input1,input2, default) from sample"
1
-----------
1
1
2 record(s) selected.