Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> How to pass run time value to spool a file....URGENT

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: How to pass run time value to spool a file....URGENT
 prasad  Posted: Jun 12, 2008 06:08:03 AM

 Total Post: 35
 Joined: Jan, 2007






 Hello friends,

I want to spool a file from SQL.....& while spoolong the file I want to pass a value from SQL statement to that file name.

If it was normal spool file....then proper naming convention Or spoolong a file from Windows could have been a good solution.

I want to spool a file with passing a value to file name at run time.

I am spoolong a file every week...so I want to append the date to the file name. e.g: xyz20080506.lst
When I will spool file in the mext week the name would be xyz20080512.lst.

So I want to fetch the date from a table through SQL query & want to append that date to file name.

Can you help me out plz....?

 Geetha
Posted: Jun 12, 2008 07:52:04 AM  

 Total Post: 21
 Joined: Mar, 2008






 
Hi Prasad,
You can pass a value to at run time to spool a file. You can give like,

SPOOL $1

inside the file replacing,

SPOOL <<filename>>

While executing, give the run time value (i.e., the file name to create) along with the file name for execution.

Here, while execution the input value passed along with the file name will be created as a file in the name of the input value given by you in the run time.

Hope this'll help you out...

Let me know in case of any issues.

Regards,
Geetha



 prasad
Posted: Jun 12, 2008 08:39:52 AM  

 Total Post: 35
 Joined: Jan, 2007






 
Thanks Geetha for replying.

I guess....the solution which you have given is for entering filename(parameter) manually.

But I do not want any manual work.

My SQL script is like this:

spool /dataproj/nyucc_sb/test.lst

insert into nyucc_sb
(select fileno from ny000ucc90
where fileno like '2008%' and substr(fileno,1,8) < (select filedate + 1 from curfiledate where appl='UCC' and stcode='NY' and dbflag = 'UD')
minus
(
select fileno from ny000ucc01
where fileno like '2008%' and filedate < 'select filedate + 1 from curfiledate where appl=''UCC'' and stcode=''NY'' and dbflag = ''UD'''
union
select ucc3num from ny000ucc04
where ucc3num like '2008%' and ucc3filedate < 'select filedate + 1 from curfiledate where appl=''UCC'' and stcode=''NY'' and dbflag = ''UD'''));

spool off

Here I am generating test.lst as a spool file.

I want to append result of following query to append the spool file name.
SELECT FILEDATE FROM DUAL;

So ultimately my spool file name should be xyz + "filedate".lst

So everytime I run my SQL script, it should fetch fildate from SQL query & it should append to spool file name.

Hope I have explained in details. Still if you are not getting plz let me know.

Thanks in advance

 Gitesh
Posted: Jun 12, 2008 11:05:49 PM  

 Total Post: 322
 Joined: May, 2005






 
first login in database.

after that execute following.

col fname new_value filename

select 'D:\report\rep\report_' || to_char(trunc(sysdate),'DDMMYY') || '.txt' fname from dual;

spool &filename

Your spool file name contains report_sysdate




 prasad
Posted: Jun 13, 2008 03:00:16 AM  

 Total Post: 35
 Joined: Jan, 2007






 
Thanks Gitesh.

Thank you very much for the help. :)

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Gopu Gopi334
  Gitesh Trivedi322
  Vinoth Kumar264
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software