Query problem [message #71135] |
Thu, 12 September 2002 22:08 |
sha
Messages: 84 Registered: July 2002
|
Member |
|
|
Hi,
How can I trim the column size based on the data I entered in the column?
e.g.
name varchar2(100)
but I enter only 5 letter names
like
raj,ram etc
when I say select name from table;
it is displaying as
name
---------------------------------------------
raj
it is occupying 100 spaces and when I select another field it is displaying in the next line.
like select name,job from table;
name
-------------
job
-----------
raj
clerk
name
--------------
job
---------------
ram
accountant
in this way it is displaying
help me
thanx in advance
|
|
|
Re: Query problem [message #71137 is a reply to message #71135] |
Fri, 13 September 2002 00:03 |
Phoenix
Messages: 2 Registered: January 2002
|
Junior Member |
|
|
Hi there,
What you describe is normal SQL behaviour (select will always take column length and not the data in the column). I do not know of any way to format the output dependend on the data, but you can set the column size in sql. Try this:
col name format a20
Now execute your statement again.
If you want to select more than one column, you might want to consider a script. Something like:
col emp_id format 99 --> for numeric columns
col emp_name format a10 --> for alfanumeric columns
select emp_id
, emp_name
from employees
Hope this helps.
|
|
|
|