use substr in IF statement : SUBSTR « Char Functions « Oracle PL / SQL






use substr in IF statement

  
SQL>
SQL>
SQL> DECLARE
  2     lv_training_code_txt VARCHAR2(10) := 'T_Code';
  3     lv_non_training_code_txt VARCHAR2(10) := 'TUSC';
  4     PROCEDURE training_class_check (p_class_check VARCHAR) IS p_class_check1 VARCHAR2(10) := p_class_check;
  5  BEGIN
  6        IF SUBSTR(p_class_check1,1,2) = 'T_' THEN
  7           p_class_check1 := 'T-' || SUBSTR(p_class_check1, 3);
  8        END IF;
  9        IF p_class_check1 LIKE 'T-%' THEN
 10           DBMS_OUTPUT.PUT_LINE(p_class_check ||' is a Training Class');
 11        ELSE
 12           DBMS_OUTPUT.PUT_LINE(p_class_check ||' is a Non-Training Class');
 13        END IF;
 14  END training_class_check;
 15
 16  BEGIN
 17     training_class_check(lv_training_code_txt);
 18     training_class_check(lv_non_training_code_txt);
 19  END;
 20  /

PL/SQL procedure successfully completed.

SQL>
SQL>

   
  








Related examples in the same category

1.SUBSTR() returns a portion of string, beginning at numeric_position up to a specified substring_length characters long.
2.Substr: retrieve a portion of the string
3.SUBSTR: get the sub-string
4.Simple demo for SUBSTR function
5.SUBSTR: from the right-hand side of original string
6.SUBSTR and INSTR are used together
7.select substr( '1234567890', 5 )
8.Use SUBSTR to decode a column
9.substr(date value,8)+16