DBAsupport.com Forums - Powered by vBulletin
Results 1 to 9 of 9

Thread: Diffrence between & && in spool file name

  1. #1
    Join Date
    Jul 2001
    Posts
    334

    Diffrence between & && in spool file name

    Hi All,
    What is the difference between & and && in sql*plus spool file

    e.g
    &myfile.txt
    &&myfile.txt

    Thanks

  2. #2
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    is it @ or &?


    @ pathname Run an SQL Script (see START)
    @MyScript.sql parameter1 parameter2 parameter3
    In the SQL-Script, refer to the parameters as &1, &2, and &3.

    @@ pathname Run a nested SQL Script.

    / Execute (or re-execute) commands in the SQL*Plus buffer
    does not list commands before running
    Cheers!
    OraKid.

  3. #3
    Join Date
    Jul 2001
    Posts
    334
    Hello balajiyes,
    I think I have cleared mentioned spool 'file name'

    let's say you spooling output into a spool file and you wana datestamp before the file name like below example.

    column col1 new_value myfile noprint
    select to_char(sysdate,'YYYYMMDD') col1 from dual;
    spool c:\&myfile.txt OR spool c:\&&myfile.txt
    .
    .
    spool off

    Now the question is what is the difference between & and && in sql*plus spool file, see below
    spool c:\&myfile.txt;
    and
    spool c:\&&myfile.txt;

    Thanks in advance.

  4. #4
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    I don't find any change
    Cheers!
    OraKid.

  5. #5
    Join Date
    Jul 2001
    Posts
    334
    Hi,
    The problem am facing is according to the below example

    column col1 new_value myfile noprint
    select to_char(sysdate,'YYYYMMDD') col1 from dual;
    ---------------------------
    (If I use single &, then I get on my c:\ file name as &myfile.txt)
    spool c:\&myfile.txt
    .
    .
    spool off
    ---------------------------

    ---------------------------
    (If I use double &&, then I get on my c:\ file name as &20031230.txt)
    spool c:\&&myfile.txt
    .
    .
    spool off
    ---------------------------
    I don't know what part I am missing, what I should perform in order to get the the proper file name like 20031230.txt


    Thanks.

  6. #6
    Join Date
    Apr 2003
    Location
    South Carolina
    Posts
    148
    This is a cut from one of the scripts that I have written and
    it gives me the results you are looking for...

    column DAY_NAME new_value file_day noprint
    select trunc(SYSDATE) DAY_NAME FROM DUAL;
    spool c:\File_&&whichday..txt

    HTH
    Gregg

  7. #7
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    It looks to me as if the \ is acting as an "escape" character, preventing the following & being interpreted as the "define" character. What happens if you do a "set escape off" first?

    You can use the escape character before the substitution character (set through SET DEFINE) to indicate that SQL*Plus should treat the substitution character as an ordinary character rather than as a request for variable substitution.
    I don't fully follow Gregg's example - but it avoids the problem because the & does not follow the \.

  8. #8
    Join Date
    Jul 2001
    Posts
    334
    Hello Dapi,
    Excellent!!! it works with SET ESCAPE OFF.

    Thanks for your help to resolve this issue.

  9. #9
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    && stores the variable in sqlplus session, & does not

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width