472,353 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

upload excel file

1
i have excel files with 2500 members with s/n,regno,firstnane,secondname and last name,and in database i have corresponds members with the same regno but i have a,b,c as the names,so i want code so that i upload files to the corresponding regno on database
Apr 2 '22 #1
2 18063
zmbd
5,501 Expert Mod 4TB
A contact of mine uses DB2 and suggested the following (I know nothing anymore about how DB2 runs)
>You may need administrative access and there are other prerequisites that need to be installed on your local instance

+ First option:
Link to the Excel workbook
Connecting Excel to IBM Db2 Warehouse
(copied from their website incase it goes down)
In the web console, go to the Run SQL page.
Type one or more SELECT statements in the editor text box.
Click one of the Run options.
Click Excel ODC File.
Download and open the BLUExcel.odc file in Excel.
If a security notice is displayed, click Enable.
Click Open to connect to the Db2 Warehouse database. The Connect To DB2 Database dialog box opens.
Type the user ID and password that you use to log in to Db2 Warehouse. To obtain the user ID and password, click Connect in the web console or Connect > Connection Information in the web console.
Ensure that the connection mode is Share, and then click OK.
Results

+Second option:
+ Use "Save As" to convert the excel file to CSV format.
+ Add temporary table to the DB2 schema set to hold the import, strongly advises AGAINST direct import to a production table - bad things can and do happen to existing datasets when appending from an outside source.
+ Follow the instructions as given at the IBM-DB2 support page (click here)
(Copied and pasted below incase their site is down... )
How to import data from a DB2 database table (from a CSV file)
How To

Summary
Customer would like to import data into a Controller DB2 database table, from a CSV (flat file) source.

How can they do this?

Objective
Import all the data from a single CSV file, into a specific DB2 database table.

Example:
The source CSV file may have come from a different database (see separate IBM Technote #0741797 for more details).

Environment
This Technote is based on:
Controller 10.3.1
DB2 10.5 & DB2 11
However, it may work for other versions/combinations.

Steps
There are many different ways to import data into a DB2 database. This Technote suggests using a DB2 command similar to: db2 IMPORT FROM "C:\UTILS\export.csv" OF DEL INSERT INTO <table_owner>.<tablename>

NOTE: It is possible to use the similar DB2 command 'load' (instead of 'import').
However, the author does not recommend this because it can lead to the DB2 database becoming stuck in 'backup pending' status (after a failed load).

Steps:
1. Logon to the DB2 database server
2. Launch: DB2 Command Window - Administrator
3. Run a command similar to: db2 connect to <database_name>
4. OPTIONAL: If you want to clear the existing contents of the target table (before importing the new data), then run a command similar to: db2 DB2 truncate table <table_owner>.<tablename>
5. Import the data by runing a command similar to: db2 IMPORT FROM "C:\UTILS\export.csv" OF DEL INSERT INTO <table_owner>.<tablename>
Example:
db2 IMPORT FROM "C:\UTILS\export.csv" OF DEL INSERT INTO fastnet.xacq_conv
6. Check with IBM Support if the database table is designed in a way that requires an extra script to be run now.
Example:
If importing into 'xacq_conv' then you will need to run the following extra scripts:
DB2 SELECT MAX(ino) from FASTNET.XACQ_CONV

This will give a result for example 100000. Therefore use this number plus one (for example 1000001) in the next command:
Expand|Select|Wrap|Line Numbers
  1. DB2 ALTER TABLE FASTNET.XACQ_CONV ALTER COLUMN INO RESTART WITH 100001 SET INCREMENT BY 1 SET MINVALUE 1 SET MAXVALUE 2147483647 SET NO CYCLE SET CACHE 500 SET NO ORDER
(image-20190627232428-1 - on the ibm site shows the command line interface - didn't import due to possible copyright)

Additional Information
Backup Pending
To check if your database is backup pending, type the following:
Expand|Select|Wrap|Line Numbers
  1. db2 connect to <database>
  2. db2 get database configuration
Look for the section similar to:Backup pending = NO

If your database has backup pending = YES then you can easily solve that by backing up the database.
TIP: The quickest type of backup is 'backup to NULL'. This causes a 'fake' backup to take place.

The command (for a 'backup to null' varies depending on what operating system your DB2 server is running:
Windows: db2 backup db <database> ONLINE to NUL
Unix/Linux: db2 backup db <database> ONLINE to /dev/null
The above create online backups. If you want an offline backup, simply remove the word 'online'.
Apr 15 '22 #2
Willjoe
12 Byte
On the Setup tab, under Integration Setup, select Excel Interface.
From Excel Interface, and then Upload from Excel, in File, enter the name of the Excel file to upload.
Click Upload.
Optional: To open the downloaded Excel file, next to the File name field, click Select.

Regards,
Will
Jul 20 '22 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: powerranger | last post by:
I wrote an asp.net application where I can upload an Excel file to the server and get the data from it to display on my datagrid. The program...
1
by: vic pahilan | last post by:
hi, pls need help. I need to upload excel field to sql server field. the user will choose excel file then i will show the fields inside that excel...
3
by: c676228 | last post by:
Hi everyone, I will develop a program to enroll a group of people on-line. Since we don't have number limitation for the people in the group. I am...
0
by: minhtran | last post by:
Hi all Please, I am a new ASP.NET, I upload an Excel File in the database, but I have an error as "Invalid Signature" . Please, anyone has a...
0
by: minhtran | last post by:
Hi all I have a problem when I upload the Excel file 2007 (file.xlsx) via ASP.NET (VB.NET, C#), but it has no problem to upload the Excel file 2003...
5
by: priyammaheshwari | last post by:
Hi all, I have a MS Access database in which requests made by people is stored,but a coulmn for cost is left empty which is suppose to be...
0
by: NareshN | last post by:
Hi All, I have this tables.I want to upload excel file data to multiple tables. Excel file consist of EmpName,1 week dates with...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.