1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Here document

Discussion in 'Support' started by Allnightlong, Jan 22, 2014.

  1. Allnightlong

    Joined:
    Jan 22, 2014
    Messages:
    2
    Likes Received:
    0
    Hi, just started using TC 16.0. Having problems with "Here Documents"

    File ppp.bat works:

    @ECHO OFF
    SETLOCAL ENABLEDELAYEDEXPANSION

    sqlplus -L -S system/dwed7g << endtext
    select name from v$database;
    exit;
    endtext

    File zzz.bat does not work:

    @ECHO OFF
    SETLOCAL ENABLEDELAYEDEXPANSION
    SET ORACLE_BASE=G:\OPT\ORACLE
    SET ORACLE_HOME=%ORACLE_BASE%\PRODUCT\112030
    FOR /F %%A IN ('net start ^| findstr OracleService ^| sort') DO (
    SET PIET=%%A
    SET ORACLE_SID=%PIET:~13,10%
    ECHO.
    ECHO %ORACLE_SID%
    sqlplus system/password@%ORACLE_SID% << endtext
    select username from dba_users;
    exit;
    endtext
    )

    Errors received:

    PD4A
    TCC: (Sys) C:\Temp\for_active_services.bat [19] De parameter is onjuist.
    "C:\Users\ITCHAL~1\AppData\Local\Temp\Ein88E2.tmp"
    TDB11203
    TCC: (Sys) C:\Temp\for_active_services.bat [19] De parameter is onjuist.
    "C:\Users\ITCHAL~1\AppData\Local\Temp\Ein8902.tmp"

    Can somebody please advice?

    Thanks

    Peter
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,288
    Likes Received:
    39
    I have no idea what that's supposed to do, but I do notice that you're posting a file named zzz.bat, while the error message refers to a file named "C:\Temp\for_active_services.bat". Maybe you should look at that file instead, particularly around line 19.
     
  3. Allnightlong

    Joined:
    Jan 22, 2014
    Messages:
    2
    Likes Received:
    0
    Hi, the name of the scripts is not important. I want to retrieve all services names called OracleService and then
    cut character 13-23 from that name (this will retrieve a Oracle SID e.g. PD4A and this
    will be placed in the variable ORACLE_SID).

    For All these I want to execute an Oracle sqlplus process with a select statement.
    This generates an error

    Any ideas?

    Thanks

    Peter Jansen
     
  4. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,188
    Likes Received:
    11
    You are combining a single line statement (FOR) with a multi-line statement (here-document) and that will only confuse the parser.

    try this instead:
    Code:
    do PIET in /p (net start | ffind /kmv /t"OracleService")
     SET ORACLE_SID=%@substr[%PIET,13,10]
     ECHO.
     ECHO %ORACLE_SID
     sqlplus system/password@%ORACLE_SID <<<  select username from dba_users; exit;
    enddo
    
    Note that the above will not work in CMD or TCC/LE. It will only work in TCC.
     

Share This Page