PL/SQL DataType: Block to differenciate between CHAR and VARCHAR2 datatype
PL/SQL DataType: Exercise-3 with Solution
Write a PL/SQL block to differenciate between CHAR and VARCHAR2 datatype.
SET SERVEROUTPUT ON; DECLARE f_name CHAR(15 CHAR); l_name VARCHAR2(15 CHAR); BEGIN f_name := 'Allen '; l_name := 'Munra '; DBMS_OUTPUT.PUT_LINE('*' || f_name || '*'); DBMS_OUTPUT.PUT_LINE('*' || l_name || '*'); END; /
*Allen * *Munra *
The both type of variable CHAR and VARCHAR2 have maximum 15 characters long. Both variable have been assigned by a 5 characters long text and trailling by two blank spaces. The value assigned to CHAR variable is padded by 8 blank spaces and two blank spaces was in original data. But the value assigned in VARCHAR2 variable have no changed, it was printed with its two blank spaces which was originally.
Improve this sample solution and post your code through Disqus
Previous: Write a PL/SQL block to insert data to a table using character type variable.
Next: Write a PL/SQL procedure to accepts a BOOLEAN parameter and uses a CASE statement to print Unknown if the value of the parameter is NULL, Yes if it is TRUE, and No if it is FALSE.
What is the difficulty level of this exercise?
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework