Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old April 28th, 2008, 06:03 AM
keithmck keithmck is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 5 keithmck Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 28 m
Reputation Power: 0
Generate a .txt file

This is my first time on the forum so a big hello to everyone!!

Firstly I am very noive user of sql to say the least, but i have be requested to create a .txt file

Its for a program that will read the txt file i create to produce a letter i.e I will be extracting, TITLE, FORENAME, SURNAME etc

MR
JOE
BLOGGS

Here is the my code so far, like i said i am a very novice user so try to help me and not condem me for my lack of knowledge!

SELECT
LPA_INPUT.INPUT_TITLE,
LPA_INPUT.INPUT_SURNAME,
LPA_HISTORY.LPA_AMT,
LPA_HISTORY.ELIG_RATE,
LPA_HISTORY.RATE_REBATE,
LPA_HISTORY.RR_AMT,
LPA_HISTORY.LPA_APPLIC,
LPA_HISTORY.LPA_AMT
FROM LPA_HISTORY, LPA_INPUT
WHERE LPA_HISTORY.CLAIM_NO = LPA_INPUT.CLAIM_NO
----------------------------------------------------
Iv been asked to have these eight fields looping over and over for all the records in the database, So im not sure how to do that and how to generate it in a txt file?! I have to produce it in a script and not by a Export/Import wizard in sql server mangement studio!!! Please help

Keith

Reply With Quote
  #2  
Old April 28th, 2008, 06:24 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,620 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 4 Days 3 h 39 m 45 sec
Reputation Power: 259
Note that this is the mysql forum, are you on this database or on Microsoft's SQLServer (aka MsSQL)?

Reply With Quote
  #3  
Old April 28th, 2008, 06:27 AM
keithmck keithmck is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 5 keithmck Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 28 m
Reputation Power: 0
Hey!!! yea was unsure where to post!!!

Its an oracle database, so no MsSQL!

Reply With Quote
  #4  
Old April 28th, 2008, 06:30 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,620 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 4 Days 3 h 39 m 45 sec
Reputation Power: 259
Then this question should be in the oracle forum, I've asked a mod to move this thread there

Reply With Quote
  #5  
Old April 28th, 2008, 06:31 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,620 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 4 Days 3 h 39 m 45 sec
Reputation Power: 259
Here is a fully commented answer to your question.
Start by improving your Google skills ...

Reply With Quote
  #6  
Old April 28th, 2008, 06:47 AM
keithmck keithmck is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 5 keithmck Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 28 m
Reputation Power: 0
Start by improving your Google skills ??

No need to get smart, bell-end!! and if ur not sure what that is....google it!!!
Comments on this post
pabloj disagrees: Take it easy boy

Reply With Quote
  #7  
Old April 28th, 2008, 11:02 AM
vpire vpire is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 127 vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 4 h 9 m 32 sec
Reputation Power: 6
You either use plsql or any programming language you like to achieve that. Native sql can't unless you select your result into a temp table then export as csv or some sort.

Reply With Quote
  #8  
Old April 28th, 2008, 11:04 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,620 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 4 Days 3 h 39 m 45 sec
Reputation Power: 259
Quote:
Originally Posted by vpire
You either use plsql or any programming language you like to achieve that. ...
Not entirely true, check the link I posted

Reply With Quote
  #9  
Old April 28th, 2008, 11:12 AM
Ebot's Avatar
Ebot Ebot is offline
Meatball Surgeon
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Elbow deep in code
Posts: 1,136 Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 17180 Folding Title: Novice Folder
Time spent in forums: 1 Week 3 Days 20 h 42 m 58 sec
Reputation Power: 640
you could just capture the output with SQLPLUS. Just turn on the logger before you run the query.
__________________
The liver is evil and must be punished!

Reply With Quote
  #10  
Old April 29th, 2008, 06:09 AM
keithmck keithmck is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 5 keithmck Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 28 m
Reputation Power: 0
OK Heres how iv decide to go; Altering some code i stubbled across!!! But its not quite working yet


EXEC_file UTL_FILE.FILE_TYPE;

cursor read_lpa_input is
select l.input_title,
l.INPUT_SURNAME,
h.LPA_AMT,
h.ELIG_RATE,
h.RATE_REBATE,
h.RR_AMT,
h.LPA_APPLIC,
h.LPA_AMT

from lpa_input l, lpa_history h
WHERE l.CLAIM_NO = h.CLAIM_NO;


BEGIN

exec_file := UTL_FILE.FOPEN ('J:/','output.txt', 'W');

open read_lpa_input;

loop

fetch read_lpa_input into wk_input_surname, wk_history_lpa_amt,
wk_history_elig_rate,
wk_history_rate_rebate,
wk_history_rr_amt,
wk_history_lpa_applic,
wk_history_lpa_amt;

Exit when read_lpa_input%notfound;


UTL_FILE.PUT_LINE(exec_file, wk_input_title);
UTL_FILE.PUT_LINE(exec_file, wk_input_surname);
UTL_FILE.PUT_LINE(exec_file, wk_history_lpa_amt);
UTL_FILE.PUT_LINE(exec_file, wk_history_elig_rate);
UTL_FILE.PUT_LINE(exec_file, wk_history_rate_rebate);
UTL_FILE.PUT_LINE(exec_file, wk_history_rr_amt);
UTL_FILE.PUT_LINE(exec_file, wk_history_lpa_applic);
UTL_FILE.PUT_LINE(exec_file, wk_history_lpa_amt);

end loop;

ERROR:


SQL> lpa_notif1
SP2-0042: unknown command "lpa_notif1" - rest of line ignored.
SQL> @lpa_notif1
fetch read_lpa_input into wk_input_surname, wk_history_lpa_amt,
*
ERROR at line 41:
ORA-06550: line 41, column 3:
PLS-00394: wrong number of values in the INTO list of a FETCH statement
ORA-06550: line 41, column 3:
PL/SQL: SQL Statement ignored

close read_lpa_input;
UTL_FILE.FCLOSE(exec_file);
end;
/

Reply With Quote
  #11  
Old April 29th, 2008, 06:15 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,620 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 4 Days 3 h 39 m 45 sec
Reputation Power: 259
See what the error means here (7 versus 8)

Reply With Quote
  #12  
Old April 29th, 2008, 06:20 AM
keithmck keithmck is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 5 keithmck Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 28 m
Reputation Power: 0
EXCELLENT!! cool site!!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Generate a .txt file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |