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!

How to extract data using SQL PLus and having the data format in txt

Status
Not open for further replies.

cp4720

MIS
Sep 10, 2001
9
MY
Hi all,

I need help. I wanna to xtract some datas using SQL Plus with the data format looking like below:

Emp No | Emp Name | ......
0123 | ABC | .....

Thanks for the help.

 
CP,

Lacking more specifications from you, here is code that does what you seem to want:

set feedback off
set echo off
set linesize 2000
set trimspool on
set pagesize 0
select 'Emp No | Emp Name | ...' from dual
/
select rpad(id,7)||'| '||rpad(first_name,9)||'| ...' from s_emp;

Be sure to copy, paste, and save this code to a script file (example "EmpText.sql"), then from the SQL*Plus prompt, execute with "@EmpText".

Let us know if this is what you wanted.

Dave
Sandy, Utah, USA @ 17:45 GMT, 10:45 Mountain Time
 
Hi santa,

Thanks. Yes, this is what I want.

I have another question. As I am very new to SQL Plus, I would like to know from where can I refer to the explaination on the coding eg, set feedback off = ? , ....etc...


Thanks.
 
CP,

In my example, above, the first 5 statements (all beginning with the word "set") are Oracle-proprietary SQL*Plus commands (not SQL commands). A link to a SQL*Plus command Quick Reference is "csis.gvsu.edu/GeneralInfo/Oracle/server.920/a90842/ch13.htm". An explanation of each SQL*Plus command (including each of the 5 "set" commands, above) appears alphabetically at that link.

Let us know if you have more questions after referring to that link.

Dave
Sandy, Utah, USA @ 06:29 GMT, 23:29 Mountain Time

 
Hi all,

Thanks for the help. It helps me a lot.
Now I am thinking how to def system year like if the system date = 17Nov2003 or 17/11/2003, it will pick only the year for me, that is 2003, any clues on this?

Thanks in advance.
 
Look at TRUNC function. For your specific case TRUNC(SYSDATE, 'Y') returns only YEAR part of current date.
You may also use TO_CHAR to format date: TO_CHAR(sysdate, 'YYYY') returns character string '2003'

Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top