Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem on DB2 Update SQL in VB.Net

Status
Not open for further replies.

Rod41

Programmer
Sep 24, 2015
7
PH
1.) csvtest table
CREATE TABLE csvtest (intcode varCHAR(14), deptcode varchar(3), alphacode varchar(5))
sample record of csvtest :
intcode ----- deptcode ----- alphacode
12021907-------13----------- "DSP"
11992564-------14----------- "ALP"
11803570-------15----------- "TOS"

2.) itemtest table
CREATE TABLE itemTest (intcode CHAR(14), alpha_code varchar(3))
sample record of itemtest :
intcode-------------------- alpha_code
00001202190713 ------------ ASL
00001199256408 ------------ ALS
00001180357015 ------------ DSP

the composition of intcode 00001202190713 is
Code- skucode - deptcode
0000- 12021907 - 13

I want to replace all alpha_code of itemtest table with the alphacode of csvtest table.
skucode and deptcode should match with intcode and deptcode of csvtest table..

Here is my sample code. Can anyone help me please... thank you


Imports IBM.Data.DB2
Imports System.IO
Imports System.IO.File
Imports IBM.Data.DB2.DB2BulkCopy

Dim con As New DB2Connection(GlobalVariables.masterconnection)

Dim COM As String = "Update all itemTEST b set b.alpha_code = (select a.alphacode from csvtest a where substr(b.intcode,4,8)=a.intcode)"

Dim Adpt As New DB2DataAdapter(com, con)



 

What is the problem, exactly? Are you getting any error messages?

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Actually there is no error on my sample code, it only replaces the Alpha_Code of ITEMTEST table with a blank.. I need to replace the Alpha_code field in ITEMTEST table with the right Alphacode in CSVTEST Table.

My exact problem, what is the complete set of SQL Update command to replace the Alpha_code of ITEMTEST table?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top