2nd Example - Data Type Conversion on PL/SQL

In the second example will be demonstrated changes in the value of one data type into another data type (data type conversion). 5 pieces variables which are var1 date, var2 varchar2, varchar2 var3, var4 number, var5 date. Var1 contains the current date (sysdate). Var2 will convert var1 and store the converted date that had become varchar2, var3 will convert the date into varchar (different format). Var4 will change Var3 results into numbers. Var5 will convert varchar to date in var2.

 Var1 DATE;
 Var2 VARCHAR2(16);
 Var3 VARCHAR2(16);
 Var5 DATE;
 Var1 := SYSDATE;
 Var2 := TO_CHAR(Var1, 'YYYY/MM');
 Var3 := TO_CHAR(Var1, 'YYYY');
 Var4 := TO_NUMBER(Var3);
 Var5 := TO_DATE(Var2, 'YYYY-MM');

No comments

Powered by Blogger.