How do you import a spreadsheet into DB2? - eclipse

I have a CSV file, but this could apply to any txt, data, or xls file. (xlsx) I have exported the data from one source and I want to import the data into a DB2 table.
I first tried Data Tools Plugin (DTP) in eclipse Helios (3.6.3) by right clicking on the table and selecting: Data > Load...
But I got this error:
Loading "myschema"."mytable"... com.ibm.db2.jcc.am.SqlException:
[jcc][10103][10941][4.14.113] Method executeQuery cannot be used for
update. ERRORCODE=-4476, SQLSTATE=null Data loading failed.
Then I tried Eclipse SQL Explorer on Eclipse Juno, but it does not support data import.
How do I get past this error so I can import?

You can import a CSV file directly into DB2 via the IMPORT or LOAD command, even with XML or BLOB as part of the data to import.
The procedure to import depends on the structure of the file you are going to import. Probably you should modify the default behaviour of these commands; DB2 has many option to adapt the command to the input file.
For more information about:
The import command: http://publib.boulder.ibm.com/infocenter/db2luw/v10r1/topic/com.ibm.db2.luw.admin.cmd.doc/doc/r0008304.html
The Load command http://publib.boulder.ibm.com/infocenter/db2luw/v10r1/topic/com.ibm.db2.luw.admin.cmd.doc/doc/r0008305.html
I think your question was more oriented to: how to use Eclipse to import data in DB2 from a CSV file. However, as I said, you can do that directly via DB2.
If you are going to import a file like the next one, the only thing that you need is to have access to a db2 client.
data.txt
1,"Andres","2013-05-18"
2,"Tom","2011-04-16"
3,"Jessica","2002-03-09"
You import with
db2 import from data.txt of del insert into test

I solved this by installing Eclipse Juno (4.2) and Data Tools Plugin (DTP) 1.10.2.
Now Data > Load... will work fine. This is the new message I get:
Data loading was successful. 142 row(s) loaded. 135 row(s) could not
be loaded.
com.ibm.db2.jcc.am.go: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502,
SQLERRMC= , DRIVER=4.7.85 One or more values could not be set in the
following column(s): USER_TIME, USER_DATE
FYI for the entire process I was using this:
DB2 driver: /opt/IBM/db2/V9.7/java
With jar files: db2jcc4.jar, db2jcc_license_cisuz.jar
Driver Class: com.ibm.db2.jcc.DB2Driver

You can import using DB2 "Control Center" *
Right Click the table and select "Import"
Then specify the csv file and message file
message file is important because in the case of failed upload, you can find the error cause in the message file
* Control Center is now deprecated in favor of "Data Studio"

From the db2 console, try this:
Import from 'yourcommaseparatedfile.csv' of del insert into "SCHEMA"."TABLE"
Regards =)

db2 'import from /users/n0sdsds/test.csv of del insert into ENTPRISE.tmp_x'

Related

Datastage Oracle Importing Table

I have a error when i use datastage connect to Oracle and import the table definition. Below is the detailed situation.
enviroment:
OS:AIX6.1,64bit,power6 processor, LANG=en_US
Data Stage Version:8.5
Installation profile
three tiers install on same machine, repository use DB2 (default).
Oracle Client 11.2 (64bit) also install on this machine, I can use SQLPLUS connect to Oracle server (11.2, 64bit, AL32UTF8) on another machine.
"dsenv" setting
add "/oracle/product/11.2.0-64/lib" to the "LIBPATH"
add "export TNS_ADMIN=/oracle/product/11.2.0-64/network/admin"
Problem
1. I use Oracle Connector(parallel) create a Link, then use this Link import Metadata, when i press Test connection, there is a dialog with "The OCI function OraOCIEnvNlsCreate:OCI_UTF16ID returned status -1. Error code: NULL, Error message: NULL" popup, and the connection failed.
I use Oracle Enterprise(parallel) create a Link, then use it import Metadata, when i click Ellipsis button list all the tables in target database, there is a dialog with "cannot get list of table names from database" popup, after I click OK on this dialog, the detail error message popup.
12:37:21(002) Unable to access database oracleLibrary orchoracle could not be loaded; Could not load "orchoracle": 
0509-022 Cannot load module /opt/IBM/InformationServer/Server/DSComponents/bin/orchoracle.o.
0509-150 Dependent module /opt/IBM/InformationServer/Server/DSComponents/bin/libclntsh.so could not be loaded.
0509-103 The module has an invalid magic number.
0509-022 Cannot load module /opt/IBM/InformationServer/Server/DSComponents/bin/orchoracle.o.
0509-150 Dependent module /opt/IBM/InformationServer/Server/DSComponents/bin/orchoracle.o could not be loaded.
from the message I found the DS search some files in DSCompoments/bin, but these files are in the oracle bin directory. I can't find the error in dsenv file, so i copied these files into DSComponents/bin, this time the error message changed to "OCI_ERROR: Bad Oracle environment".
I am not sure which enviroment variable I missed, please tell me.
I use Oracle OCI(Server) create a Link and import a table, it works fine.
So, my question is why I can't use the Oracle Connector and Oracle Enterprise to connect the Oracle. Thanks.
Yes the PATH variable needs to be set to $ORACLE_HOME/bin. Adding this variable to the dsenv file and recycling all services fixed the Oracle COnnector issue for us. It is required to be added to the dsenv file and recycling ASBNode and datastage is also required. Here are the directives needed in the dsenv file to use Oracle Connector :(eg is from our system AIX 6.1 , datastage 8.5 connecting to Oracle 11g Enterprise)
We also added the following :
TNS_ADMIN=/opt/oracle/product/11.1.0/client_1/network/admin; export TNS_ADMIN

