Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    10

    Unanswered: Db2 Stored Procedure

    I am trying to do an insert in the below table in DB2 and am getting an error while inserting the value 9 || SUBSTR (V_BRANCH_NO,2,2), in the BA_BATCH_NO, field. The field BA_BATCH_NO and BA_BRANCH_NO has been defined as an INTEGER type. The value of BA_BRANCH_NO is 456

    All I need to do is ADD 9 which is an integer to the last 2 digits of branch number.

    Hence the result would be 956

    INSERT INTO SIEBEL.STG_PAYMNET_OUTBOUND (
    BA_BANK_NO,
    BA_BRANCH_NO,
    BA_BATCH_NO
    BA_BATCH_DATE)
    VALUES
    (V_BANK_NO
    V_BRANCH_NO
    9 || SUBSTR (V_BRANCH_NO,2,2),
    V_DATE);

    I would not like to declare the BA_BATCH_NO and BA_BRANCH_NO as char as I would SET their values to 0 later on so I will have to declare them as integer

    I guess the way I am doing the substring of integer field is wrong
    Any comments

    Regards

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

    Re: Db2 Stored Procedure

    INT('9'||SUBSTR(CHAR(BA_BATCH_NO),2,2)) will do the trick

    Sathyaram


    Originally posted by gsinha
    I am trying to do an insert in the below table in DB2 and am getting an error while inserting the value 9 || SUBSTR (V_BRANCH_NO,2,2), in the BA_BATCH_NO, field. The field BA_BATCH_NO and BA_BRANCH_NO has been defined as an INTEGER type. The value of BA_BRANCH_NO is 456

    All I need to do is ADD 9 which is an integer to the last 2 digits of branch number.

    Hence the result would be 956

    INSERT INTO SIEBEL.STG_PAYMNET_OUTBOUND (
    BA_BANK_NO,
    BA_BRANCH_NO,
    BA_BATCH_NO
    BA_BATCH_DATE)
    VALUES
    (V_BANK_NO
    V_BRANCH_NO
    9 || SUBSTR (V_BRANCH_NO,2,2),
    V_DATE);

    I would not like to declare the BA_BATCH_NO and BA_BRANCH_NO as char as I would SET their values to 0 later on so I will have to declare them as integer

    I guess the way I am doing the substring of integer field is wrong
    Any comments

    Regards
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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