Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trimming a column

Status
Not open for further replies.

wgechter

MIS
Jul 24, 2002
85
US
I am querying our database on a table, patient, desc:

pat_last_name char(20)
pat_first_name char(20)
pat_ext_id char(11)

My query:
set colsep '|'
select pat_ext_id, pat_last_name, Pat_first_name
from patient
where pat_ext_id = '69910.0';

My output:
pat_ext_id|pat_last_name |pat_first_name |
69910.0 |Gechter |Wendi |

I would like my output to trim off the spaces at the end. Output to look like:
69910.0|Gechter|Wendi|

I am using Oracle 8i and SQL Plus. I have tried using trim and it doesn't work. I have also tried rtrim and ltrim. Unless I am using it wrong, it is not working. Are there any other suggestions? Thanks, Wendi
 
As well, this is also what I get when running the following queries. Like I said earlier, tried rtrim, doesn't work. Thanks,

SQL> set colsep '|'
SQL> set heading off
SQL> select trim(both '' from pat_ext_id), pat_last_name, Pat_first_name
2 from mrpa99
3 where pat_ext_id = '69910.0';

|GECHTER |WENDI

SQL>
SQL> set colsep '|'
SQL> set heading off
SQL> select trim(trailing '' from pat_ext_id), pat_last_name, Pat_first_name
2 from mrpa99
3 where pat_ext_id = '69910.0';

|GECHTER |WENDI
 
What if just
select rtrim(pat_ext_id)||'|'||pat_last_name)||'|'||Pat_first_name
 
Thank you very much!! That worked. Here is the exact query:

select rtrim(pat_ext_id)||'|'||rtrim(pat_last_name)||'|'||rtrim(Pat_first_name) from mrpa99 where pat_ext_id = '69910.0';

69910.0|GECHTER|WENDI

Thanks again!! Wendi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top