How to develope application for converting excel data into oracle database
I am very new to the oracle world. I want to develop application for converting excel sheet into oracle database using oracle forms. I have basic knowldge of oracle but i am totally new to the forms. Can anybody tel me step by step procedure to do this task? Please help me out in this problem.
Thanx in advance.
Hello,
just do a "Search" in this forum with words "excell to oracle"... and you could find lot of posts about that, i.e.:
Re: How to load excel-csv file into oracle database
Jose L
Similar Messages
-
Regarding loading of excel data into oracle database
hello,
Can someone help me in knowing that how can we load excel sheets data into oracle database.
I will be really thankful to you.
GursimranHi,
There is tool given by oracle "Oracle Bulk Loader "
you can use this.
But in order use this you need a control file, which specifies how data should be loaded into the database; and a data file, which specifies what data should be loaded.
Example :- this is the control file which has information how the data is processed.
LOAD DATA
INFILE test.dat
INTO TABLE test
FIELDS TERMINATED BY '|'
(i, s)
Example :- test.dat which is the data file or say your excel sheet or document
(1, 'foo')
(2, 'bar')
(3, ' baz')
example of Loading :-
sqlldr <yourName> control=<ctlFile> log=<logFile> bad=<badFile>
sqlldr testing control=test.ctl log=test.log
Thanks
Pavan Kumar N -
Want to load excel data into oracle table with out changing it to CSV
Hello all,
I have a requirement in dumping excel data into oracle database table without changing it to CSV file and this has to be used in normal sql/plsql environment i.e., pkg/procedure cant be used in the forms also...
so, can u guys can help me out in this
thanks.............The link Pavan provided discusses Oracle Heterogeneous Services. This allows you (using ODBC) to create a database link from Oracle to a non-Oracle data source like Excel. This would allow you to query the Excel data source from SQL*Plus or any other client tool. But that is probably going to require that your Oracle database is running on Windows since I'm not aware of any Excel ODBC drivers for Unix.
Another potential option would be to write a Java stored procedure that parsed the file. There are a few different Java libraries that can read and write Excel data files. You could load one of those libraries into the database's JVM and then write Java code that parsed the file. You would then be able to call your Java stored procedure from PL/SQL.
Justin -
How to create a Macro in excel to store the excel data to Oracle Database
Hi All
Does anyone has created a macro in excel which on being run stores the excel data to Oracle database. In my project I need to create one such macro for updating oracle database with excel data and another for inserting excel records.
I tried doing this using a macro in MS access but Client wants its to be done using Excel Macro only.
Any help would be highly appreciated.
Thanks in advance..
ShikhaPlease read Chapter 19.7 Creating Selection Lists (http://download.oracle.com/docs/html/B25947_01/web_complex007.htm#CEGFJFED) of the Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers 10g Release 3 (10.1.3.0)
Cheers,
Mick. -
Importing excel data into oracle tables
Hello gurus,
Importing excel data into oracle tables..
I know this is the most common question on the thread ...First, i searched the forum, i found bunch of threads with loading data using sqlloader, converting excel into .Txt, tab delimited file, .csv file etc....
Finally i was totally confused in terms how to get this done....
Here is wat i have
- Excel file on local computer.
- i have laod data into dev environment tables(So no risk involved, but want to try something simple)
- Oracle version 11.1.0.7
- Sqlplus and toad (editors)
Here is wat i like to do ....i dont know if its possible
- Without going to unix server can i do everthing on local system by making use of oracle db and sqlplus or toad
SQLLOADER might be one option...but i dont want to go the unix server for placing files and logs and stuff.
Wat will be best and simplest option to do?? and wat format will best to convert from excel into csv, or txt or tab delimited etc.....
If you suggest sqlloader, any code example will be greatly appriciated.
Thank you so much!!!Hi,
user642297 wrote:
Imran,
This is increadible option in toad!!! It works absolutely sweet!! I have toad 9.7 version. IT works great. Thank you so much!!You are welcome :)
Well i have further discussion on this ....this option is great if you doing in staging or development area. What if your doing in prod?? If you automating the sqlloader then how do u do it?? I think we still need to stick with traditional approach of laoding data by making use of SQLLoader right ?? If m wrong please correct me.well, in our case, we do have access to a custom schema in prod where we create the staging table and load the data from datafiles.
try this:
load data
infile 'C:\dest.csv'
into table dest_table
fields terminated by "~" optionally enclosed by '"'
TRAILING NULLCOLS
(name,
owner_nm,
description_column,
UPDT_DT DATE 'MM/DD/YYYY')
{code}
you can get more info about sql loader and your error here:
http://download.oracle.com/docs/cd/B10501_01/server.920/a96652/ch05.htm
http://www.allinterview.com/showanswers/53766.html
And one more quick question ...i found an example of control file , in that i see .dat format file. Is it a data file ?? can i try that option ?? But in excel i didnt see to convert the .dat format file.
Any thoughts ???
It is same as a delimiter text file.
steps to create a .dat file (from a excel file):
1. Insert a column between two columns and populate it with the delimiter (in our case, it is ~)
2. Save the file as unicode text.
3. Open the file in text editor and remove all the tabs (find an replace with blank)
4. Save the file as "DEST.dat". Select encoding as UTF-8 while saving.
5. Your .dat file is ready.
Regards
Imran
Edited by: Imran Soudagar on Apr 22, 2010 10:22 PM -
How to insert more than 32k xml data into oracle clob column
how to insert more than 32k xml data into oracle clob column.
xml data is coming from java front end
if we cannot use clob than what are the different options availableAre you facing any issue with my code?
String lateral size error will come when you try to insert the full xml in string format.
public static boolean writeCLOBData(String tableName, String id, String columnName, String strContents) throws DataAccessException{
boolean isUpdated = true;
Connection connection = null;
try {
connection = ConnectionManager.getConnection ();
//connection.setAutoCommit ( false );
PreparedStatement PREPARE_STATEMENT = null;
String sqlQuery = "UPDATE " + tableName + " SET " + columnName + " = ? WHERE ID =" + id;
PREPARE_STATEMENT = connection.prepareStatement ( sqlQuery );
// converting string to reader stream
Reader reader = new StringReader ( strContents );
PREPARE_STATEMENT.setClob ( 1, reader );
// return false after updating the clob data to DB
isUpdated = PREPARE_STATEMENT.execute ();
PREPARE_STATEMENT.close ();
} catch ( SQLException e ) {
e.printStackTrace ();
finally{
return isUpdated;
Try this JAVA code. -
Problems with special characters uploading data into oracle database
Greetings
I have a problem uploading data into oracle tables from sybase datasource. The data that I want to upload is in Spanish, for example when I have a varchar field with the data 'Consultoría', in oracle table the data upload with interrogation symbols.
I have my source and target datastores configured as follows.
Any suggestion? Thank you for your timeChack section 10 Locales and Multi-byte Functionality in the SAP Data Services Reference Guide for an exhaustive description of NLS settings.
As a summary, following settings are required:
locales in the datastore definitions match the actual locale used in the associated databases
the locale of the DS engine allows for source to target translation
the character set in the target database supports storage of accented characters -
Parsing xml data into oracle database
Oracle ACEs,
We got a requirement that needs to load xml data into oracle db. Is it possible to load xml data into oracle db using built-in package. Is Oracle provides one ?
Our database version is Oracle 9i.
Your help in this regard is highly appreciated.
Many Thanks.Check this out.
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_xmlsav.htm#1008593 -
How to convert excel data into OTF and FAX
Hi All,
We have a requirement where in we have a smartform output (OTF data) converted into PDF, and an excel sheet, both being sent as email attachments.
Now, we need to send the content of both the attachments as FAX.
Since smartform output was OTF convertible, FAX was being sent using 'CONVERT_OTF_AND_FAX' FM.
Can you let me know, if there is a possible way for manipulating the data that is converted to EXCEL, as OTF, and then FAX it?
Or else, please suggest me an alternative way to FAX normal data (other than using 'CONVERT_OTF_AND_FAX').
Thanks in advance,
RAVIHi All,
We have a requirement where in we have a smartform output (OTF data) converted into PDF, and an excel sheet, both being sent as email attachments.
Now, we need to send the content of both the attachments as FAX.
Since smartform output was OTF convertible, FAX was being sent using 'CONVERT_OTF_AND_FAX' FM.
Can you let me know, if there is a possible way for manipulating the data that is converted to EXCEL, as OTF, and then FAX it?
Or else, please suggest me an alternative way to FAX normal data (other than using 'CONVERT_OTF_AND_FAX').
Thanks in advance,
RAVI -
Import Excel File Data into oracle database table.
HI,
i want to insert data into a specific table from a excel file. please help me..
for example
emp.xls file's data need to be import in emp database table.
thanks in advance...Hi,
to all knowledgable person, this would be gald for u all that i have solved the problem.
through this procedure..
PROCEDURE IMPORT_FROM_EXCEL_PROC (as_FileName VARCHAR2, exe_name varchar2) IS
appid PLS_INTEGER;
convid PLS_INTEGER;
docid PLS_INTEGER;
conv_established BOOLEAN := FALSE;
buffer VARCHAR2(100);
Emp_code VARCHAR2(100);
Emp_name VARCHAR2(100);
Emp_desig VARCHAR2(100);
Emp_Salary VARCHAR2(100);
ls_error VARCHAR2(1000);
li_row integer;
li_col integer;
li_error_count integer;
li_load_count integer;
BEGIN
--Start Excel
--This line assumes that Excel is in the specified directory
-- APPID := DDE.APP_BEGIN('D:\OFFICE11\EXCEL.EXE',DDE.APP_MODE_MINIMIZED);
APPID := DDE.APP_BEGIN(exe_name,DDE.APP_MODE_MINIMIZED);
--Establish a conversation with Excel
--The following loop will not end until a conversation with Excel
--has been established. Therefore, it can result in a endless loop,
--so use with caution.
WHILE NOT conv_established LOOP
BEGIN
convid := DDE.INITIATE('excel', 'system');
conv_established := TRUE;
EXCEPTION
WHEN DDE.DMLERR_NO_CONV_ESTABLISHED THEN
conv_established := FALSE;
END;
END LOOP;
--Open Excel document
--This assumes that you have an Excel spreadsheet named ddetest.xls in the root of c:
DDE.EXECUTE(convid, '[Open("'||as_FileName||'")]', 10000);
--Initiate conversation with Excel document
docid := DDE.INITIATE('excel',as_FileName);
--Begin transfer from Excel to Forms
li_load_count := 0;
li_error_count := 0;
li_col := 1;
li_row := 2;
GO_BLOCK('IMPORT_XLS');
DDE.REQUEST (docid, 'R' || TO_CHAR(li_row) || 'C' || TO_CHAR(li_col), buffer, DDE.CF_TEXT, 1000);
WHILE length(buffer) > 2 LOOP
WHILE li_col < 5 LOOP
buffer := substr(buffer, 1, instr(buffer, chr(10)) - 2);
IF li_col = 1 THEN --Emp_code
Emp_code := buffer;
ELSIF li_col = 2 THEN --Emp_name
Emp_name := buffer;
ELSIF li_col = 3 THEN --Emp_desig
Emp_desig := buffer;
ELSE --Emp_salary
Emp_salary := buffer;
END IF;
IF nvl(ls_error,'N') = 'N' THEN
li_col := li_col + 1;
DDE.REQUEST (docid, 'R' || TO_CHAR(li_row) || 'C' || TO_CHAR(li_col), buffer, DDE.CF_TEXT, 1000);
ELSE
li_col := 5;
END IF;
END LOOP;
IF nvl(ls_error, 'N') = 'N' THEN
li_load_count := li_load_count + 1;
IF li_load_count = 1 THEN
FIRST_RECORD;
ELSE
NEXT_RECORD;
END IF;
:IMPORT_XLS.Emp_code := Emp_code;
:IMPORT_XLS.Emp_name := Emp_name;
:IMPORT_XLS.Emp_desig := Emp_desig;
:IMPORT_XLS.Emp_salary := Emp_salary;
ELSE
li_error_count := li_error_count + 1;
DDE.POKE(docid, 'R' || TO_CHAR(li_row) || 'C5', ls_error, DDE.CF_TEXT, 10000);
END IF;
ls_error := '';
Emp_code := '';
Emp_name := '';
Emp_desig := '';
Emp_salary := '';
li_col := 1;
li_row := li_row + 1;
DDE.REQUEST (docid, 'R' || TO_CHAR(li_row) || 'C' || TO_CHAR(li_col), buffer, DDE.CF_TEXT, 1000);
END LOOP;
IF li_error_count > 0 THEN
DDE.EXECUTE(convid, '[[save]]', 10000);
Message(TO_CHAR(li_load_count) || ' Record(s) Loaded. ' ||
TO_CHAR(li_error_count) || ' Invalid Record(s). See error in excel file.');
ELSE
Message(TO_CHAR(li_load_count) || ' Record(s) Successfully Loaded.');
END IF;
--End transfer to Excel
DDE.TERMINATE(docid);
DDE.TERMINATE(convid);
DDE.APP_END(appid);
--Handle exceptions
EXCEPTION
WHEN DDE.DDE_APP_FAILURE THEN
MESSAGE('WINDOWS APPLICATION CANNOT START.');
WHEN DDE.DDE_PARAM_ERR THEN
MESSAGE('A NULL VALUE WAS PASSED TO DDE');
WHEN DDE.DMLERR_NO_CONV_ESTABLISHED THEN
MESSAGE('DDE CANNOT ESTABLISH A CONVERSATION');
WHEN DDE.DMLERR_NOTPROCESSED THEN
MESSAGE('A TRANSACTION FAILED');
END; -
How to insert date into oracle database
Hi, there,
I want to insert date information to oracle database in a jsp page using JSTL. but always got wrong message:
javax.servlet.jsp.JspException:
INSERT INTO DATE_TEST
(date_default,date_short,date_medium)
values(?,?,?)
: Invalid column type
I don't know how to convert java date type to oracle date type or vice versa. the following is the source code(all the fields of DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM are oracle date type. and even I want to insert d instead d1, I got the same wrong message)
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%
Calendar now;
Calendar rightNow = Calendar.getInstance();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>
Hello World
</title>
</head>
<body>
<h2>
The current time is:
</h2>
<p>
<%= new java.util.Date() %></p>
<%
java.util.Date d=new java.util.Date();
java.sql.Date d1=new java.sql.Date(d.getYear(),d.getMonth(),d.getDate());
out.print(d1.toString());
%>
<sql:update>
INSERT INTO DATE_TEST
(DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM)
VALUES(?,?,?)
<sql:dateParam value="${d}" type="date" />
<sql:dateParam value="${d}" type="date" />
<sql:dateParam value="${d}" type="date" />
</sql:update>
</body>
</html>
thank you very much for the great help!!Hi, there,
I want to insert date information to oracle database in a jsp page using JSTL. but always got wrong message:
javax.servlet.jsp.JspException:
INSERT INTO DATE_TEST
(date_default,date_short,date_medium)
values(?,?,?)
: Invalid column type
I don't know how to convert java date type to oracle date type or vice versa. the following is the source code(all the fields of DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM are oracle date type. and even I want to insert d instead d1, I got the same wrong message)
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%
Calendar now;
Calendar rightNow = Calendar.getInstance();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>
Hello World
</title>
</head>
<body>
<h2>
The current time is:
</h2>
<p>
<%= new java.util.Date() %></p>
<%
java.util.Date d=new java.util.Date();
java.sql.Date d1=new java.sql.Date(d.getYear(),d.getMonth(),d.getDate());
out.print(d1.toString());
%>
<sql:update>
INSERT INTO DATE_TEST
(DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM)
VALUES(?,?,?)
<sql:dateParam value="${d}" type="date" />
<sql:dateParam value="${d}" type="date" />
<sql:dateParam value="${d}" type="date" />
</sql:update>
</body>
</html>
thank you very much for the great help!! -
I am having the following code in Button-Press-Event for inserting the data from the selected Excel sheet. My problem is only the last row of the Excel file is store in Oracle Table. Others are not at all coming. Anybody having idea on this....?
DECLARE
M_APPID PLS_INTEGER;
M_CONVID PLS_INTEGER;
M_BUFFER VARCHAR2(240);
M_CNT NUMBER;
M_ROW NUMBER;
M_COL NUMBER;
M_ROWID NUMBER := 0;
M_ERROR CHAR;
M_EXCEL_FILE VARCHAR2(2000);
M_EXIT_FLAG CHAR(1);
BEGIN
SET_ITEM_PROPERTY('M_PROCESSING_INFO',VISUAL_ATTRIBUTE,'BP_LOOK');
:M_PROCESSING_INFO := 'Validating file, please wait...';
SYNCHRONIZE;
SET_ITEM_PROPERTY('M_BTN_PREVIEW',ENABLED,PROPERTY_FALSE);
L_VALIDATE_FILE_EXISTENCE;
GO_BLOCK('OW_EXCEL_UPLOAD');
CLEAR_BLOCK(NO_VALIDATE);
GO_BLOCK('OT_EXCEL_ERROR_LOG');
CLEAR_BLOCK;
SET_BLOCK_PROPERTY('OW_EXCEL_UPLOAD',UPDATE_ALLOWED,PROPERTY_FALSE);
SET_BLOCK_PROPERTY('OW_EXCEL_UPLOAD',DELETE_ALLOWED,PROPERTY_FALSE);
SET_BLOCK_PROPERTY('OW_EXCEL_UPLOAD',INSERT_ALLOWED,PROPERTY_TRUE);
GO_ITEM('OW_EXCEL_UPLOAD.OU_ROW_NO');
M_APPID := DDE.APP_BEGIN(M_EXCEL_FILE|| ' '||CHR(34)||:P_TXT_FILE_NAME||CHR(34), DDE.APP_MODE_MINIMIZED);
M_CONVID := DDE.INITIATE('EXCEL', :P_TXT_FILE_NAME);
FIRST_RECORD;
M_CNT := 0;
FOR M_ROW IN :M_START_ROW .. :M_END_ROW LOOP
M_ROWID := M_ROWID + 1;
FOR M_COL IN :M_START_COL .. :M_END_COL LOOP
INSERT INTO TEMP VALUES (M_ROWID, M_COL);
M_BUFFER := '';
M_CNT := M_CNT + 1;
:M_PROCESSING_INFO := 'Processing R'||M_ROW||'C'||M_COL;
SYNCHRONIZE;
DDE.REQUEST(M_CONVID, 'R'||M_ROW||'C'||M_COL, M_BUFFER, DDE.CF_TEXT, 240);
M_BUFFER := RTRIM(LTRIM(M_BUFFER));
M_BUFFER := SUBSTR(M_BUFFER,0,LENGTH(M_BUFFER)-2);
:M_PROCESSING_INFO := 'Processed R'||M_ROW||'C'||M_COL;
SYNCHRONIZE;
IF M_BUFFER IS NULL AND M_COL = 1 THEN
M_EXIT_FLAG := 'Y';
EXIT;
END IF;
COPY(M_ROWID,'OW_EXCEL_UPLOAD.OU_ROW_NO');
BEGIN
IF M_COL = 1 THEN
:EXU_CONT_NO := M_BUFFER;
ELSIF M_COL = 2 THEN
:EXU_LOT_NO := M_BUFFER;
ELSIF M_COL = 3 THEN
:EXU_PART_NO := M_BUFFER;
ELSIF M_COL = 4 THEN
:EXU_QTY := TO_NUMBER(M_BUFFER);
END IF;
EXCEPTION
WHEN OTHERS THEN
L_SAVE_ERROR_LOG(:P_TXT_FILE_NAME,M_ROW,M_BUFFER,L_ERR_DESC(3107));
GO_BLOCK('OT_EXCEL_ERROR_LOG');
EXECUTE_QUERY;
END;
END LOOP;
CREATE_RECORD;
M_CNT := 0;
IF M_EXIT_FLAG = 'Y' THEN
EXIT;
END IF;
END LOOP;
:M_RECORD_CNT := M_ROWID - 1;
DDE.TERMINATE(M_CONVID);
DDE.APP_END(M_APPID);
FIRST_RECORD;
COMMIT;
:M_PROCESSING_INFO := 'Data in the Excel Sheet uploaded into the System.';
SYNCHRONIZE;
GO_BLOCK('OW_EXCEL_UPLOAD');
EXECUTE_QUERY;
END;
Note:
My temp table is having exact number of rows as in Excel sheet.Have you used the debugger and single stepped through the code to see where the problem is?
-
Native SQL: insert data into oracle database, no return message.
hi,
the statement : insert into <TableName> values (Source)
how can I know if the data have already insert to the database table?
now I have a program have this problem: the data has already exist, but there's no error message return when insert the same data again.
data: dbs like dbcon-con_name value 'HRGK',
dbtype type dbcon_dbms.
data: sqlerr_ref type ref to cx_sql_exception,
exc_ref type ref to cx_sy_native_sql_error,
error_text type string.
data: cnt type i,
i(2) type c.
set locale language 'E'.
EXEC SQL.
CONNECT TO :DBS
ENDEXEC.
EXEC SQL.
SET CONNECTION :DBS
ENDEXEC.
EXEC SQL.
SELECT COUNT(*) from org_unit into :cnt
ENDEXEC.
write: / cnt.
*do.
i = 'A'.
try.
EXEC SQL.
BEGIN
insert into ORG_UNIT ( ORGAN_ID, UNIT_NO, UNIT_NAME, PARENT_ID)
values ( 'A', '123412', 'SDFSG', 'DDS'); " ORGAN_ID is primary key
" If the data 'A' has already exist in database ORG_UNIT, it will show error message
" But if I use :I instead 'A', it will not show error message.
IF SQL%FOUND THEN
COMMIT;
END IF;
END;
endexec.
EXEC SQL.
SELECT COUNT(*) from ORG_UNIT into :cnt
ENDEXEC.
write: / cnt.
catch cx_sy_native_sql_error into exc_ref.
error_text = exc_ref->get_text( ).
write: / error_text.
catch cx_sql_exception into sqlerr_ref.
perform handle_sql_exception using sqlerr_ref.
endtry.
EXEC SQL.
disconnect :DBS
ENDEXEC.
*enddo.
*& Form handle_sql_exception
form handle_sql_exception
using p_sqlerr_ref type ref to cx_sql_exception.
format color col_negative.
if p_sqlerr_ref->db_error = 'X'.
write: / 'SQL error occured:', p_sqlerr_ref->sql_code,
/ p_sqlerr_ref->sql_message. "#EC NOTEXT
else.
write:
/ 'Error from DBI (details in dev-trace):',
p_sqlerr_ref->internal_error. "#EC NOTEXT
endif.
endform. "handle_sql_exception
please help to see the words:
*" If the data 'A' has already exist in database ORG_UNIT, it will show error message*
*" But if I use :I instead 'A', it will not show error message.*
in the program.
Thanks a lot!resumption and jer,
Sorry I cannot format the code for easy reading!
The page is submitting to itself. See action = \"$uri\". I used the same logic to enter SELECT querries into the database. It pulls and displays data back on the webpage. The code I used for this is below. Compare it with the one above for inserting data into the table.
<?php
// connect to oracle
$username = "xxxxx";
$paswd = "yyyyy";
$dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
"(HOST=patriot.gmu.edu)(PORT=1521))".
"(CONNECT_DATA=(SID=COSC)))";
$db_conn = ocilogon($username, $paswd, $dbstring);
// username and password will be unset if they weren't passed,
// or if they were wrong
if( !isset($query)) {
// just print form asking for account details
echo "<form action=\"$uri\" method=post>\n";
echo "<p>Enter Query: ";
echo "<input type=text size=100 maxlength=200 name=query value=\"$query\">\n";
echo "<br><input type=submit name=submit value=Submit>\n";
echo "</form>\n";
exit;
// remove unwanted slashes from the query
$query = stripslashes($query);
// run the query
$stmt = OCIParse($db_conn, $query);
OCIExecute($stmt, OCI_DEFAULT);
// Open the HTML table.
print '<table border="1" cellspacing="0" cellpadding="3">';
// Read fetched headers.
print '<tr>';
for ($i = 1;$i <= ocinumcols($stmt);$i++)
print '<td class="e">'.ocicolumnname($stmt,$i).'</td>';
print '</tr>';
// Read fetched data.
while (ocifetch($stmt))
// Print open and close HTML row tags and columns data.
print '<tr>';
for ($i = 1;$i <= ocinumcols($stmt);$i++)
print '<td class="v">'.ociresult($stmt,$i).'</td>';
print '</tr>';
// Close the HTML table.
print '</table>';
OCIFreeStatement($stmt);
OCILogoff($db_conn);
?> -
Insert data into oracle database using a PHP form
I'm trying to enter data into my oracle database table using a php form. When I click submit no data is added. Could someone help me please. I'm new to php/oracle thing.
NOTE: I don't have any problem connecting to the database using php.
Here is the code I'm using:
<?php
// just print form asking for name if none was entered
if( !isset($query)) {
echo "<form action=\"$uri\" method=post>\n";
echo "<p>Enter Name: ";
echo "<input type=text size=100 maxlength=200 name=data value=\"$data\">\n";
echo "<br><input type=submit name=submit value=Submit>\n";
echo "</form>\n";
exit;
// insert client's name
$query = "INSERT INTO client (name) VALUES ($data)";
// connect to Oracle
$username = "xxxx";
$paswd = "yyyyyy";
$dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
"(HOST=patriot.gmu.edu)(PORT=1521))".
"(CONNECT_DATA=(SID=COSC)))";
$db_conn = ocilogon($username, $paswd, $dbstring);
$stmt = OCIParse($db_conn, $query);
OCIExecute($stmt, OCI_DEFAULT);
OCIFreeStatement($stmt);
OCILogoff($db_conn);
?>
Thanks for your help. I will also appreciate a better was to do it.
Tonyresumption and jer,
Sorry I cannot format the code for easy reading!
The page is submitting to itself. See action = \"$uri\". I used the same logic to enter SELECT querries into the database. It pulls and displays data back on the webpage. The code I used for this is below. Compare it with the one above for inserting data into the table.
<?php
// connect to oracle
$username = "xxxxx";
$paswd = "yyyyy";
$dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
"(HOST=patriot.gmu.edu)(PORT=1521))".
"(CONNECT_DATA=(SID=COSC)))";
$db_conn = ocilogon($username, $paswd, $dbstring);
// username and password will be unset if they weren't passed,
// or if they were wrong
if( !isset($query)) {
// just print form asking for account details
echo "<form action=\"$uri\" method=post>\n";
echo "<p>Enter Query: ";
echo "<input type=text size=100 maxlength=200 name=query value=\"$query\">\n";
echo "<br><input type=submit name=submit value=Submit>\n";
echo "</form>\n";
exit;
// remove unwanted slashes from the query
$query = stripslashes($query);
// run the query
$stmt = OCIParse($db_conn, $query);
OCIExecute($stmt, OCI_DEFAULT);
// Open the HTML table.
print '<table border="1" cellspacing="0" cellpadding="3">';
// Read fetched headers.
print '<tr>';
for ($i = 1;$i <= ocinumcols($stmt);$i++)
print '<td class="e">'.ocicolumnname($stmt,$i).'</td>';
print '</tr>';
// Read fetched data.
while (ocifetch($stmt))
// Print open and close HTML row tags and columns data.
print '<tr>';
for ($i = 1;$i <= ocinumcols($stmt);$i++)
print '<td class="v">'.ociresult($stmt,$i).'</td>';
print '</tr>';
// Close the HTML table.
print '</table>';
OCIFreeStatement($stmt);
OCILogoff($db_conn);
?> -
How to load excel data into oracle table
How do i load data from an excel file with several worksheets into an oracle table?
using Oracle 10g
Excel
sample data of excel
Name eric Name mary
AccountNo 123 AccountNo 321
amount1 5.0 Amount1 1.0
amount2 5.5 Amount2 2.0
amount3 6.0 Amount3 3.0
Total 16.5 Total 6.0
Name larry Name beth
AccountNo 123 AccountNo 321
amount1 5.0 Amount1 1.0
amount2 5.5 Amount2 2.0
amount3 6.0 Amount3 3.0
Total 16.5 Total 6.0
Note: Assume data are aligned into columns like a real excel workbookI have some used something like this.
don't ask any details as I am not a xl person, but i think its pretty straight forword.
hope its helpful for you or someone else
Dim i As Integer
Dim conn As New ADODB.Connection
Dim strInsert As String
Dim strExecInsert As String
conn.ConnectionString = "Provider=MSDAORA.1;User ID=scott;password=tiger;Data Source=orcl.world;Persist Security Info=False"
conn.Open
strInsert = "insert into xlsc ( emp, dept, doj," & _
"dol, dob, Ce ,ED, v_date ) values("
'this is to insert first 2347 rows from xl to orcl
While i < 2348
strExecInsert = strInsert & "'" & _
Trim(Cells(i, 1).Value) & "','" & _
Trim(Cells(i, 2).Value) & "','" & _
Trim(Cells(i, 3).Value) & "','" & _
Trim(Cells(i, 4).Value) & "','" & _
Trim(Cells(i, 5).Value) & "','" & _
Trim(Cells(i, 6).Value) & "','" & _
Trim(Cells(i, 7).Value) & "','" & _
Trim(Cells(i, 8).Value) & "' )"
'MsgBox strExecInsert
If Cells(i, 1).Value <> "" Then
conn.Execute (strExecInsert)
End If
i = i + 1
Wend
'conn.Execute ("commit")
conn.Close
End Sub
Maybe you are looking for
-
Error trying to generate addmrpt (ADDM Report) on Oracle 10.1.0.4
Hello, When I launch $ORACLE_HOME/rdbms/admin/addmrpt.sql on my Fedora 3 Oracle 10g connected using sys as sysdba (or system), I get the following error : Specify the Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entrez une valeur
-
How to import java Classes in report Builder
Hi, I want to import classes from a jar file into Report Builder (10 g). I'm not able to find my JAR in -- Program --> Import Java Classes option. I have set the classpath pointing to my JAR.
-
To add a program just check one or all?
Silly question but... I have CS6 and installed InDesign and Photoshop and Acrobat. Now I want to add Illustrator. Running "setup" it's not clear if I should check those 3 AND Illustrator or JUST Illustrator. If I only check Illustrator will it uninst
-
Smart Collection "Capture Date is in the last n hours" not working?
In Smart Collection, the rule "Capture Date is in the last n hours" doesn't work for me. It seems to behave similarly to "Capture Date is today". (See the screenshot below). Has anyone else noticed this, or can you replicate this? If so, I'll file
-
Since the upgrade yesterday it has crashed repeatedly.