AppWorx, Dollar Universe and Sysload Community

 View Only
Expand all | Collapse all

Dates captured in CL_IN to be used in "variables" section of UPROC

  • 1.  Dates captured in CL_IN to be used in "variables" section of UPROC

    Posted Jun 23, 2015 09:20 AM
    Good day,
    I have captured some dates in the CL_IN.  Now I would like to be able to use those variables in the “variables” section of the UPROC.  For some reason, the values doesn’t seem to transfer.  Did I do something wrong?
    Here is the content of my CL_IN:
    @ECHO OFF
     
    REM ==============================================================
     
    REM Internal Uproc sample script for Windows
     
    REM ==============================================================
     
    REM
     
    ECHO Starting...
     
    REM
     
    for /F %%a in ('%UXEXE%\uxdat yyyymm -1m') do (set PREV_REF_PERIOD=%%a)
    REM @PARAM <PREV_REF_PERIOD> TEXT <6> [<%PREV_REF_PERIOD%>]
     
    REM
     
    for /F %%b in ('%UXEXE%\uxdat yyyymm') do (set REFERENCE_PERIOD=%%b)
    REM @PARAM <REFERENCE_PERIOD> TEXT <6> [<%REFERENCE_PERIOD%>]
     
    REM
     
    Call "%UXDIR_ROOT%\Scripts\SQLCode\SQLCMDQueryO.bat"
     
    ECHO End.
     
     
     
    SET resexe=0
    And where I would like to use the variables (see picture)
     
    Help!!


  • 2.  Dates captured in CL_IN to be used in "variables" section of UPROC

    Posted Jun 23, 2015 09:29 AM
    63k7cl12g40u.jpg


  • 3.  Dates captured in CL_IN to be used in "variables" section of UPROC
    Best Answer

    Posted Jun 23, 2015 10:26 PM
    Hi,

    You can't directly use the script variables in your variable values. The reason is that the variable are initialized before the script is executed. It wouldn't take the value calculated in the script then.

    What I would do:
    • I use a special string in my variable value
    • I would then calculate the real value in the script
    • Then I would replace the special string with the value just calculated
    An example of value replacement (taken from http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-search-replace-substitute!OpenDocument&ExpandSection=3&BaseTarget=East&AutoFramed):
    setlocal enabledelayedexpansion
    set sqlcmd=sql _DATE_ param
    set find=_DATE_
    set replace=2015
    call set sqlcmd=%%sqlcmd:!find!=!replace!%%
    echo %sqlcmd%

    Note: I tried it and it seems that it doesn't work when executed directly in a command shell but it works when executed in a script

    Does it help?

    Regards,



  • 4.  Dates captured in CL_IN to be used in "variables" section of UPROC

    Posted Jun 26, 2015 09:17 AM
    Thank you so much for the tip...  it's working !