Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2002
    Location
    Omaha, NE
    Posts
    25

    Question Unanswered: INSERT Script Syntax Error

    I am unsure if this is the correct forum, or if this should go to UNIX, but we'll find out.

    We have a UNIX shell script that performs an insert to DB2 and has the following line of code in it...

    ACNTTMP=`db2 "select count(*) from $TABNAME"`

    $TABNAME is set higher in the script. When I try to run the script, I receive the following error message...

    load.insert.profit.cmt[141]: 0403-057 Syntax error at line 695 : `(' is not expected.

    where load.insert.profit.cmt is the executable wrapper script I'm running, [141] is the line of the wrapper script the call to the shell script is, and line 695 is where the code above is located in the shell script.

    If this would be better suited in the UNIX thread, let me know so I can move it.

    Thanks in advance for any assistance.

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: INSERT Script Syntax Error

    I'm not sure why the error is ...

    If I were you, I'd do your statement as follows (remember, I'm not a shell scripting guru)

    db2 -x "select count(*) from $TABNAME" | read ACNTTMP

    Originally posted by djschmitt
    I am unsure if this is the correct forum, or if this should go to UNIX, but we'll find out.

    We have a UNIX shell script that performs an insert to DB2 and has the following line of code in it...

    ACNTTMP=`db2 "select count(*) from $TABNAME"`

    $TABNAME is set higher in the script. When I try to run the script, I receive the following error message...

    load.insert.profit.cmt[141]: 0403-057 Syntax error at line 695 : `(' is not expected.

    where load.insert.profit.cmt is the executable wrapper script I'm running, [141] is the line of the wrapper script the call to the shell script is, and line 695 is where the code above is located in the shell script.

    If this would be better suited in the UNIX thread, let me know so I can move it.

    Thanks in advance for any assistance.

  3. #3
    Join Date
    Nov 2002
    Location
    Omaha, NE
    Posts
    25
    To be honest, I do not know why we are coding that way either. I am new to this position - my first with UNIX or DB2 - and am learning a great deal.

    Now this is starting to look more like a UNIX scripting problem than DB2.

    The code you provided worked nicely, however, I am receiving the same message on the following line of code...

    ACNT=`echo $ACNTTMP | awk '{print $3}'`

    which does not include a (

    A little background: These scripts were working fine before I started formatting them and adding comments to make them easier to read - I know, if it isn't broke, don't fix it. My formatting included indenting if/then statements. I know that I have to have an EOF at the first position of a line. Any other rules I need to know of?

  4. #4
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    If the script is already in Prod, probably my previous comment is not useful ....

    Maybe running your script using
    ksh -x <scriptname>
    might provide more information to debug ...

    Good luck

    Cheers

    Sathyaram

    Originally posted by djschmitt
    To be honest, I do not know why we are coding that way either. I am new to this position - my first with UNIX or DB2 - and am learning a great deal.

    Now this is starting to look more like a UNIX scripting problem than DB2.

    The code you provided worked nicely, however, I am receiving the same message on the following line of code...

    ACNT=`echo $ACNTTMP | awk '{print $3}'`

    which does not include a (

    A little background: These scripts were working fine before I started formatting them and adding comments to make them easier to read - I know, if it isn't broke, don't fix it. My formatting included indenting if/then statements. I know that I have to have an EOF at the first position of a line. Any other rules I need to know of?

  5. #5
    Join Date
    Nov 2002
    Location
    Omaha, NE
    Posts
    25
    Scarry...I was changing some code un-related to the error message and it went away. Now I have a different Syntax Error, but that will go on the UNIX side if I can't figure it out.

    Thanks for all your help.

  6. #6
    Join Date
    Nov 2002
    Posts
    9

    Dos edit

    Originally posted by djschmitt
    Scarry...I was changing some code un-related to the error message and it went away. Now I have a different Syntax Error, but that will go on the UNIX side if I can't figure it out.

    Thanks for all your help.
    Are you editing this files via a dos/windows editor? If so, you may have Cr/Lf problems. Verify that you don't have embedded lf somehwere.

  7. #7
    Join Date
    Nov 2002
    Location
    Omaha, NE
    Posts
    25

    Re: Dos edit

    Originally posted by mmainguy
    Are you editing this files via a dos/windows editor? If so, you may have Cr/Lf problems. Verify that you don't have embedded lf somehwere.
    Yes, I am editing with a windows editor then using FTP to send the updated files to UNIX. What is a Cr/Lf problem?

  8. #8
    Join Date
    Nov 2002
    Posts
    9

    sorry carriage return linefeed

    Make sure when you ftp you're using ascii mode. DOS text files have 2 characters at the end of the line a carriage return (0x0a) and a linefeed (0x0d) whereas unix generally only has a newline (0x0d). If you ftp'd the file and used a binary transfer instead of ascii, you'll end up with very strange errors.

    You may be able to easily fix it by either:
    #1 resending in ascii mode
    #2 running dtox (dos to unix conversion) on the file

    To switch to ascii mode, type asc before doing the put in the ftp.

Posting Permissions

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