Home > database >  How will the excel in PB data imported into the SQL database?
How will the excel in PB data imported into the SQL database?

Time:09-28

I have now realized the data imported into a dw, and only two columns of data table can also be updated in the SQL database, but generally SQL database table has a lot of columns, I choose a table in the dw of certain columns or two tables a few columns, when such import SQL database error, consult everybody who is an example to reference the warrior?
Attach my import code:
Dw_1. Settransobject (sqlca)
String ls_null
SetNull (ls_null)
Dw_1. ImportFile (ls_null)
//this is to import CSV data table
Update code:
If dw_1. The update ()=1 then
commit;
Messagebox (" ", "OK")
The else
The rollback.
Messagebox (" ", "failure")
End the if
Dw_1. Settransobject (sqlca)
Dw_1. Retrieve ()

If you need a quick update, do you have a specific code? The younger brother is a novice,

CodePudding user response:

From the data window is used in circulation, put all the columns in each of the variables, then use the insert or update statement.
Roughly:
Assuming that two columns
String c1 and c2
Long I, j
For I=1 to dw_1. Rowcount ()
C1=dw_1. Getitemstring (I, "c1")
C1=dw_1. Getitemstring (I, "c2")
Select count (1) into: j from TB where c1=: c1
If j=1 then//assume that c1 primary key, that is, there is only one.
Update the set of TB c2=: c2 where c1=: c1
The else
Insert into TB (c1, c2) values (: c1, c2)
End the for
  • Related