Getting clob
A Run-Time error is raised by Visual Studio 2005Prof in my code when reading column of type clob and assigning its value to a std::string.
This is the code:
void GetClob( unsigned int col, std::string & clobStr )
if( resultSet_->isNull( col ) )
return;
oracle::occi::Clob clob = resultSet_->getClob( col );
if( clob.isNull() )
return;
clob.open( oracle::occi::OCCI_LOB_READONLY );
unsigned int clobSize = clob.length();
assert( clobSize > 0 );
clobStr.resize( clobSize );
clob.read( clobSize, (unsigned char *)&clobStr[ 0 ], clobSize );
clob.close();
The VS error occurs when leaving the scope of GetClob method and the message says:
Run-Time Check Failure #2 - Stack around the variable 'clob' was corrupted. I can see that clobStr variable contains the actual correct string.
======================
Even if I reduce the code like this:
void GetClob( unsigned int col, std::string & clobStr )
if( resultSet_->isNull( col ) )
return;
oracle::occi::Clob clob = resultSet_->getClob( col );
if( clob.isNull() )
return;
clob.open( oracle::occi::OCCI_LOB_READONLY );
// unsigned int clobSize = clob.length();
// assert( clobSize > 0 );
// clobStr.resize( clobSize );
// clob.read( clobSize, (unsigned char *)&clobStr[ 0 ], clobSize );
clob.close();
I still get the same error.
Please can you 1) comment on the above code, and/or 2) provide a sample code how reading columns of clob type should be handled?
I can read numeric columns w/o any problems.
I am using WinXP, occi 10.2.0.3.0 with the latest Patch 10 downloaded from here http://www.oracle.com/technology/tech/oci/occi/occidownloads.html.
Thank you for your help! This problem has taken me a lot of time already.
Try the following code sample.
#include <iostream>
#include <fstream>
#include <occi.h>
using namespace oracle::occi;
using namespace std;
* The demo sample has starts from startDemo method. This method is called
* by main. startDemo calls other methods, the supporting methods for
* startDemo are,
* insertRows - insert the rows into the table
* dataRollBack - deletes the inserted rows
* populateClob - populates a given clob
* dumpClob - prints the clob as an integer stream
// These will tell the type of read/write we use
#define USE_NORM 1
#define USE_CHUN 2
#define USE_BUFF 3
/* Buffer Size */
#define BUFSIZE 200;
class occiClob
public:
string username;
string password;
string url;
void insertRows (Connection *conn)
throw (SQLException)
Statement *stmt = conn->createStatement ("INSERT INTO electronic_media(product_id,ad_id,ad_composite,ad_sourcetext) VALUES (:v1,:v2,:v3,:v4)");
Blob blob(conn);
blob.setEmpty();
Clob clob(conn);
clob.setEmpty();
stmt->setInt(1,6666);
stmt->setInt(2,11001);
stmt->setBlob(3,blob);
stmt->setClob(4,clob);
stmt->executeUpdate();
stmt->setSQL ("INSERT INTO electronic_media(product_id,ad_id,ad_composite,ad_sourcetext) VALUES (:v1, :v2, :v3, :v4)");
stmt->setInt(1,7777);
stmt->setInt(2,11001);
stmt->setBlob(3,blob);
stmt->setClob(4,clob);
stmt->executeUpdate();
stmt->setSQL ("INSERT INTO electronic_media(product_id,ad_id,ad_composite,ad_sourcetext) VALUES (:v1, :v2, :v3, :v4)");
stmt->setInt(1,8888);
stmt->setInt(2,11001);
stmt->setBlob(3,blob);
stmt->setClob(4,clob);
stmt->executeUpdate();
conn->commit();
conn->terminateStatement (stmt);
void dataRollBack (Connection *conn)
throw (SQLException)
Statement *stmt = conn->createStatement ("DELETE FROM electronic_media WHERE product_id=6666 AND ad_id=11001");
stmt->executeUpdate();
stmt->setSQL("DELETE FROM electronic_media WHERE product_id=7777 AND ad_id=11001");
stmt->executeUpdate();
stmt->setSQL("DELETE FROM electronic_media WHERE product_id=8888 AND ad_id=11001");
stmt->executeUpdate();
conn->commit();
conn->terminateStatement (stmt);
* populating the clob uses write method;
void populateClob (Clob &clob,unsigned int way)
throw (SQLException)
unsigned int bufsize=BUFSIZE;
if (way == USE_NORM)
cout << "Populating the Clob using write method" << endl;
unsigned int offset=1;
unsigned char *buffer = new unsigned char[bufsize];
strcpy((char *)buffer,
"Just for source text content(added using write method)");
unsigned int size=strlen((char *)buffer);
unsigned int bytesWritten=clob.write (size,buffer, size,offset);
//cout <<"Bytes Written : " << bytesWritten << endl;
delete[] buffer;
else if(way==USE_CHUN)
cout << "Populating the Clob using writeChunk method" << endl;
unsigned int offset=1;
unsigned int pieceCount = 4;
unsigned char *buffer = new unsigned char[bufsize*pieceCount];
strcpy((char *)buffer,
"Just for source text content(added using writeChunk method)");
unsigned int size=strlen((char *)buffer);
// Open the clob for writeChunk
clob.open(OCCI_LOB_READWRITE);
for (int i = 0; i < pieceCount; ++i,offset+=size)
clob.writeChunk(size,buffer,size,offset);
cout << "Clob Size " << clob.length() << endl;
delete[] buffer;
clob.close();
else if(way==USE_BUFF)
// Uses stream here
cout << "Populating the Clob using writeBuffer(Stream) method" << endl;
char file = (char )"clobdemo.dat";
char *buffer = new char[bufsize + 1];
ifstream inFile;
inFile.open(file,ios::in);
if (!inFile)
cout << "clobdemo.dat file not found\n";
delete[] buffer;
return;
unsigned int size;
Stream *strm=clob.getStream();
while(inFile)
memset (buffer, NULL, bufsize + 1);
inFile.read(buffer,bufsize);
strm->writeBuffer(buffer,strlen(buffer));
strcpy(buffer,"This piece for writeLastBuffer");
size=strlen(buffer);
strm->writeLastBuffer(buffer,size);
clob.closeStream(strm);
inFile.close();
delete[] buffer;
cout << "Populating the Clob - Success" << endl;
* printing the clob data as integer stream
void dumpClob (Clob &clob,unsigned int way)
throw (SQLException)
unsigned int size=BUFSIZE;
unsigned int offset = 1;
if (clob.isNull())
cout << "Clob is Null\n";
return;
unsigned int cloblen = clob.length();
cout << "Length of Clob : "<< cloblen << endl;
if (cloblen == 0)
return;
unsigned char *buffer= new unsigned char[size];
memset (buffer, NULL, size);
if (way==USE_NORM)
cout << "Dumping clob (using read ): ";
int bytesRead=clob.read(size,buffer,size,offset);
for (int i = 0; i < bytesRead; ++i)
cout << buffer;
cout << endl;
else if(way==USE_BUFF)
Stream *inStream = clob.getStream (1,0);
cout << "Dumping clob(using stream): ";
int bytesRead=(inStream->readBuffer((char *)buffer, size));
while (bytesRead > 0)
for (int i = 0; i < bytesRead; ++i)
cout << buffer[i];
bytesRead=(inStream->readBuffer((char *)buffer, size));
cout << endl;
clob.closeStream (inStream);
delete []buffer;
occiClob ()
* default values of username & password
username = "HR";
password = "HR";
url = "";
void setUsername (string u)
username = u;
void setPassword (string p)
password = p;
void setUrl (string u)
url = u;
void runSample ()
throw (SQLException)
Environment *env = Environment::createEnvironment (
Environment::DEFAULT);
Connection *conn = env->createConnection (username, password, url);
insertRows (conn);
// Selecting and modifying the clob column of the table
string sqlQuery =
"SELECT product_id,ad_id,ad_sourcetext FROM electronic_media FOR UPDATE";
Statement *stmt1 = conn->createStatement (sqlQuery);
ResultSet *rset1 = stmt1->executeQuery ();
cout << "Query :" << sqlQuery << endl;
unsigned int way=USE_NORM;
while (rset1->next ())
cout << "Product_id : " << (int)rset1->getInt(1) << endl;
cout << "Ad_id : " << (int)rset1->getInt(2) << endl;
Clob clob = rset1->getClob (3);
dumpClob (clob, USE_NORM);
if (way==USE_NORM)
populateClob(clob,USE_NORM);
way=USE_CHUN;
else if(way==USE_CHUN)
populateClob(clob,USE_CHUN);
way=USE_BUFF;
else if(way==USE_BUFF)
populateClob(clob,USE_BUFF);
way=USE_NORM;
stmt1->executeUpdate();
stmt1->closeResultSet (rset1);
// Printing after updating the clob content.
way = USE_BUFF;
sqlQuery = "SELECT product_id, ad_id, ad_sourcetext FROM electronic_media \
ORDER BY product_id";
Statement *stmt2 = conn->createStatement (sqlQuery);
ResultSet *rset2 = stmt2->executeQuery ();
cout << "Query :" << sqlQuery << endl;
while (rset2->next ())
cout << "Product_id : " << (int)rset2->getInt(1) << endl;
cout << "Ad_id : " << (int)rset2->getInt(2) << endl;
Clob clob = rset2->getClob (3);
if (way==USE_NORM)
dumpClob (clob, USE_NORM);
way=USE_BUFF;
else if(way==USE_BUFF)
dumpClob (clob, USE_BUFF);
way=USE_NORM;
stmt2->closeResultSet (rset2);
dataRollBack(conn);
conn->terminateStatement (stmt1);
conn->terminateStatement (stmt2);
env->terminateConnection (conn);
Environment::terminateEnvironment (env);
};//end of class occiClob
int main (void)
try
occiClob *b = new occiClob ();
b->setUsername ("HR");
b->setPassword ("HR");
b->runSample ();
catch (exception &e)
cout << e.what();
Similar Messages
-
Hi all
iam using oracle9i and i changing our applications from mysql to oracle .
this is my java for mysql
ObjectInputStream in =
new ObjectInputStream(
rs.getBinaryStream("filterObject"));
but now for oracle i have to change the data type of filterObject to clob and bcoz of this i am getting null pointer exception. I have converted the clob type to string
by
String str=rs.getClob("filterObject").getSubString(1,(int)(rs.getClob("filterObject").length()));
but still iam not able to convert into binary stream type
So can any one help me in fixing this problem
Thanking you in advance
dinnyCheck out the O'Reilly book "Java Programming with Oracle JDBC," by Donald Bales. I also saw promising entries on asktom.oracle.com when I searched for jdbc and lob.
Good luck. -
oracle is 8.1.6, my jdbc is /home/oracle/OraHome1/jdbc/lib/classes111.zip
my table test_clob's struction
id int
content clob
While I run my class, it report:
Exception in thread "main" java.lang.AbstractMethodError
at ...(Oracle_clob.java:72)
the error line is:
Clob clob = result.getClob(2);
the code is :
import java.sql.*;
import java.io.*;
import java.util.*;
public class Oracle_clob
public static void main(String[] args)
Connection con = null;
int iRowCount = 0;
Statement stmt = null;
ResultSet result = null;
String sDriver = "oracle.jdbc.driver.OracleDriver";
String sURL = "jdbc:oracle:oci8:@orcl";
String sUsername = "sj";
String sPassword = "sj";
try // Attempt to load the JDBC driver
{ // with newInstance
Class.forName( sDriver ).newInstance();
catch( Exception e ) // error
System.err.println(
"Failed to load current driver.");
return;
} // end catch
try
con = DriverManager.getConnection ( sURL,
sUsername,
sPassword);
stmt = con.createStatement();
catch ( Exception e)
System.err.println( "problems connecting to " +
sURL + ":" );
System.err.println( e.getMessage() );
if( con != null)
try { con.close(); }
catch( Exception e2 ) {}
return;
} // end catch
try {
String ls_sql;
ls_sql = "select id, content from test_clob";
result = stmt.executeQuery(ls_sql);
String ls_field=null;
if (result == null) {
System.out.print("result is null");
return ;
if(result.next()){
Clob clob = result.getClob(2);
Reader char_stream = clob.getCharacterStream();
char[] buffer = new char[1024];
int length = 0;
ls_field = "";
String ls_newString;
try{
while((length=char_stream.read(buffer))!=-1){
//for(int i=0; i<length; i++){
ls_newString = String.valueOf(buffer);
ls_field = ls_field + ls_newString;
char_stream.close();
catch( Exception e3 ) {
System.out.print("error: "+ e3.getMessage());
else
System.out.print("next is false");
if (ls_field== null ) ls_field = "";
System.out.print(" field: "+ ls_field);
result.close();
catch(SQLException ex) {
System.out.print("aq.executeQuery: " + ex.getMessage());
finally
try { stmt.close(); }
catch( Exception e ) {}
try { con.close(); }
catch( Exception e ) {}
} // end finally clause
} // end main
} // end class Create4JData
What's wrong with it? Thank you advance.getClob is supported by JDBC2.0 which is not supported by classes111.zip. Get the classes12.zip and the corresponding OCI driver by installing oracle client update.
-
Getting CLOB fron Database then creating a CSV File
Hi,
I am trying to read a CLOB for the DB in my Backing Bean with the help of EJB.
The code in my backing bean is:
char[] strReportContent = reportObj.getReportText();The API where the accessors for getReportText() is;
@Lob
@Column(name="REPORT_TEXT")
public char[] getReportText()
return reportText;
public void setReportText(char[] reportText)
this.reportText = reportText;
}The problem is that when I do a system out on strReportContent I get a garbage value and not what is in the DB.
Please Help.
Then to render it on the CSV the code is:
// Init servlet response.
response.reset();
response.setContentType("plain/text");
// response.setContentLength(input.available());
response.setHeader("Content-disposition",
"inline; filename=\"" + selectedReportId.getReportName() + "\"");
output =
new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);
char[] strReportContent = reportObj.getReportText();
output.write(strReportContent.toString().getBytes(), 0, strReportContent.length);Hi,
I am not removing any zeroes . I created the same file in .txt format and XI was able to write the value 008.2010 to the txt file.
I suppose this has somehting to do with excel file properties . By default when we add 008.2010 in the excel sheet , it takes only 8.201. We need to change the format to "text" manually in the excel file to take in zeroes as well.
So , i really dont know how to make sure that the excel file properties does not truncate zeroes while XI is creating the CSV file.
Regards
Vinay P. -
How to get CLOB from stored procedure via StoredProcedureCall
hi all
I got "sp" on server : procedure get_text(p_in in varchar2, o_list out clob);
in code:
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("get_text");
call.addNamedArgumentValue("p_in", new String("MyList"));
call.addNamedOutputArgument("o_list"); // <- out CLOB
Vector v = (Vector)this.m_UnitOfWorkt.executeSelectingCall( call ); // <- here I got error
but if o_list is varchar is all ok
so how to get data from clob?
Please help
Regards
KrzysztofPost Author: achaithanya
CA Forum: Data Connectivity and SQL
I'm connecting to database through stored procedure only.We have sybase installed on our local system so that we are given permissions only to access the stored procedures.When u see the fields in CR XI i.e Field explorer you are able to see only 1st result fileds.I connected to sybase and there i'm able to see the output of 1st & 2nd Result set.
Regards,
Chaithanya. -
Anyone get CLOB.createTemporary to work in WebLogic w/ Ora 9.0.1?
I've got code that works in java for temporary CLOB in Oracle 9.0.1. It works using JDBC Client API or Oracle connection pooling. But when I deploy to WebLogic App Server, I get
"java.lang.reflect.InvocationTargetException null" on the statement:
myClob = CLOB.createTemporary(conn, false, CLOB.DURATION_SESSION);
I read that temporary clob was an Oracle extension. That would lead one to believe that WebLogic may not support it. And I tried tweeking classpath/path to use Oracle's jars first, etc. I've also tried different ways of connecting: JDBC Client, straight RMI, and JNDI lookups, trying to get around "WebLogic"... Is this a losing battle and do I have to modifiy my code to use the EMPTY_CLOB() functions, or has someone gotten this to work? THANKS!I've talked with BEA on this issue. They say that the CLOB.createTemporary() method signature indicates that it takes a
generic JDBC object, but it in fact takes an Oracle-specific object. They say "Oracle is lying to us" and say that
as a result, my code will not work if using a WebLogic Connection Pool. I realize the risks of using vendor-specific
extension methods, but I would think that if I configure the WL app server to use the oracle classes12.zip and put it in
front of CLASSPATH, etc. that this would work. It does not, with the BEA reason stated above. I really like this
CLOB.createTemporary method and refuse to change my code. Any words of wisdom, especially from an
Oracle insider? Thanks!
I've got code that works in java for temporary CLOB in Oracle 9.0.1. It works using JDBC Client API or Oracle connection pooling. But when I deploy to WebLogic App Server, I get
"java.lang.reflect.InvocationTargetException null" on the statement:
myClob = CLOB.createTemporary(conn, false, CLOB.DURATION_SESSION);
I read that temporary clob was an Oracle extension. That would lead one to believe that WebLogic may not support it. And I tried tweeking classpath/path to use Oracle's jars first, etc. I've also tried different ways of connecting: JDBC Client, straight RMI, and JNDI lookups, trying to get around "WebLogic"... Is this a losing battle and do I have to modifiy my code to use the EMPTY_CLOB() functions, or has someone gotten this to work? THANKS! -
Filling clob with non ascii characters
Hello,
I have had some problems with clobs and usage of german
umlauts (����). I was'nt able to insert or update
strings containing umlaute in combination with string
binding. After inserting or updating the umlaut
characters were replaced by strange (spanish) '?'
which were upside down.
However, it was working when I did not use string bindung.
I tried varios things, after some time I tracked
the problem down to to oracle.toplink.queryframework.SQLCall.java. In the
prepareStatement(...) you find something
like
ByteArrayInputStream inputStream = new ByteArrayInputStream(((String) parameter).getBytes());
// Binding starts with a 1 not 0.
statement.setAsciiStream(index + 1, inputStream,((String) parameter).getBytes().length);
I replaced the usage of ByteArrayInputStram with CharArrayReader:
// TH changed, 26.11.2003, Umlaut will not work with this.
CharArrayReader reader = new CharArrayReader(((String) parameter).toCharArray());
statement.setCharacterStream(index + 1, reader, ((String) parameter).length() );
and this worked.
Is there any other way achieving this? Did anyone
get clobs with non ascii characters to work?
Regards -- Tobias
(Toplink 9.0.3, Clob was mapped to String, Driver was Oracle OCI)I don't think the console font is the problem. I use Lat2-Terminus16 because I read the Beginner's Guide on the wiki while installing the system.
My /etc/vconsole.conf:
KEYMAP=de
FONT=Lat2-Terminus16
showconsolefont even shows me the characters missing in the file names; e.g.: Ö, Ä, Ü -
I am having trouble retrieving a clob locator from a column despite being able to set it in a previous statement. The clob is always returned as null.
This happens to both an 8.1.6 and 8.1.7 with the latest classes12.zip
Thanks,
-elliott
Here is my code snippet:
oracle.sql.CLOB clob = null;
// Select LOB locator into standard result set.
StringBuffer sSelect = new StringBuffer();
sSelect.append("SELECT " + mercColName + " FROM BUG" + whereClause.toString() + "FOR UPDATE");
debug.println("Get Clob: " + sSelect.toString());
ResultSet rs =
stmt.executeQuery(sSelect.toString());
while (rs.next()) {
// Get LOB locator into Java wrapper classes.
try {
clob = (oracle.sql.CLOB) rs.getClob(1);
catch (Exception ex) {
//do nothing
if (clob == null)
//update row
StringBuffer sUpdateClob = new StringBuffer();
sUpdateClob.append("UPDATE BUG SET " + mercColName + " = (empty_clob()) " + whereClause.toString());
debug.println("Update Clob: " + sUpdateClob.toString());
stmt.execute(sUpdateClob.toString());
m_DelayConnection.commit();
ResultSet rs2 =
stmt.executeQuery(sSelect.toString());
while (rs2.next()) {
// Get LOB locator into Java wrapper classes.
clob = (oracle.sql.CLOB) rs2.getObject(1);
java.io.Writer writer;
// read data into a character array
char[] data = pval.toCharArray();
// write the array of character data to a CLOB
writer = clob.getCharacterOutputStream();Found the problem. I was using the ODBC driver instead of the JDBC driver.
-
Hi
I am trying to use Stragg and merge a clob .
requirement is
Tables": EMPL_HDR, EMPL-EDU, EMPL-CERT, EMPL-EMPLMNT-HISTORY, EMPL-CLEARANCE, EMPL-MIL-SVC etc
there is a hdr_seq that is carried over to all the tables. At the end of the job, for reporting purposes, we want all relevant data for the employee to be put in one relevant column.
for eg:
EMPL_ID HDR_SEQ EDU_CLOB DEGREE UNIVERSITY GRADUATION_DT
1 987654 226
2 514275 266 BA in Communications from Penn State University on 05-27-1986 BA Penn State University 27-MAY-86
3 526541 270 High School Diploma on 06-27-1976 High School Diploma 27-JUN-76
6 526734 321 MS in Information Systems from SU on 06-25-1998 MS SU 25-JUN-98
I can build this using varchar2(4000) in stragg
select distinct a.empl_id, a.hdr_seq,
stragg(degree_type || decode (discipline,NULL,NULL, ' in ' || discipline)
|| decode( University, NULL,NULL,' from ' || University )
|| decode(graduation_dt, NULL,NULL,' on ' || to_char(graduation_dt ,'MM-DD-YYYY'))
) over ( partition by a.hdr_seq) as edu_clob ,
stragg(degree_type)over ( partition by a.hdr_seq)as degree ,
stragg(university) over ( partition by a.hdr_seq) as University ,
stragg ( graduation_dt) over ( partition by a.hdr_seq) as graduation_dt
from rw_edu a,kj_hdr b where a.hdr_seq =b.hdr_seq
But when I use CLOB instead of Varchar2, I get ORA-00932 error - expect - getting CLOB.
As for STRAGG - I used the one from AskTom
http://www.sqlsnippets.com/en/topic-11591.html
I was intending to use this in MERGE and write to the table from within a procedure/function to be called from informatica every night as a part of a batch.
Tried few different ways and saw stragg with Merge is good. Also - Can I use MERGE with Clob too?
The Merge that I tried was
merge into kj_hdr K
using (
select distinct a.empl_id, a.hdr_seq,
stragg(degree_type || decode (discipline,NULL,NULL, ' in ' || discipline)
|| decode( University, NULL,NULL,' from ' || University )
|| decode(graduation_dt, NULL,NULL,' on ' || to_char(graduation_dt ,'MM-DD-YYYY'))
) over ( partition by a.hdr_seq) as edu_clob
from rw_edu a,kj_hdr b where a.hdr_seq =b.hdr_seq ) r
on ( K.hdr_Seq = r.hdr_seq )
when matched then update set K.edu_clob = r.edu_clob
where edu_clob is a clob field. edu_all is a varchar2(4000)
Thank You for your timeHi Frank
Enclosing the SQL for the tables & few records.
KJ_HDR , RW_CERT (0:M certs for any hdr_seq and some fields may be null), RW_EDU (0:M edu info )
every night, i need to append this 'beautified' data into the CLOB which will be used for reports.
At the end, I am enclosing SQL that i tried to do this with CLOBAGG & MERGE using DBMS_CRYPTO. I can loop through in cursor and update the CLOB too I guess..
create table KJ_HDR
hdr_seq NUMBER not null,
empl_id VARCHAR2(12) not null,
eff_st_dt DATE,
place_of_birth VARCHAR2(200),
create_dt DATE,
mobility_status_type VARCHAR2(50),
mobility_avail_dt VARCHAR2(35),
edu_all VARCHAR2(4000),
edu_clob CLOB,
cert_clob CLOB
alter table KJ_HDR
add constraint KJ1 unique (HDR_SEQ)
using index;
create table RW_CERT
cert_seq NUMBER not null,
hdr_seq NUMBER,
empl_id VARCHAR2(12),
eff_st_dt DATE,
cert_type VARCHAR2(75),
cert_name VARCHAR2(100),
cert_flag VARCHAR2(1) default 'Y',
cert_dt DATE,
create_dt DATE
alter table RW_CERT
add constraint RW_CERT_PK primary key (CERT_SEQ)
using index;
create table RW_EDU
edu_seq NUMBER not null,
hdr_seq NUMBER,
empl_id VARCHAR2(12),
degree_type VARCHAR2(50),
discipline VARCHAR2(100),
other VARCHAR2(100),
university VARCHAR2(150),
graduation_dt DATE,
create_dt DATE,
eff_st_dt DATE
alter table RW_EDU
add constraint RW_EDU primary key (EDU_SEQ)
using index;
-- data for kj_hdr
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (321,
'567890',
to_date('02/29/2012 00:00','mm/dd/yyyy hh24:mi'),
'Las Vegas, NV, USA',
to_date('02/29/2012 06:11','mm/dd/yyyy hh24:mi'),
'Not looking at this time',
'NA');
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (2,
'777555',
to_date('01/19/2012 00:00','mm/dd/yyyy hh24:mi'),
'Worcester',
to_date('01/19/2012 23:42','mm/dd/yyyy hh24:mi'),
Null,
Null);
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (3,
'526577',
to_date('01/19/2012 00:00','mm/dd/yyyy hh24:mi'),
'Lowel',
to_date('01/19/2012 23:42','mm/dd/yyyy hh24:mi'),
Null,
Null);
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (4,
'622123',
to_date('01/19/2012 00:00','mm/dd/yyyy hh24:mi'),
'India',
to_date('01/19/2012 23:42','mm/dd/yyyy hh24:mi'),
Null,
Null);
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (302,
'568193',
to_date('02/28/2012 00:00','mm/dd/yyyy hh24:mi'),
Null,
to_date('02/28/2012 10:28','mm/dd/yyyy hh24:mi'),
'Not looking at this time',
'NA');
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (270,
'123456',
to_date('02/27/2012 00:00','mm/dd/yyyy hh24:mi'),
Null,
to_date('02/27/2012 14:04','mm/dd/yyyy hh24:mi'),
'Not looking at this time',
'NA');
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (266,
'514275',
to_date('02/27/2012 00:00','mm/dd/yyyy hh24:mi'),
Null,
to_date('02/27/2012 13:55','mm/dd/yyyy hh24:mi'),
'Not looking at this time',
'NA');
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (272,
'345234',
to_date('02/27/2012 00:00','mm/dd/yyyy hh24:mi'),
Null,
to_date('02/27/2012 16:37','mm/dd/yyyy hh24:mi'),
'Not looking at this time',
'NA');
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (269,
'836989',
to_date('02/27/2012 00:00','mm/dd/yyyy hh24:mi'),
'Phoenix, Arizona, US',
to_date('02/27/2012 14:03','mm/dd/yyyy hh24:mi'),
'Not looking at this time',
'NA');
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (273,
'712712',
to_date('02/27/2012 00:00','mm/dd/yyyy hh24:mi'),
'Overbrook, Pennsylvania, USA',
to_date('02/27/2012 16:40','mm/dd/yyyy hh24:mi'),
'Not looking at this time',
'NA');
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (144,
'123456',
to_date('02/14/2012 00:00','mm/dd/yyyy hh24:mi'),
'MA',
to_date('02/14/2012 13:05','mm/dd/yyyy hh24:mi'),
'A',
'A');
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (226,
'987654',
to_date('02/24/2012 00:00','mm/dd/yyyy hh24:mi'),
Null,
to_date('02/24/2012 14:57','mm/dd/yyyy hh24:mi'),
'Not looking at this time',
'NA');
insert into KJ_HDR (
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
PLACE_OF_BIRTH,
CREATE_DT,
MOBILITY_STATUS_TYPE,
MOBILITY_AVAIL_DT ) values (1,
'584949',
to_date('01/19/2012 00:00','mm/dd/yyyy hh24:mi'),
'Bankok',
to_date('01/19/2012 00:00','mm/dd/yyyy hh24:mi'),
Null,
Null);
-- insert into RW_CERT
insert into RW_CERT (
CERT_SEQ,
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
CERT_TYPE,
CERT_NAME,
CERT_FLAG,
CERT_DT,
CREATE_DT) values (245,
272,
'345234',
to_date('02/27/2012 00:00','mm/dd/yyyy hh24:mi'),
'ITIL',
'v3: Foundation',
Null,
to_date('10/01/2009 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/27/2012 16:38','mm/dd/yyyy hh24:mi'),
insert into RW_CERT (
CERT_SEQ,
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
CERT_TYPE,
CERT_NAME,
CERT_FLAG,
CERT_DT,
CREATE_DT) values (242,
272,
'345234',
to_date('02/27/2012 00:00','mm/dd/yyyy hh24:mi'),
'Microsoft',
'Microsoft Certified Systems Engineer (MCSE)',
Null,
to_date('01/01/1994 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/27/2012 16:37','mm/dd/yyyy hh24:mi'),
insert into RW_CERT (
CERT_SEQ,
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
CERT_TYPE,
CERT_NAME,
CERT_FLAG,
CERT_DT,
CREATE_DT) values (281,
341,
'988999',
to_date('02/29/2012 00:00','mm/dd/yyyy hh24:mi'),
'American Society for Quanlity',
'Biomedical Auditor',
Null,
to_date('01/01/1950 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/29/2012 15:09','mm/dd/yyyy hh24:mi'),
insert into RW_CERT (
CERT_SEQ,
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
CERT_TYPE,
CERT_NAME,
CERT_FLAG,
CERT_DT,
CREATE_DT) values (282,
341,
'988999',
to_date('02/29/2012 00:00','mm/dd/yyyy hh24:mi'),
'Human Resources',
'Global Professional in Human Resources (GPHR)',
Null,
to_date('05/01/1950 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/29/2012 15:09','mm/dd/yyyy hh24:mi'),
insert into RW_CERT (
CERT_SEQ,
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
CERT_TYPE,
CERT_NAME,
CERT_FLAG,
CERT_DT,
CREATE_DT) values (243,
272,
'345234',
to_date('02/27/2012 00:00','mm/dd/yyyy hh24:mi'),
'PMI',
'(PMP) Project Management Professional',
Null,
to_date('07/01/2007 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/27/2012 16:38','mm/dd/yyyy hh24:mi'),
insert into RW_CERT (
CERT_SEQ,
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
CERT_TYPE,
CERT_NAME,
CERT_FLAG,
CERT_DT,
CREATE_DT) values (283,
341,
'988999',
to_date('02/29/2012 00:00','mm/dd/yyyy hh24:mi'),
'CISSP',
Null,
'1',
to_date('02/01/1950 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/29/2012 15:09','mm/dd/yyyy hh24:mi'),
insert into RW_CERT (
CERT_SEQ,
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
CERT_TYPE,
CERT_NAME,
CERT_FLAG,
CERT_DT,
CREATE_DT) values (284,
341,
'988999',
to_date('02/29/2012 00:00','mm/dd/yyyy hh24:mi'),
'COMP TIA',
'CompTIA CTP+',
Null,
to_date('06/01/1950 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/29/2012 15:09','mm/dd/yyyy hh24:mi'),
insert into RW_CERT (
CERT_SEQ,
HDR_SEQ,
EMPL_ID,
EFF_ST_DT,
CERT_TYPE,
CERT_NAME,
CERT_FLAG,
CERT_DT,
CREATE_DT) values (244,
272,
'345234',
to_date('02/27/2012 00:00','mm/dd/yyyy hh24:mi'),
'Six Sigma',
'Green Belt',
Null,
to_date('01/01/2010 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/27/2012 16:38','mm/dd/yyyy hh24:mi'),
-- insert into RW_EDU
insert into RW_EDU (
EDU_SEQ,
HDR_SEQ,
EMPL_ID,
DEGREE_TYPE,
DISCIPLINE,
OTHER,
UNIVERSITY,
GRADUATION_DT,
CREATE_DT,
EFF_ST_DT) values (229,
270,
'123456',
'High School Diploma',
Null,
Null,
Null,
to_date('06/27/1976 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/27/2012 14:04','mm/dd/yyyy hh24:mi'),
insert into RW_EDU (
EDU_SEQ,
HDR_SEQ,
EMPL_ID,
DEGREE_TYPE,
DISCIPLINE,
OTHER,
UNIVERSITY,
GRADUATION_DT,
CREATE_DT,
EFF_ST_DT) values (281,
321,
'567890',
'MS',
'Information Systems',
Null,
'SU',
to_date('06/25/1998 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/29/2012 06:11','mm/dd/yyyy hh24:mi'),
insert into RW_EDU (
EDU_SEQ,
HDR_SEQ,
EMPL_ID,
DEGREE_TYPE,
DISCIPLINE,
OTHER,
UNIVERSITY,
GRADUATION_DT,
CREATE_DT,
EFF_ST_DT) values (233,
272,
'345234',
'MBA',
'Business',
Null,
'UMUC',
Null,
to_date('02/27/2012 16:37','mm/dd/yyyy hh24:mi'),
insert into RW_EDU (
EDU_SEQ,
HDR_SEQ,
EMPL_ID,
DEGREE_TYPE,
DISCIPLINE,
OTHER,
UNIVERSITY,
GRADUATION_DT,
CREATE_DT,
EFF_ST_DT) values (287,
327,
'836989',
'BS',
'Journalism',
Null,
'University of Maryland College Park',
to_date('05/01/1987 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/29/2012 11:34','mm/dd/yyyy hh24:mi'),
insert into RW_EDU (
EDU_SEQ,
HDR_SEQ,
EMPL_ID,
DEGREE_TYPE,
DISCIPLINE,
OTHER,
UNIVERSITY,
GRADUATION_DT,
CREATE_DT,
EFF_ST_DT) values (234,
272,
'345234',
'MS',
'Public Policy',
Null,
'Georgetown University',
Null,
to_date('02/27/2012 16:37','mm/dd/yyyy hh24:mi'),
insert into RW_EDU (
EDU_SEQ,
HDR_SEQ,
EMPL_ID,
DEGREE_TYPE,
DISCIPLINE,
OTHER,
UNIVERSITY,
GRADUATION_DT,
CREATE_DT,
EFF_ST_DT) values (225,
266,
'514275',
'BA',
'Communications',
Null,
'Penn State University',
to_date('05/27/1986 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/27/2012 13:55','mm/dd/yyyy hh24:mi'),
insert into RW_EDU (
EDU_SEQ,
HDR_SEQ,
EMPL_ID,
DEGREE_TYPE,
DISCIPLINE,
OTHER,
UNIVERSITY,
GRADUATION_DT,
CREATE_DT,
EFF_ST_DT) values (235,
272,
'345234',
'BS',
'Foreign Service',
Null,
'Georgetown University',
Null,
to_date('02/27/2012 16:37','mm/dd/yyyy hh24:mi'),
insert into RW_EDU (
EDU_SEQ,
HDR_SEQ,
EMPL_ID,
DEGREE_TYPE,
DISCIPLINE,
OTHER,
UNIVERSITY,
GRADUATION_DT,
CREATE_DT,
EFF_ST_DT) values (236,
273,
'712712',
'BS',
'Mechanical Engineering',
Null,
'University of California, Davis',
to_date('06/27/1977 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/27/2012 16:40','mm/dd/yyyy hh24:mi'),
insert into RW_EDU (
EDU_SEQ,
HDR_SEQ,
EMPL_ID,
DEGREE_TYPE,
DISCIPLINE,
OTHER,
UNIVERSITY,
GRADUATION_DT,
CREATE_DT,
EFF_ST_DT) values (186,
226,
'987654',
'BM',
'NOTHING ',
Null,
'SOME PLACE',
Null,
to_date('02/24/2012 14:57','mm/dd/yyyy hh24:mi'),
insert into RW_EDU (
EDU_SEQ,
HDR_SEQ,
EMPL_ID,
DEGREE_TYPE,
DISCIPLINE,
OTHER,
UNIVERSITY,
GRADUATION_DT,
CREATE_DT,
EFF_ST_DT) values (301,
341,
'988999',
'BS',
'Computer Science',
Null,
'Western Illinois University',
to_date('12/01/1999 00:00','mm/dd/yyyy hh24:mi'),
to_date('02/29/2012 15:09','mm/dd/yyyy hh24:mi'),
SQL USED to get the CLOB, ALL fields
select distinct empl_id, hdr_seq, dbms_crypto.hash(edu_clob,1)
from
( select a.empl_id, a.hdr_seq ,
clobagg (degree_type || decode (discipline,NULL,NULL, ' in ' || discipline)
|| decode( University, NULL,NULL,' from ' || University )
|| decode(graduation_dt, NULL,NULL,' on ' || to_char(graduation_dt ,'MM-DD-YYYY'))
) over ( partition by a.hdr_seq) as edu_clob
from rw_edu a,kj_hdr b where a.hdr_seq =b.hdr_seq )
merge into kj_hdr K
using (
select distinct empl_id, hdr_seq , edu_clob from ( select a.empl_id, a.hdr_seq,
clobagg (degree_type || decode (discipline,NULL,NULL, ' in ' || discipline)
|| decode( University, NULL,NULL,' from ' || University )
|| decode(graduation_dt, NULL,NULL,' on ' || to_char(graduation_dt ,'MM-DD-YYYY'))
) over ( partition by a.hdr_seq) as edu_clob
from rw_edu a,kj_hdr b where a.hdr_seq =b.hdr_seq )) r
on ( K.hdr_Seq = r.hdr_seq )
when matched then update set K.edu_clob = r.edu_clob
----- I need distinct rows.
Thanks again for the time.
Regards -
Hi All,
Is TEXT_IO can deal with CLOB Data????Here is a sample of how to use the DBMS_LOB package to get CLOB chunks that you have to adapt:
DECLARE
src_lob CLOB;
buffer VARCHAR2(32767);
amt BINARY_INTEGER := 2000;
pos INTEGER := 2147483647;
BEGIN
SELECT clob_col INTO src_lob
FROM lob_table
WHERE key_value = ...;
LOOP
dbms_lob.read (src_lob, amt, pos, buffer);
-- you get there 2000 characters
TEXT_IO.Put( ..., buffer ) ;
pos := pos + amt;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('End of CLOB data');
END;Francois -
ClassCastException: weblogic.jdbc.rmi.SerialResultSet
HI,
I am using WebLogic 6.0 SP2 connection pooling to get CLOB data from Oracle database.
It is working fine to get the connection and get non-CLOB data like string, but
when I retrieve the CLOB column in my program such as, theClob = ((oracle.jdbc.OracleResultSet)
rs).getCLOB(1),
Weblogic throws ClassCastException: weblogic.jdbc.rmi.SerialResultSet, does anybody
experience the same problem ? How can I get around this problem ?
Thanks
JohnHi,
I've got the same error. The only diference is that I read BLOBs out of the table
((oracle.jdbc.OracleResultSet)rset).getBLOB(1) from oracle.jdbc.OracleResultSet).
Best regards,
Kai
"John Chen" <[email protected]> wrote:
>
HI,
I am using WebLogic 6.0 SP2 connection pooling to get CLOB data from
Oracle database.
It is working fine to get the connection and get non-CLOB data like string,
but
when I retrieve the CLOB column in my program such as, theClob = ((oracle.jdbc.OracleResultSet)
rs).getCLOB(1),
Weblogic throws ClassCastException: weblogic.jdbc.rmi.SerialResultSet,
does anybody
experience the same problem ? How can I get around this problem ?
Thanks
John -
Insert Word File in Oracle 8i database
Can any one help me to insert one MS-Word File created thru a VB Application into Oracle Table.
Hi,
u can use pl/sql procedure to insert doc into database
Have a look
store microsoft doc into oracle database by clob
SQL> desc test
Name Null? Type
NO NUMBER
FILE_DATA CLOB
SQL> select * from all_directories;
OWNER DIRECTORY_NAME
DIRECTORY_PATH
SYS DIR_FILE
/oradata4/upd
create or replace procedure doc_insert(file_name varchar2)
as
f_lob bfile;
c_lob clob;
begin
insert into test (no,file_data) values
(1,empty_clob())
return file_data into c_lob;
f_lob := bfilename( 'DIR_FILE', file_name );
dbms_lob.fileopen(f_lob, dbms_lob.file_readonly);
dbms_lob.loadfromfile
( c_lob, f_lob, dbms_lob.getlength(f_lob) );
dbms_lob.fileclose(f_lob);
commit;
end;
Procedure created.
SQL> exec doc_insert('lob_case.doc');
PL/SQL procedure successfully completed.
SQL>
select dbms_lob.getlength(FILE_DATA),file_data from test;
DBMS_LOB.GETLENGTH(FILE_DATA)
FILE_DATA
46592
ÐÏ à¡± á > þÿ V X þÿÿÿ U
================================================
Retrive doc from oracle database
declare
clob_loc CLOB;
buffer VARCHAR2(32767);
buffer_size CONSTANT BINARY_INTEGER := 32767;
amount BINARY_INTEGER;
offset NUMBER(38);
file_handle UTL_FILE.FILE_TYPE;
directory_name CONSTANT VARCHAR2(80) := '/oradata4/upd/all';
new_xml_filename CONSTANT VARCHAR2(80) := 'lob_case.doc';
BEGIN
DBMS_OUTPUT.ENABLE(100000);
-- GET CLOB LOCATOR
SELECT file_data INTO clob_loc
FROM test
WHERE no = 1;
file_handle := UTL_FILE.FOPEN(
location => directory_name,
filename => new_xml_filename,
open_mode => 'w',
max_linesize => buffer_size);
amount := buffer_size;
offset := 1;
-- READ FROM CLOB / WRITE OUT NEW XML TO DISK
WHILE amount >= buffer_size
LOOP
DBMS_LOB.READ(
lob_loc => clob_loc,
amount => amount,
offset => offset,
buffer => buffer);
offset := offset + amount;
UTL_FILE.PUT(
file => file_handle,
buffer => buffer);
UTL_FILE.FFLUSH(file => file_handle);
END LOOP;
UTL_FILE.FCLOSE(file => file_handle);
END;
Thanks
Kuljeet -
Datatypes in MySQL: getInt for integer, what for text?
As question. We use getInt to retrieve integer types in an MySQL database and getString for varchar types and so forth.What should i use for the text datatype? There is no getText. getString too?
Second question, I have a table which needs to store paragraphs of text in a row. What should i use? Text or blob? Any special precautions i need to take when using blob? Any special steps to take or is it just like the others?
Lastly, I also have the following error, i googled it up already, but mainly the results says something about missing jar files.To be honest i dont get them at all. Can anyone please explain it to me? Thanks.
javax.servlet.ServletException: Wrapper cannot find servlet class Maintenance.Support.AddProdLog or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:619)Thanks.The various getters on resultset relate to the form that the data is to be used in the program, rather than the form it's stored on the database. getString is fine for text.
The choice between clobs and text is often moot, it depends on how big the entries are likely to get, CLOBs are more complicated to use, they are stored separately from the database record and are optimised for quite large blocks. I wouldn't go to CLOBs if I expected the paragraphs to be less than about 2K characters. -
I get CLOB from Web Service and try to convert it to XMLType using schema, but get error
ORA-30931: Element 'LoanDetails' cannot contain mixed text
What element I should set to "mixed"? Or what I should do?! It happens only in Solaris , in Windows all works properly. As I discovered RTF text in node cause this errorI would strongly recommend wrapping the contents of the LoanDetails node in a CDATA section if possible. It looks like the response is not valid per the XML Schema in the WSDL To be sure I'd need to see the WSDL for the Web Service and the WebService response
-
Need help in converting rows to colums
Hi all,
I have a table with 2 columns.
colId value
1 aaa
2 bbb
3 ccc
1 ddd
2 eee
3 fff
I want to store the above table's data into another table which has 3 columns.
col1 col2 col3
aaa bbb ccc
ddd eee fff
I'm trying pivot query. But i'm not getting it correctly. Please help.
I have Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
Thanks in advance,
Girish G
Edited by: Girish G on Jul 28, 2011 1:28 AMGirish G wrote:
Hi Tubby,
Let me explain the actual scenario.
I'm getting CLOB data from external source to oracle stored procedure.
The data is coming in the following form.
col1#|#col2#|#col3~|~col1#|#col2#|#col3~|~col1#|#col2#|#col3
Here #|# -> is column delimiter.
and ~|~ -> is row delimiter.
I want to store the above data into a table which has 3 columns.
My approach was to extract each column data and store it in temporary table in separate rows. Then move the data from temporary table to final destination table.
Is there any other alternative for my requirement? please suggest.
Thanks,
Girish GMuch better when you show us the context like this.
It's late and i have sleepiness within my bones so this isn't likely optimal.
select
regexp_substr(split, '[^@]+', 1, 1) as col1 ,
regexp_substr(split, '[^@]+', 1, 2) as col2 ,
regexp_substr(split, '[^@]+', 1, 3) as col3
from
select
replace(regexp_substr(source_str, '[^@]+', 1, level), '#|#', '@') as split
from
select
replace('val1#|#val2#|#val3~|~val4#|#val5#|#val6~|~val7#|#val8#|#val9', '~|~', '@') as source_str
from dual
connect by level <= length(source_str) - length (replace(source_str, '@') ) + 1
);I also don't have an 11 instance running (tested this on XE) so i can't use 'magical' things like regexp_count and fun stuff. This should give you a basic idea of how to parse the data though.
I decode your delimiters into something "more manageable" just because it's easier than worrying about escaping special characters and all that fun stuff i'm too sleepy to try.
Since you're dealing with a CLOB (do you actually have more than 4000 characters of data?) you may have to abandon this and look in to a pipelined function as a suitable alternative.
Maybe you are looking for
-
I've looked around but can't seem to find a way to extract an audio file from a CD. I'm certain this was possible with Audition. I assume that Soundbooth (as part of my Master Bundle)is regarded by Adobe as superior to Audition but I feel there are m
-
MacBook Pro can't connect to wireless internet
I have a MacBook Pro that I have had from about 3 years now. It's been great but earlier this week, it wasn't able to connect to the internet here at my school (college). I didn't think too much of it because my schools internet is always spotty and
-
Inserting a Row in to a JTable
I have been looking and looking in the tutorials and other topics but can not find exactly what I need. I just need to start with a blank table and once something happens it will trigger to insert a row in to the table for updates. Here is the code o
-
I am using IPAD Mini.When I am searching for any particular song or album from my shared ITUNES folder, the search is conducted in the apple store and not on the shared library. How to search for the song in the shared library
-
We are getting an error whenever the calendar is syncing.. it stop at 7 out of xxx record and then an error pops up saying "Unknown Error". I tried to uninstall/reinstall blackbery manager and it still did not fix the issue. I also cleared the folder