1.

What are Transactions in PL/SQL?

Answer»

The LIKE operator is a comparison operator in PL/SQL through which compares a character, string, or CLOB value to a pattern. The operator RETURNS TRUE if the value matches the pattern and FALSE if it does not.

For an example, we will take a procedure here and check for values:

DECLARE PROCEDURE compare (myvalue  varchar2, pattern varchar2 ) is BEGIN   IF myvalue LIKE pattern THEN      dbms_output.put_line ('True');   ELSE      dbms_output.put_line ('False');   END IF; END;   BEGIN   compare('John', 'J%n');   compare('Jack', 'Ja_k');   compare('Amit', 'Am%');   compare('Sac', 'Sac_'); END; /

The OUTPUT displays the following:

True True True False Statement processed. 0.00 seconds

Above we have used the following wildcards:

%
It allows to MATCH any string of any length
_
It allows to match only a single character

For example, above we used J%n for “John”, the output was true, since the % wildcard matches any string of any length.



Discussion

No Comment Found