if v_name1 = v_name2 then dbms_output.put_line('Both the words are same'); else dbms_output.put_line('Both the words are different'); end if; end;
The output is Both the words are different.
if rtrim(v_name1) = v_name2 then
if you use rtrim for char data it will diplay the message two words are same.
This is because Char is a fixed length datatype and values are padded with blank spaces to match specified length. Varchar2 is variable length datatype.
ans is both values are not equal char(20)='name' covered in memorey areea is 20 but varchar2(20)='name' covered in memorey areea is 4 becoze char is fixed lenth char data type but varchar2 is variable lenth char data type
Spaces will be padded with y variable,its means y will store y='sudhir ' . while x only store 6 six character so both string will not be equal
create or replace procedure test2 as x varchar(20):='sudhir'; y char(20):='sudhir'; begin if(x=y) then dbms_output.put_line('both are equal'); else dbms_output.put_line('both are not equal'); end if; end;
Yes but small difference
if we use char (20) it will padd the blank space
where as varchar 2(20) it will not padd blank space..
chinnu
Jan 27th, 2015
char datatype is fixed,but it cant be reused. eq: char(10) -- elena,first 5 characters will be filled remaining field are padded.
varchar2 datatype fixed,but it can be reused. eq: varchar2(10) -- elena, first 5 characters will be filled and remaining fields are reused.
Char(20) = 'name' varchar2(20)='name' When comparing these two values, are the spaces padded in char are considered or not? Are both values equal?