Results 1 to 2 of 2

Thread: VARCHAR to INT

  1. #1
    Join Date
    Feb 2002
    Location
    Hamilton
    Posts
    150

    Unanswered: VARCHAR to INT

    I have a column called batch_cycle which is defined as VARCHAR but its contents are all numerics. It is the date in modified julian format. What I am trying to do is to export out a select number of rows based on the batch cycle but I keep running into the operand is not valid for the column type. So I tried to CAST it to an INT but I run into the same issues

    Here is the query stripped out of the script

    db2 "export to $dir/tps_liability_info_import.ixf of ixf messages msgs_$Datetime.txt select * from $schema.$table where CAST(batch_cycle as INT) > ('$julian'-'40')" >> $output

    This query works

    db2 "export to $dir/tps_liability_info_import.ixf of ixf messages msgs_$Datetime.txt select * from $schema.$table where batch_cycle >='13310
    00'" >> $output

    But I need to turn the julian date into a variable that I can just choose to keep x number of iterations of the rows that were created for the amount of batch cycles I want to keep.

  2. #2
    Join Date
    Feb 2002
    Location
    Hamilton
    Posts
    150
    I got it to work. I just created another variable for the julian-40 called date_value

    db2 "export to $dir/tps_liability_info_import.ixf of ixf messages msgs_$Datetime.txt select * from $schema.$table where CAST(batch_cycle as INTEGER) > $date_value" >> $output

Posting Permissions

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