Inserting dates into oracle
I'm trying to insert a date into a table...I'm not getting an error - but Oracle is not inserting a record.
string some_date = "10/27/2004";
In Oracle I'm converting the date string using the TO_DATE function, the column is a DATE datatype.
TO_DATE(p_some_date,'DD-MON-YYYY')
Any suggestions?
The format used to display or input a date has no bearing on the way it is stored. In Oracle a date is stored using 7 bytes as follows:
yy 1 - trunc(yy / 100) + 100
yy 2 - mod(yy, 100) + 100
mm 3 - simple month (1-12)
dd 4 - simple day (1-31)
hh 5 - hh + 1
mm 6 - mm + 1
ss 7 - ss + 1You can see how this format relates to a "displayed date" as follows:
SQL> connect /
Connected.
SQL> create table t
2 (
3 c date
4 );
Table created.
SQL> insert into t values (sysdate);
1 row created.
SQL> select to_char(c, 'DD-MON-YYYY HH24:MI:SS'), dump(c) from t;
TO_CHAR(C,'DD-MON-YY DUMP(C)
28-OCT-2004 19:40:45 Typ=12 Len=7: 120,104,10,28,20,41,46
1 row selected.However, you are telling Oracle that the format of the input date string is "DD-MON-YYYY" but it is not. The format of the input string is "MM/DD/YYYY". If you want to pass the string in that format just change your to_date to match that format (i.e. to_date(some_date, 'DD/MM/YYYY')
- Mark
Similar Messages
-
Insert data into oracle table from XML file
I need to insert data into oracle table from XML file
If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
Thanks in advanceThe XML DB forum provides the best support for XML topics related to Oracle.
Here's the FAQ on that forum:
XML DB FAQ
where there are plenty of examples of shredding XML into Oracle tables and such like. ;) -
How to insert data into Oracle db from MySQL db through PHP?
Hi,
I want to insert my MySQL data into Oracle database through PHP.
I can access Mysql database using mysql_conect() & Oracle database using oci_connect() through PHP.
Now How can I insert my data which is in MySQL into Oracle table. Both table structure are exactly same.
So I can use
insert into Oracle_Table(Oracle_columns....) values(Select * from MySQL_Table);
But again problem is I can't open both connections at the same time.
So has anyone done this before or anyone having any other idea..
Plz guide me...You can do it if you setup a ODBC Gateway between MYSQL and Oracle DB. Then you can directly read from MySQL table using DB links and insert into Oracle table in one single SQL Statement.
Otherwise you need to fetch the data from MySQL Into variables in your PHP Program and then insert into Oracle after binding the variables to the insert statement for Oracle. Hope that is clear enough.
Regards
Prakash -
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);
?> -
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);
?> -
ADF Mobile - insert data into oracle db from oracle adf mobile application
Hi,
I have to insert data from mobile into oracle database 11g(not in local sqlite database), can somebody tell me how to do it?
Thanks,
AnshulHi, Anshul, one common way is to expose DB data as ADF BC, and then add a service interface on top of ADF BC. This would allow the ADF Mobile app to access server DB through ADF BC. There may be other mechanisms to access server-side DB - I think APEX also expose some REST interface to Oracle DB as well. Another option is to use TopLink - TopLink can also expose some REST services.
Thanks,
Joe Huang -
Source is Oralce. Destination is SQL Server.
Requirement - I have to fetch sql server server data (empid's) based emp table and send this as input data to oracle to fetch and empid's are common.
I cannot use merge or loopkup or for each as oracle have too many records.
For example - In MS SQL - i have empid=1,2..Only these records, I have to fetch from oracle source into sql server destination. For this, I have adopted the below approaches...The major problem I face, when i build a empid's as a string, it is taking only
4000 chars. My string lenght is 10000. How do I breakup this string lengh and send to data flow task till all broken strings length passed to DFT.
Approach-1
created two variables - oraquery string, empid string
step1 - ms sql database - created sql task - declare @empid varchar(max)
SELECT @empid=
Stuff((SELECT ',' + empid
FROM
(SELECT DISTINCT convert(varchar(10),empid ) empid FROM emp
) x
For XML PATH ('')),1,1,'')
select @empid = '(' + @empid + ')'
select @empid
resultset=singlerow
resultset=resultname=0; variablename=User::empid (empid is declared as string)
step2 - oracle database - created data flow task
created oledb source
I put this statemnt in oraquery expression - "select * from dept where dept in "
+ @[User::empid] + "
expression=true
[OLE DB Source [1]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14.
An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80040E14 Description: "ORA-00936: missing expression".
Approach-2
created three variables - oraquery string, empid int, loop object--when I put int then it is automatically setting to 0
step1 - ms sql database - created sql task - SELECT DISTINCT convert(varchar(10),empid ) empid FROM emp
resultset=fullresult
resultset=resultname=0; variablename=User::loop
step2 - created a for each loop container
for loop editor - for each ado ennumerator
enumerator configuration - loop
variablemapping - variable=empid;index=0
step3 - oracle database - created data flow task (outside for each loop. If I put inside it is taking long time)
created oledb source
I put this statemnt in oraquery expression - "select * from dept where dept in "
+ @[User::empid] + "
expression=true
Data inserting in a destination table but empid=0.Sorry didnt understand if your step3 is outside loop how
@[User::empid] will get values for the empids from User::loop. The iteration happens inside loop so you
need to have a logic to form the delimited list inside using a script task or something and concatenating everything and storing to variable @[User::empid]
. Then only it will have full value used to be used in step3 query
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
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!! -
DB Adaptor and inserting dates into Oracle DB
Hi,
I'm using the Oracle DB Adaptor to poll a table in one instance (using logical delete) and to invoke a DB adaptor to insert/merge a row into a separate instance.
NOTE :both tables have different definitions.
I am using a BPEL transform to tfrm the data received from the poll/receive step.
I need to transform some date variables and the target date column CreatedTs is expecting to receive the date in the Oracle DD-MON-YYYY format (can't change the NLS_DATE_FORMAT value for the target).
I'm trying to use the provided xsl:formatDateTime function with various formats but can't get anything useful to work.
Any ideas ?Hi there,
Please see the Bpel developer's guide at otn.oracle.com/bpel. There are two troubleshooting entries of interest:
dateTime Conversion Exceptions
and
Issues with Oracle DATE
Just search on these strings.
The xsl:formatDateTime function is for converting xs:dateTimes to strings. If you already have a value in proper ISO dateTime format do not try to convert it. The database adapter likes that format only.
If you are starting with a string like DD-MON-YYYY and have to convert it into a legal dateTime, then that is hard as functions like xsl:formatDateTime go the opposite way only, i.e. dateTime to string, not string to dateTime.
A few days we had a customer who needed to convert MM/DD/YYYY to a dateTime. I am copying the solution here.
Used the expression builder in the assign to build:
orcl:format-string('{0}-{1}-{2}T00:00:00', substring(bpws:getVariableData('Receive_1_receive_InputVariable','ReceiverDeptCollection','/ns2:ReceiverDeptCollection/ReceiverDept/receiverEmpCollection/ReceiverEmp/someDate'), 7, 4), substring(bpws:getVariableData('Receive_1_receive_InputVariable','ReceiverDeptCollection','/ns2:ReceiverDeptCollection/ReceiverDept/receiverEmpCollection/ReceiverEmp/someDate'), 4, 2), substring(bpws:getVariableData('Receive_1_receive_InputVariable','ReceiverDeptCollection','/ns2:ReceiverDeptCollection/ReceiverDept/receiverEmpCollection/ReceiverEmp/someDate'), 1, 2))
That worked in converting i.e. 01/05/2005 to 2005-01-05T00:00:00.
To convert DD-MON-YYYY that is tricky because you need to first convert DEC to 12, SEP to 09, and so on. I couldn't figure out how to do that but another on this forum may be able to help you out. If you are really stuck and you know the database accepts i.e DD-MON-YYYY, you could tell the adapter that the date field is a string, then it will simply pass the value as is which should work.
To do that please see chapter 20 of the bpel dev guide, and search for
Configuring Offline Database Tables
Use that to change the type to basic varchar2 in the BPEL designer so the dbadapter will think the column is a string and not convert it.
Thanks
Steve -
Re: Insert data into oracle database using a PHP form
Hai its different for me, i want to display a data based on the input from php form. I see and trying your script but it didn't work.
<?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;
$data=$_POST;
stripslashes($data);
// Select statement
$query = "SELECT * FROM animal WHERE skin=$data";
// connect to Oracle
$username = "xxxxxx";
$paswd = "xxxxxx";
$dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
"(HOST=yyyyyyyy)(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);
$stmt = OCIParse ($db_conn, $sql);
OCIBindByName ($stmt, ":name", &$data, -1);
OCIExecute ($stmt);
OCIFreeStatement($stmt);
OCILogoff ($db_conn);
?>
Could you please advice me ? whats wrong with that script ?What is the error you get? What solutions have you tried already?
-
Insert data into oracle table from XML script not working
Hi,
I wrote simple PL/SQL program to extract values from a XML file and disply all the employee names. But the first employee name repeating. Please can you tell me how to fix it.
set serveroutput on size 2000;
declare
indoc VARCHAR2(2000);
indomdoc dbms_xmldom.domdocument;
innode dbms_xmldom.domnode;
myParser dbms_xmlparser.Parser;
l_nl dbms_xmldom.DOMNodeList;
lv_value varchar2(30);
l_n dbms_xmldom.DOMNode;
begin
indoc := '<emp> <name> Scott </name>
<name> Tiger </name>
</emp>';
myParser := dbms_xmlparser.newParser;
dbms_xmlparser.parseBuffer(myParser, indoc);
indomdoc := dbms_xmlparser.getDocument(myParser);
innode := dbms_xmldom.makeNode(indomdoc);
l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(indomdoc),'/emp/name');
dbms_output.put_line('Record count '||dbms_xmldom.getLength(l_nl));
FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
l_n := dbms_xmldom.item(l_nl, cur_emp);
lv_value := dbms_xslprocessor.valueOf(l_n,'//name/text()');
dbms_output.put_line('Emp Name : '||lv_value);
END LOOP;
end;
/Based on an earlier example of mine from {message:id=2826611}
This works in 10.2.x.x for sure. I can't recall (didn't look up) whether in 10.1 it allowed for going straight from a CLOB to a DOMDocument via newDomDocument.
declare
indoc VARCHAR2(2000);
indomdoc dbms_xmldom.domdocument;
l_nl dbms_xmldom.DOMNodeList;
lv_value VARCHAR2(30);
l_n dbms_xmldom.DOMNode;
l_xmltype XMLTYPE;
l_index PLS_INTEGER;
begin
indoc := '<emp> <name> Scott </name>
<name> Tiger </name>
</emp>';
indomdoc := dbms_xmldom.newDomDocument(indoc);
l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(indomdoc),'/emp/name');
dbms_output.put_line('Record count '||dbms_xmldom.getLength(l_nl));
-- Method 1
FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
l_n := dbms_xmldom.item(l_nl, cur_emp);
lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_n));
dbms_output.put_line('Emp Name : '||lv_value);
END LOOP;
dbms_xmldom.freeDocument(indomdoc);
-- Method 2
dbms_output.new_line;
l_xmltype := XMLTYPE(indoc);
l_index := 1;
WHILE l_xmltype.Existsnode('/emp/name[' || To_Char(l_index) || ']') > 0
LOOP
lv_value := l_xmltype.extract('/emp/name[' || To_Char(l_index) || ']/text()').getStringVal();
dbms_output.put_line('Emp Name : '||lv_value);
l_index := l_index + 1;
END LOOP;
end; -
Hi All,
I am trying to insert data into oracle 9i temp tables using the following style. but getting error as
ERROR at line 3
ORA-00933 SQL command not properly ended
Please assist me.
INSERT INTO emp (empname,empno)
SELECT *
FROM XMLTABLE (
'/EMP/CODE'
PASSING xmltype (BFILENAME ('test_dir', 'emp.xml'), NLS_CHARSET_ID ('CHAR_CS'))
COLUMNS empname VARCHAR (30) path 'empname',
empno VARCHAR (30) path 'empno')
MY emp.xml is
<?xml version="1.0" encoding="AR8ISO8859P6"?>
<EMP>
<CODE>
<EMPNAME>YALEXFBARK044</EMPNAME>
<EMPNO>803926354086</EMPNO>
</CODE>
<CODE>
<EMPNAME>YALEXFOLV0044</EMPNAME>
<EMPNO>803926354109</EMPNO>
</CODE>
<CODE>
<EMPNAME>YALEXFREDTT44</EMPNAME>
<EMPNO>803926354093</EMPNO>
</CODE>
<EMP>>
Oracle version: 8i - 9.0.x.x
There was no option that I can recall or could find. All the parsing of XML that I've done in 8i was via the xmldom package.
Oracle version: 9.2.x.x - 10.1.x.x
This is were Oracle introduced extract, extractValue and TABLE(XMLSequence(extract())) for dealing with repeating nodes.
Oracle version: 10.2.x.x
Oracle introduced XMLTable as a replacement for the previous methods since it could handle all three methods for extracting data from XML. At that point, Oracle stopped enhancing extract/extractValue in terms of performance and focused on XMLTable. In 10.2.0.1 and .2, XMLTable was implemented via Java and in .3 it was moved into the kernel so performance from .3 onwards should be better than the older 9.2 / 10.1 methods. If not, feel free to open a ticket with Oracle support. Apparently Oracle also introduced XMLQuery as well but I've never heard of many using that in 10.2
>
from Methods to parse XML per Oracle version
so use correct way for your oracle version -
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. -
Steps to insert xml data into oracle
Please give me next steps to insert xml data into oracle 9i:
i've been doing this steps :
1. create folder in oracle port:8080
2. copy xsd into folder
3. register schema
4. Give me next step...
5.
6.
Thanksthis is my complete xmlschema
<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">
<xs:element name = "A3A8Vers" type = "xs:string"/>
<xs:element name = "F1F5Vers" type = "xs:string">
</xs:element>
<xs:element name = "sequence" type = "xs:string">
</xs:element>
<xs:element name = "amf" type = "xs:string">
</xs:element>
<xs:element name = "trnsKeyNumber" type = "xs:string">
</xs:element>
<xs:element name = "mac" type = "xs:string">
</xs:element>
<xs:element name = "encryptionKey" type = "xs:string">
</xs:element>
<xs:element name = "signature" type = "xs:string">
</xs:element>
<xs:element name = "signer">
<xs:complexType>
<xs:sequence>
<xs:element ref = "entityNumber"/>
<xs:element ref = "keyNumber"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name = "entityNumber" type = "xs:string">
</xs:element>
<xs:element name = "keyNumber" type = "xs:string">
</xs:element>
<xs:element name = "pblKey">
<xs:complexType>
<xs:sequence>
<xs:element ref = "entityNumber"/>
<xs:element ref = "entityRole"/>
<xs:element ref = "keyNumber"/>
<xs:element ref = "publicKeyVal"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name = "ntrTime" type = "xs:string">
</xs:element>
<xs:element name = "deActionTime" type = "xs:string">
</xs:element>
<xs:element name = "actionTime" type = "xs:string">
</xs:element>
<xs:element name = "entityRole">
<xs:complexType>
<xs:attribute name = "role" default = "INVALID">
<xs:simpleType>
<xs:restriction base = "xs:NMTOKEN">
<xs:enumeration value = "TKD"/>
<xs:enumeration value = "SKD"/>
<xs:enumeration value = "INVALID"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name = "publicKeyVal">
<xs:complexType>
<xs:sequence>
<xs:element ref = "exponent"/>
<xs:element ref = "mod"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name = "exponent" type = "xs:string">
</xs:element>
<xs:element name = "mod" type = "xs:string">
</xs:element>
<xs:element name = "encriptionTransKey" type = "xs:string">
</xs:element>
<xs:element name = "keyType" type = "xs:string">
</xs:element>
</xs:schema>.
I use command to create table :
create table elements of xmltype
xmlschema "http://192.168.1.1:8080/test.xsd"
element "publicKey"
. But why the result,table as object type. so i cant use command "desc <table_name>;" -
How to insert data into local database from oracle server
I am new in C#.
I am trying to design a local database in my C# project and I am trying to sync my database with our oracle server. I can login using oracle server. But I can't insert data into my local database from oracle server.
anybody can help me ...............
thanks..............................You can use SSIS package for that
Start a new Integration Services project in Business Intelligence Development Studio/ SSDT. Add a new SSIS package with a data flow task. Add a OLEDB source to connect to Oracle server and add a OLEDB Destination to connect to your local database.
Select tables for source and destination. On executing package source data will get transferred to your local database.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Maybe you are looking for
-
Mass update of huge list of Material master records
Hi dudes, I want to update 1 field for the huge list of material master record, i.e., statistics field in sales org 2 tab. please help regards, madhav
-
Adobe Reader 9 & Adobe Distiller 6.0
I have a user who has Distiller 6.0 & Reader 9.0 on his laptop. On a specific web site he is trying to download a pdf document, the computer defaults to distiller 6.0 and the web site refuses to open the document, stating that Reader 8.0 or 9.0 canno
-
Calling portal v2 pages with parameters in a jsp
Hello everybody, I'm currently trying to create, in a jsp, a link to a portal-v2 page with parameters. Practically : [JSP / Portlet 1] - a 1st jsp generates some links, all to the same page but each sets a different value to a paramete
-
How do i get my Talk Talk email account loaded onto my IPAD
How do i create a short cut for my Talk Talk email account on my IPAD 2. PS it would help if there was written instructions when you purchase the product.
-
Can I send group e-mails from an IPad?
Can I send group e-mails from an IPad?