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

Home
Oracle PL / SQL
1.Aggregate Functions
2.Analytical Functions
3.Char Functions
4.Constraints
5.Conversion Functions
6.Cursor
7.Data Type
8.Date Timezone
9.Hierarchical Query
10.Index
11.Insert Delete Update
12.Large Objects
13.Numeric Math Functions
14.Object Oriented Database
15.PL SQL
16.Regular Expressions
17.Report Column Page
18.Result Set
19.Select Query
20.Sequence
21.SQL Plus
22.Stored Procedure Function
23.Subquery
24.System Packages
25.System Tables Views
26.Table
27.Table Joins
28.Trigger
29.User Previliege
30.View
31.XML
Oracle PL / SQL » Char Functions » SUBSTR 
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 VARCHARIS 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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.