How to COPY local file to remote database

I have remote postgresql database and a local csv file which I need to add to the database. I'm trying to do it with PyCharm.
Thus, I'm trying to copy data from a local file to a remote database.
If the database local is, then this command works:
COPY master_relationsextra(code, serial_number, member_type, characteristic, price_list)
FROM '/Users/name/Desktop/AUTOI.csv' with CSV HEADER delimiter ';' encoding 'ISO-8859-1';
But for the remote database it doesn't working.
Any advice how can I do that?
I'm using PyCharm thus I did with PyCharm's help. All queries and commands did PyCharm for me. I did it as follows:
I connected to the remote database from PyCharm database pane
Right click on table and then import from file
Choose all rules and import
That did the trick for me.

Transaction log full with import from CSV to DB2

I'm trying to upload a CSV file to DB2 with the following command:
db2 import from MY_FILE.csv of del insert into TEST.TABLE
The file contains more that 2 millions rows. I got transaction log is full when I try to upload it.
Is there a way to upload it without getting this error ?
Yup. :)
You can use the COMMITCOUNT AUTOMATIC option for IMPORT. With that option IMPORT will determine when your transaction logs will be full and automatically commit the data. That way transaction logs are "cleared" and DB2 is ready for the next chunk of data.

DB2 10.1 table data copy to IBM VSE 7.4 table

We have one application where we have db2 10.1 as database.
Now one requirement came in which we need to interface few tables to HOST which is on IBM DB2 VSE 7.4
I tried to execute load command with client option but it give "SQL1325N The remote database environment does not support the command or one
of the command options." error.
command is :"D:\tempdata>db2 load client from app.tbl of ixf
insert into host.tbl"
Many post says that its not allow to use load from 10.1 to VSE Z/OS.
Another option I tried is import but its too slow and we need to delete records every time as truncate is not available.
Replication can be think for option but we would like to avoid replication.
Can anyone suggest way to achieve this. Load can be use or not?
It seems its not allow to use load from remote machine. But wondering what is use of CLIENT option in load then.
Finally we decided to use import utility after deleting HOST DB2 records. In that we need to execute delete and import command on part of table. If we try to import or delete big table at one go it give error of log file size full.
Hope this will help.

return null from select in oracle sql developer

I'm using oracle database 12c in windows x64.
I imported an oracle database(from a .dmp file). The detail information view from oracle sql developer shows:
NUM_ROWS:74524900; BLOCKS:1356877; AVG_ROW_LEN:126; SAMPLE_SIZE:2000
However, when I try to run sql commands:
select * from <table_name> where rownum<=10;
or select * from <table_name>;
I got nothing returned. And the status show the retrieved number of rows: 0 ("提取的所有行:0").
I also try to run these commands in cmd, and failed again. The returned information is "No row is selected" (未选定行).
Please help. Thx!
Thanks nop77svk. This is because I failed to import the table. A close look at the import log file show that the table failed to pass 8192 extension (oracle error 1653). A drawback of 42679603 lines occurred.
I guess I may need to import the table one by one. And turn on the autoextend option of the tablespaces.
Thanks anyway.