If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Db2 Stored Procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-17-03, 17:10
gsinha gsinha is offline
Registered User
 
Join Date: Oct 2003
Posts: 10
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
Reply With Quote
  #2 (permalink)  
Old 12-17-03, 18:41
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: Db2 Stored Procedure

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

Sathyaram


Quote:
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On