tailieunhanh - Oracle Built−in Packages- P93

Oracle Built−in Packages- P93: Ah, for the good old days of Version of PL /SQL! Life was so simple then. No stored procedures or functions and certainly no packages. You had your set of built−in functions, like SUBSTR and TO_DATE. You had the IF statement and various kinds of loops. With these tools at hand, you built your batch−processing scripts for execution in SQL*Plus, and you coded your triggers in SQL*Forms , and you went home at night content with a good day's work done. | Appendix A What s on the Companion Disk r2 Raw string to XOR with r1 Restrictions This program asserts the following purity level with the RESTRICT_REFERENCES pragma PRAGMA RESTRICT_REFERENCES BIT_XOR WNDS RNDS WNPS RNPS Example To toggle a bit if it is off turn it on and if it is on turn it off in a bit flag variable using a bitmask use the BIT_XOR function as follows DECLARE fourteenth VARCHAR2 8 fifteenth VARCHAR2 8 twentieth VARCHAR2 8 mask RAW 4 bitfield1 VARCHAR2 8 bitfield2 VARCHAR2 8 BEGIN set the bitfield for the 15th through 18th bitfieldl 0003C000 set the bitfield for the 26st bitfield2 02000000 set the mask for the 14th fourteenth 00002000 set the mask for the 15th fifteenth 00004000 set the mask for the 20th twentieth 00080000 merge the masks for the 14th 15th and 20th mask HEXTORAW fourteenth HEXTORAW fifteenth mask mask HEXTORAW twentieth check to see IF the bitfields have the 14th or 20th set IF mask HEXTORAW bitfield1 00000000 THEN bitfield1 is not set ELSE bitfield1 is set END IF IF mask HEXTORAW bitfield2 00000000 THEN bitfield2 is not set ELSE bitfield2 is set END IF toggle bit 15 in the mask mask mask HEXTORAW fifteenth check to see IF the bitfield1 has the 14th 15th or 20th set IF mask HEXTORAW bitfield1 00000000 THEN bitfield1 is not set ELSE bitfield1 is set END IF END This is the output from the previous example bitfieldl is set bitfield2 is not set bitfieldl is not set The UTL_RAW Interface 451 Appendix A What s on the Companion Disk The function The CAST_TO_RAW function converts the VARCHAR2 input string into a raw datatype. The data is not altered only the data type is changed. This is essentially a VARCHAR2_to_RAW function FUNCTION c IN VARCHAR2 .