Load into database from a file
hi,
i need to know is there any other means other than sql loader ,i import data into the oracle8i database from a file i.e)if i need to load into a server from a client machine
which does not have oracle 8i client version how could i
do it.kindly help out. thanks in advance.
UTL_FILE
With the UTL_FILE package, your PL/SQL programs can read and write operating system text files. UTL_FILE provides a restricted version of operating system stream file I/O.
UTL_FILE I/O capabilities are similar to standard operating system stream file I/O (OPEN, GET, PUT, CLOSE) capabilities, but with some limitations. For example, you call the FOPEN function to return a file handle, which you use in subsequent calls to GET_LINE or PUT to perform stream I/O to a file. When file I/O is done, you call FCLOSE to complete any output and free resources associated with the file.
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_file.htm#ARPLS069
Joel P�rez
Similar Messages
-
How can i load file into database from client-side to server-side
i want to upload file from client-side to server-side, i use the following code to load blob into database.
if the file is in the server-side, it can work, but if it in the client-side, it said that the system cannot find the file. i think it only will search the file is in the server-side or not, it will not search the client-side.
how can i solve it without upload the file to the server first, then load it into database??
try
ResultSet rset = null;
PreparedStatement pstmt =
conn.prepareStatement ("insert into docs values (? , EMPTY_BLOB())");
pstmt.setInt (1, docId);
pstmt.execute ();
// Open the destination blob:
pstmt.setInt (1, docId);
rset = pstmt.executeQuery (
"SELECT content FROM docs WHERE id = ? FOR UPDATE");
BLOB dest_lob = null;
if (rset.next()) {
dest_lob = ((OracleResultSet)rset).getBLOB (1);
// Declare a file handler for the input file
File binaryFile = new File (fileName);
FileInputStream istream = new FileInputStream (binaryFile);
// Create an OutputStram object to write the BLOB as a stream
OutputStream ostream = dest_lob.getBinaryOutputStream();
// Create a tempory buffer
byte[] buffer = new byte[1024];
int length = 0;
// Use the read() method to read the file to the byte
// array buffer, then use the write() method to write it to
// the BLOB.
while ((length = istream.read(buffer)) != -1)
ostream.write(buffer, 0, length);
pstmt.close();
// Close all streams and file handles:
istream.close();
ostream.flush();
ostream.close();
//dest_lob.close();
// Commit the transaction:
conn.commit();
conn.close();
} catch (SQLException e) {Hi,
Without some more details of the configuration, its difficult to know
what's happening here. For example, what do you mean by client side
and server side, and where are you running the upload Java application?
If you always run the application on the database server system, but can't
open the file on a different machine, then it sounds like a file protection
problem that isn't really connected with the database at all. That is to
say, if the new FileInputStream (binaryFile) statement fails, then its not
really a database problem, but a file protection issue. On the other hand,
I can't explain what's happening if you run the program on the same machine
as the document file (client machine), but you can't write the data to the
server, assuming the JDBC connection string is set correctly to connect to
the appropriate database server.
If you can provide some more information, we'll try to help.
Simon
null -
How to Load the data from excel file(Extension is .CSV) into the temp.table
Hi
How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
Kindly Suggest the Solution.
Regards,
SachinHello Sachin,
You can use the following metalink note:How to Read Data from an EXCEL Spreadsheet into a Form Using Webutil Client_OLE2 (Doc ID 813535.1) and modify it a little bit.
Instead of copy values into forms you can save them in your temporary table.
Kind regards,
Alex
If someone's helpful or correct please mark it accordingly. -
How to load the data from excel file into temprory table in Forms 11g?
Hi
How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
Kindly Suggest the Solution.
Regards,
SachinDeclare
v_full_filename varchar2(500);
v_server_path varchar2(2000);
v_separator VARCHAR2(1);
v_filename VARCHAR2(400);
filename VARCHAR2 (100);
v_stop_load varchar2 (2000);
v_rec_error_log varchar2(4000);
v_error_log varchar2(4000);
ctr NUMBER (12);
cols NUMBER (2);
btn number;
RES BOOLEAN;
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
cell ole2.obj_type;
cellType ole2.OBJ_TYPE;
args ole2.obj_type;
PROCEDURE olearg
IS
args ole2.obj_type;
BEGIN
args := ole2.create_arglist;
ole2.add_arg (args, ctr);
ole2.add_arg (args, cols);
cell := ole2.get_obj_property (worksheet, 'Cells', args);
ole2.destroy_arglist (args);
END;
BEGIN
v_full_filename := client_get_file_name(directory_name => null
,file_name => null
,file_filter => 'Excel files (*.xls)|*.xls|'
||'Excel files (*.xlsx)|*.xlsx|'
,message => 'Choose Excel file'
,dialog_type => null
,select_file => null
If v_full_filename is not null Then
v_separator := WEBUTIL_CLIENTINFO.Get_file_Separator ;
v_filename := v_separator||v_full_filename ;
:LOAD_FILE_NAME := substr(v_filename,instr(v_filename,v_separator,-1) + 1);
RES := Webutil_File_Transfer.Client_To_AS(v_full_filename,"server_path"||substr(v_filename,instr(v_filename,v_separator,-1) + 1));
--Begin load data from EXCEL
BEGIN
filename := v_server_path||substr(v_filename,instr(v_filename,v_separator,-1) + 1); -- to pick the file
application := ole2.create_obj ('Excel.Application');
ole2.set_property (application, 'Visible', 'false');
workbooks := ole2.get_obj_property (application, 'Workbooks');
args := ole2.create_arglist;
ole2.add_arg (args, filename); -- file path and name
workbook := ole2.get_obj_property(workbooks,'Open',args);
ole2.destroy_arglist (args);
args := ole2.create_arglist;
ole2.add_arg (args, 'Sheet1');
worksheet := ole2.get_obj_property (workbook, 'Worksheets', args);
ole2.destroy_arglist (args);
ctr := 2; --row number
cols := 1; -- column number
go_block('xxx');
FIRST_RECORD;
LOOP
--Column 1 VALUE --------------------------------------------------------------------
olearg;
v_stop_load := ole2.get_char_property (cell, 'Text'); --cell value of the argument
:item1 := v_stop_load;
cols := cols + 1;
--Column 2 VALUE --------------------------------------------------------------------
olearg;
:item2 := ole2.get_char_property (cell, 'Text'); --cell value of the argument
cols := cols + 1;
--<and so on>
ole2.invoke (application, 'Quit');
ole2.RELEASE_OBJ (cell);
ole2.RELEASE_OBJ (worksheet);
ole2.RELEASE_OBJ (worksheets);
ole2.RELEASE_OBJ (workbook);
ole2.RELEASE_OBJ (workbooks);
ole2.RELEASE_OBJ (application);
END;
--End load data from EXCELPlease mark it as answered if you helped. -
How to load the data from excel file into table in oracle using UTL_FI
How to load the data from excel file into table in oracle
and from table to excel file
using UTL_FILE package
Please give me some exampleThis is something i tried in oracle apex
http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
Regards,
CKLP -
How to load the data from .csv file to oracle table???
Hi,
I am using oracle 10g , plsql developer. Can anyone help me in how to load the data from .csv file to oracle table. The table is already created with the required columns. The .csv file is having about 10lakh records. Is it possible to load 10lakh records. can any one please tell me how to proceed.
Thanks in advance981145 wrote:
Can you tell more about sql * loader??? how to know that utility is available for me or not??? I am using oracle 10g database and plsql developer???SQL*Loader is part of the Oracle client. If you have a developer installation you should normally have it on your client.
the command is
sqlldrType it and see if you have it installed.
Have a look also at the FAQ link posted by Marwin.
There are plenty of examples also on the web.
Regards.
Al -
SQL Loader to Load Multiple Tables from Multiple Files
Hi
I wish to create a control file to load multiple tables from multiple files
viz.Emp.dat into emp table and Dept.dat into Dept table and so on
How could I do it?
Can I create a control file like this:
OPTIONS(DIRECT=TRUE,
SKIP_UNUSABLE_INDEXES=TRUE,
SKIP_INDEX_MAINTENANCE=TRUE)
UNRECOVERABLE
LOAD DATA
INFILE 'EMP.dat'
INFILE 'DEPT.dat'
INTO TABLE emp TRUNCATE
FIELDS TERMINATED BY "|" OPTIONALLY ENCLOSED BY '"'
(empno,
ename,
deptno)
INTO TABLE dept TRUNCATE
FIELDS TERMINATED BY "|" OPTIONALLY ENCLOSED BY '"'
(deptno,
dname,
dloc)
Appreciate a Quick Reply
mailto:[email protected]Which operating system? ("Command Prompt" sounds like Windows)
UNIX/Linux: a shell script with multiple calls to sqlldr run in the background with "&" (and possibly nohup)
Windows: A batch file using "start" to launch multiple copies of sqlldr.
http://www.pctools.com/forum/showthread.php?42285-background-a-process-in-batch-%28W2K%29
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx?mfr=true
Edited by: Brian Bontrager on May 31, 2013 4:04 PM -
SQL* Loader Loading specific column from CSV file to the table
Dear All,
Iam Loading specific column from .CSV file to the oracle table.
Could pls help how i can load only that cols into the table
Eg: CSV file having id, Frst_name,Last_name, Address,Phone,Insurance etc
out of this I want to load only Frst_name,Last_name columns to oracle table say fname and lname.
Thanks in Adv.
JunuLily,
I made some changes to your table def but you will get the idea
-- Table EMPLOYEE
CREATE TABLE EMPLOYEE
EMPID NUMBER NOT NULL,
EMPNICKNAME VARCHAR2(10 BYTE) NULL,
FNAME VARCHAR2(20 BYTE) NOT NULL,
MI VARCHAR2(20 BYTE) NULL,
LNAME VARCHAR2(20 BYTE) NOT NULL,
FULLNAME VARCHAR2(20 BYTE) NOT NULL,
HIREDATE DATE DEFAULT SYSDATE NOT NULL
-- data file employee.dat
1,amy,b,amy b
2,cindy,d,cindy d
3,eric,f,eric f
4,gary,h,gary
-- Control file : Employee.ctl ( you can use truncate, replace or append , see sqlldr for more options)
load data
Truncate into table employee
fields terminated by ","
optionally enclosed by '"'
TRAILING NULLCOLS
empId INTEGER EXTERNAL,
FName char(20),
LName char(20),
FullName char(30)
now to load use following or you can speicify infile in control fle
sqlldr username/passowrd control=employee.ctl data=employee.dat log=employee.log
{code}
Hope this help.
Regards -
In this case I had already processed this table once before 'no changes' and processed the second time I received this error ...sql execution Failed. It's like the sql server 2008 R2 doesn't see or detect the process. Starting Phase #0 Synchronizing Database:
then it shows 'Loading to database new table file name.dbo[table] ... sql execution failed (this is my issue)Hi TheJudge2,
Based on my understanding, you have installed SQL Server Migration Assistant successfully then you perform migration. After migration, you can’t find the table which you want to migrate to SQL Server 2008 R2 under the database in your SQL Server Management
Studio, then you perform migration again. Then error message “Loading to database new table file name.dbo[table] ... sql execution failed” is thrown out. Please correct me if I misunderstand your meaning.
Firstly, I would like to know whether you perform migration from Access database to SQL Server. I have performed migration from Access database to SQL Server in my lab environment. Based on my test, I could migrate Access database to SQL Server successfully
and table existed under the database in SQL Server Management Studio after migration.
Besides, “sql execution failed” is a general error message. It is hard to find out the cause from this error message. Please check the information under the Output in SQL Server Migration Assistant again. It would be better if you can provide the complete
output information for our deep analysis.
Best regards,
Qiuyun Yu -
Unable to load new information from configuration file /var/ldap/ldap_clien
Hi all,
When I run the command "ldapclient init", I got the error message:
# ldapclient init -a proxyDN=cn=proxyagent,ou=profile,dc=example,dc=ca -a domainName=example.ca -a profileName=UserProfile -a proxyPassword=pwd 10.1.10.50
Unable to load new information from configuration file '/var/ldap/ldap_client_file' ('Unable to open filename '/var/ldap/ldap_client_file' for reading (errno=2).').
Any idea?
Thanks a lot for your help!Does the profile UserProfile exist on your LDAP server?
Do the logs on your LDAP server show access problems?
Try using -v to get more verbose output -
How to create database from .sql file
how to create database from .sql file..?? i put the sintax query in a sql file.. and i want to call it in java code..
ho to do it..??why do you want to do this from java?
i just don't see the point.
find your dba and have him/her run it for you -
Issue in loading specific columns from a file to teradata table using IKM
Hi,
Can any one help to resolve the issue in loading specific columns from text file to teradata table.
i tried using IKM file teradata and columns are getting displaced.
my requirement suppose i have 5 columns in file and i have to load only 3columns to table using IKM.
same thing can be achived using LKM file to teradata but i want use IKM.
please suggest me on this
Regards
VinodHi,
I believe that the problem you are having is that you have a delimited file, of which you want to pick columns from position 2,3,5. In this case, ODI will pick the first 3 columns of a delimited file regardless of position.
For example, if you a tab delimited file with c1,c2,c3,c4,c5 columns, and you want only columns c2,c3,c5 - when mapping these in an ODI interface, and executing, you will actually pick up the data from c1,c2,c3 as these are the first three columns in the file (reading from left to right). You can ignore "columns" on the right hand side of a file, but not the left. E.g delimited file with c1,c2,c3,c4,c5. Only pick columns c1,c2 will give you data for the first 2 columns
Create a temporary table to load all the data from the file, and use you temp table to extract the data you require. Or you could get the file created with the first three columns as the columns you require.
Cheers
Bos
Edited by: Bos on Jan 18, 2011 1:06 PM -
Load the text from a file to JTextField, I need help badly
Can anybody help me, I try to load the text from a file to JTextField,
it compiled but it does not run
here the message i get:
----jGRASP exec: java buttonAction
----at: Sep 11, 2007 6:27:09 PM
----jGRASP wedge: pid for wedge is 3104.
----JGRASP wedge2: pid for wedge2 is 216.
----JGRASP wedge2: CLASSPATH is ".;;.;D:\Program Files\QuickTime\QTSystem\QTJava.zip;D:\Program Files\jGRASP\extensions\classes".
----jGRASP wedge2: working directory is [L:\Documents\GUI Pro] platform id is 2.
----jGRASP wedge2: actual command sent ["D:\Program Files\Java\jdk1.5.0_01\bin\java.exe" buttonAction].
----JGRASP wedge2: pid for process is 1440.
Exception in thread "main" java.lang.NullPointerException
at buttonAction.loadData(buttonAction.java:122)
at buttonAction.<init>(buttonAction.java:31)
at buttonAction.main(buttonAction.java:163)
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
private void loadData()
try
FileReader fr = new FileReader("myData.txt");
BufferedReader br = new BufferedReader(fr);
br.readLine();
while(br != null)
name.setText(br.toString());
catch (IOException e){}
}See this demo:
import java.io.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.FlowLayout;
public class TextFieldTest extends JFrame {
private JLabel fieldLabel;
private JTextField field;
private JButton loadTextBtn;
public TextFieldTest() {
initComponents();
private void initComponents() {
fieldLabel = new JLabel();
field = new JTextField(30);
loadTextBtn = new JButton("Load Text");
this.getContentPane().setLayout(new FlowLayout());
this.getContentPane().add(fieldLabel);
this.getContentPane().add(field);
this.getContentPane().add(loadTextBtn);
this.pack();
this.setLocationRelativeTo(null);
this.setTitle("TextFieldDemo");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
loadTextBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
loadText();
private void loadText() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("test.txt")));
String label = br.readLine();
String data = br.readLine();
br.close();
fieldLabel.setText(label);
field.setText(data);
} catch (Throwable t) { t.printStackTrace(); }
public static void main(String[] argv) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new TextFieldTest().setVisible(true);
}The contents of test.txt are as follows:
this is the label
the data for the field goes here -
Building Database from .dbf files
Hello All,
I had to reinstall oracle software. But I have all the data\control\log files from previous installation.
So my question is, Can I rebuild my database from those files? If so, how?
All the installation directories are same as before. I don't know if this helps but just wanted to provide as much info as possible.
Thanks,
SatishAll your tablespace, user, grants, etc. information is stored within the system datafile, so if you install the Oracle server, then manually recreate the directory structure from your previous database (for example on NT, you'd create d:\oracle\oradata\your_sid\*.dbf
d:\oracle\admin\your_sid\pfile | bdump | etc...) then put the datafiles in the location where the control files says they should be, and your pfile points to the correct control files then it will be OK.
Your pfile will contain the location(s) of your control files. When you nomount the database, the instance will start and the pfile will find the location/locate the control file (this is why you recreate the control file in nomount mode); then when you mount the database, the control files are actually opened and read so the instance can locate the datafiles, identify the tablespaces, etc (this is why you have to put the control files in the location(s) specified in the pfile and datafiles, etc. back in the location specified in the control file). Then opening the database just basically validates everything and opens for use. As long as you don't specify SIZE or REUSE for the datafiles in the control file, and comment out everything after the CHARACTER SET listed in the control file and you still have the datafiles that contain data, you won't need anything like an import. You may need media recovery of some sort or experiment with incomplete recovery (if files are available) and open with resetlogs; but normally if you have an OracleService and you have a pfile, control files, and datafiles, everything will be there (user info and all is stored in the system datafile).
Hope this helps answer some of your questions. Anyway - you can try it and if it fails, you can always start over as long as you have a backup copy of your datafiles and controlfiles and pfile.
Gridahsir -
Jfmerge: [240]Failure loading colour palette from form file.
Hi All,
I need your help. I am new to JetForm and have to use it because of my work. Recently I have been assigned a task which is to amend an existing form, however, when I opened it with the JetForm Designer, it prompted me with message #4043 with following information:
The current settings for Symbol Set handling are different
from when the form was last saved.
Form: Convert is Yes,950,950
Current: Convert is Yes,1252,850
I skipped the warning message and just compile the MDF file directly without any changes. Then, I just got the "jfmerge: [240]Failure loading colour palette from form file." error message during the printing process. May I know how could I fix it? Please help and advise.
Thanks,
CharoiteHello,
I have exactly same problem than you while opening an existing .ifd file :
The current settings for Symbol Set handling are different from when the template was last saved.
Template : Convert is No,936,850
Current : Convert is N0,1252,850
I suppose it is due to chinese characters (Simsun font) bad installed on my desktop, but it is only hypothesis.
Did you achieve to avoid this message since 05/2011 ?
Maybe you are looking for
-
No Partner details in new order : CRM_ORDER_MAINTAIN
Hi ..... I am trying to create new order in which i am getting error related to partner data though i am passing al the data into the CRM_ORDER_MAINTAIN function. I am not able to figure out what is the problem. Following is my code part -> READ TABL
-
Photoshop CS4 installation path problem
i having installation problem after i restore my pc, where i have install it normally before window restore. after install it doesnt work at all. It set the installation path to common files folder, i have try uninstall all and reinstall it but still
-
i am in a situation, need your help.... When I try to save as an existing query, I see only only favorites and roles on save query as window. but i want to save in the same infoarea. the infoareas list is not displayed at all. is there a way i can ge
-
What is necessary for MM in IDOC and ALE??
hii What is ALE, EDI and IDOC in SAP?? Explain the above things with example What i have to learn as MM consultant to work on support project .. Can some body explain me with their real time experience Thanks
-
Urgent, please help! Oracle 7 to Oracle 8
Hi, Our company has a client application developed basing on VC++, Oracle OLE to communication with Oracle database. Now, there is need to upgrade the client side OLE for Oracle 8 . My question is: 1. if or not, we have to modify VC source code, usin