Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2003
    Posts
    65

    Question Unanswered: Can you send variables to sybase at the command line

    I was wondering if you can pass in a variable to sybase at the command line like so:

    Code:
    isql -u .. -p .. -s somedb sybasQuery.sql <variable here> ...
    and the sybaseQuery.sql contains a query like so:
    Code:
    select *
    from some_table
    where source_cde = %1
    can this be done ?

    Thanks for the help in advance.

  2. #2
    Join Date
    Feb 2004
    Posts
    28

    Re: Can you send variables to sybase at the command line

    This can be easily done in Unix platform using shell scripting. Which platform are you planning to run your script ?



    Originally posted by llccoo
    I was wondering if you can pass in a variable to sybase at the command line like so:

    Code:
    isql -u .. -p .. -s somedb sybasQuery.sql <variable here> ...
    and the sybaseQuery.sql contains a query like so:
    Code:
    select *
    from some_table
    where source_cde = %1
    can this be done ?

    Thanks for the help in advance.

  3. #3
    Join Date
    Nov 2003
    Posts
    65
    hi thanks for the reply.

    Well im using w2k at the moment. I write batch files in dos to execute a isql to get data

    load to oracle
    sqlplus to process it

    email reports.

    well i have liek 8 little sybasequeries with just one parameter in the where clause different. so i wanted to just write one and pass in a variable.

  4. #4
    Join Date
    Nov 2003
    Posts
    65

    Re: Can you send variables to sybase at the command line

    i have been looking around for awhile now doesn't seem that you can pass in a variable on the command line.

    any ideas on how i might be able to achieve this through a batch process in DOS. Be nice if i was using a UNIX platform but at the moment i'm using W2K.


    Originally posted by jv59
    This can be easily done in Unix platform using shell scripting. Which platform are you planning to run your script ?

  5. #5
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524

    Re: Can you send variables to sybase at the command line

    On Win, build your SQL file using echo and variables, then execute it using isql -i

  6. #6
    Join Date
    Nov 2003
    Posts
    65

    Re: Can you send variables to sybase at the command line

    Nice idea, can you show me some examples? Thanks.


    Originally posted by fadace
    On Win, build your SQL file using echo and variables, then execute it using isql -i

  7. #7
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    Make something like dump_db.bat (see attachment)

    Which is called by dump_batch.bat:
    rem @echo off
    goto INIT
    REM -------------------------------------------------------
    REM INIT
    REM -------------------------------------------------------
    :INIT
    call d:\sybase_beheer\ini\setenv.bat
    REM
    REM Local settings
    REM
    REM
    REM Checks
    REM
    REM
    REM Parameters
    REM
    REM
    REM Cleanup old logfile dumps
    REM
    if exist %SYB_DB_DUMPS_LOG% del %SYB_DB_DUMPS_LOG%
    REM
    REM -------------------------------------------------------
    REM EXEC_SCRIPT
    REM -------------------------------------------------------
    :EXEC_SCRIPT
    call %SYB_ONDERHOUD%\dump_db.bat master
    call %SYB_ONDERHOUD%\dump_db.bat sybsystemprocs
    call %SYB_ONDERHOUD%\dump_db.bat <insert onther databases here>
    call %SYB_ONDERHOUD%\dump_db.bat <insert onther databases here>
    call %SYB_ONDERHOUD%\dump_db.bat <insert onther databases here>
    call %SYB_ONDERHOUD%\dump_db.bat <insert onther databases here>

    goto END

    REM -------------------------------------------------------
    REM END
    REM -------------------------------------------------------
    :END



    (Don't pay attention to the strange %environmentvariable%-names..they're dutch .
    Attached Files Attached Files

  8. #8
    Join Date
    Nov 2003
    Posts
    65
    thanks for the starting point ... i will try to write one up.
    And ill let ya know how it turns out!

  9. #9
    Join Date
    Nov 2003
    Posts
    65
    THis worked great! Thanks for the example it helped alot. Now i can generate all my 6 sybase scripts off the one bat file with just 2-3 variables passed in.

    Know any other nice tricks for sybase =)

    Originally posted by Martijnvs
    Make something like dump_db.bat (see attachment)

    Which is called by dump_batch.bat:
    rem @echo off
    goto INIT
    REM -------------------------------------------------------
    REM INIT
    REM -------------------------------------------------------
    :INIT
    call d:\sybase_beheer\ini\setenv.bat
    REM
    REM Local settings
    REM
    REM
    REM Checks
    REM
    REM
    REM Parameters
    REM
    REM
    REM Cleanup old logfile dumps
    REM
    if exist %SYB_DB_DUMPS_LOG% del %SYB_DB_DUMPS_LOG%
    REM
    REM -------------------------------------------------------
    REM EXEC_SCRIPT
    REM -------------------------------------------------------
    :EXEC_SCRIPT
    call %SYB_ONDERHOUD%\dump_db.bat master
    call %SYB_ONDERHOUD%\dump_db.bat sybsystemprocs
    call %SYB_ONDERHOUD%\dump_db.bat <insert onther databases here>
    call %SYB_ONDERHOUD%\dump_db.bat <insert onther databases here>
    call %SYB_ONDERHOUD%\dump_db.bat <insert onther databases here>
    call %SYB_ONDERHOUD%\dump_db.bat <insert onther databases here>

    goto END

    REM -------------------------------------------------------
    REM END
    REM -------------------------------------------------------
    :END



    (Don't pay attention to the strange %environmentvariable%-names..they're dutch .

  10. #10
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    You're welcome .
    Glad I could help.
    I don't have more tricks at the moment, but I'll keep you in mind when I come across some..

Posting Permissions

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