Home » SQL & PL/SQL » SQL & PL/SQL » Space in the path!
Space in the path! [message #32086] Mon, 02 August 2004 04:19 Go to next message
Milly
Messages: 72
Registered: March 2004
Member
Hi All!!

I have a problem when in my file.sql used for the spool there'e a space in the path....

How can I solve this problem?

Thanks!
Re: Space in the path! [message #32097 is a reply to message #32086] Mon, 02 August 2004 21:21 Go to previous messageGo to next message
Jai Vrat Singh
Messages: 205
Registered: September 2002
Location: Singapore
Senior Member
Even mine does not work. Whatever method i try , it gives error for space in file name.
As a workaround you can use

#!/bin/ksh

sqlplus user@dbsid/password > 'my file with space' <b><<STR
</b>

select sysdate from dual;

STR



I think it can work if we can change the SQLPLUS settings, rendering some other character as a separator. eg if we can set ~ as separator. Then we can issue the command as

SQL> spool~my file
SQL>
SQL> spool~off


So that ~ is now the separator and space (' ') is taken literally. Experts! is there any means to achieve this?
Re: Space in the path! [message #32098 is a reply to message #32086] Mon, 02 August 2004 21:38 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Problem Description 
------------------- 
On Windows it is not possible to spool files with space in the file name or 
spool files on directories with space in their names though the OS allows such 
names. 
When you try to spool to a directory with a space in it's name it gives: 
SQL>spool c:program filestest.lst 
SP2-0333: Illegal spool file name: "c:program filestest.lst" (bad character: ' ') 
When you try to spool a file with a space in it's name again it gives the same 
error: 
SQL>spool c:temptest emp.lst 
SP2-0333: Illegal spool file name: "c:temptest emp.lst" (bad character: ' ') 
This cannot be done even by using quotes around the file names. 

Solution Description 
-------------------- 
The following can be used as a workaround for this: 
If you want to spool a filename with space on a directory with a space in it's 
name then Spool it to some other directory (c:temp) and then move it to the 
required directory with the host command. 
spool c:temptest.lst 
select * from emp; 
spool off 
host move "c:temptest.lst" "c:program filestest emp.lst" 
If you want to spool a file on a directory with a space in it's name then 
specify a virtual drive for that directory through DOS prompt and then spool 
it to that drive. 
From the DOS prompt: 
subst g: "c:program files" 
and from SQL*Plus: 
spool g:test.lst 
select * from emp; 
spool off 
For removing the virtual directory mapping, from DOS prompt you can use: 
subst g: /d 

Explanation 
----------- 
This restriction is imposed by SQL*Plus because previously, SPOOL files would 
be created by mistake if the following commands were issued. 
SQL> spool out ; => Created spooling file OUT.LIS 
SQL> spool off ; => Created spooling file OFF.LIS 
These commands will now return: 
SQL> spool off ; 
Illegal spool file name: "off " (bad character: ' ') 
SQL> spool out ; 
Illegal spool file name: "out " (bad character: ' ') 
The provided solution works around this restriction by using the OS features 
which allow such names. 
HTh,
MHE
Re: Space in the path! [message #32099 is a reply to message #32097] Tue, 03 August 2004 00:32 Go to previous message
Jai Vrat Singh
Messages: 205
Registered: September 2002
Location: Singapore
Senior Member
This site has some problem with HTML tags. It has bug for if i put unix here cocument then it does not show the staring tag. I am trying to correct here.

#!/bin/ksh

sqlplus user@dbsid/password > 'my file with space' <<<b>STR</b>

select sysdate from dual;

STR

Previous Topic: calling a procedure from a table ,using EXECUTE IMMEDIATE
Next Topic: ask question
Goto Forum:
  


Current Time: Thu Apr 18 02:15:34 CDT 2024