SQL LOADER: how to load CLOB column using stored function
Hi,
I am a newbie of sql loader. Everything seems to be fine until I hit a
road block - the CLOB column type. I want to load data into the clob
column using a stored function. I need to do some manipulation on the
data before it gets saved to that column. But I got this error when I
run the sql loader.
SQL*Loader-309: No SQL string allowed as part of "DATA" field
specification
DATA is my CLOB type column.
here is the content of the control file:
LOAD DATA
INFILE 'test.csv'
BADFILE 'test.bad'
DISCARDFILE 'test.dsc'
REPLACE
INTO TABLE test_table
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
codeid BOUNDFILLER,
reason BOUNDFILLER,
Checkstamp "to_date(:CHECKSTAMP, 'mm/dd/yyyy')",
"DATA" "GetContent(:codeid, :reason)"
All references are suggesting to use a file to load data on
CLOB column but I want to use a function in which it generates
the content to be saved into the column.
Any help is greatly appreciated.
Thanks,
Baldwin
MISICompany
*** Duplicate Post ... Please Ignore ***
Similar Messages
-
How to retrieve multiple columns using "returning" in the Insert query.
hi,
wanted to know how to retrieve multiple columns using "returning" in the Insert Query.
For retrieving one column we write the query as follows:
Insert into TABLE values(1,2,3,4) returning COLUMN1 into PARAMETER
But can we retrive multiple columns in the same query?
am using oracle 10g and coding in .NETHi,
You can definetely get multiple values from a single query using the 'returning' clause.
Eg : insert into emp (empno, ename, job, deptno) values (7324,'ADAM','MARKETING',30) returning ename, deptno into var1, var2; PN : var1 & var2 to be declared as varchar2 & number respectively.
More insight into the 'RETURNING' clause in this link.
http://www.samoratech.com/PLSQL/swArtPLSQLReturn.htm
Regards,
Bhanu. -
How to set unequal columns using master pages in InDesign CS3?
How to set unequal columns using master pages in InDesign CS3?
I don't have CS3 anymore but I don't think this has substantially changed in the last few versions of InDesign.
Choose View > Grids & Guides > uncheck Lock Column Guides. Then drag the column guides to the position you want. -
How to get last column used in report sorting?
hi,
how to get last column used in report sorting?
simonHow to identifiy which column was sorted having different reports on page?
just use:
'YOUR_STATIC_REGION_NAME' instead of p_static_id,
:APP_ID for p_app_id,
:APP_PAGE_ID for p_page_id
:APP_USER_ID for p_app_user.
and dont forget to grant SELECT on #OWNER# to APEX_030200.WWV_FLOW_PREFERENCES$
good luck and thank you Juergen.Schuster
Simon -
How can and where i use the function "HTMLDB_UTIL.CLEAR_PAGE_CACHE "
how can and where i use the function "HTMLDB_UTIL.CLEAR_PAGE_CACHE " ?
where is the place to put this function?i have notice that sometime, during visual a report of a table, order by data insert desc, some record are not displayed on some client.
Only whe we clear the cache of internet explorer than this record can view.
I have an idea that a clear page when i call the report may be solve the problem.
Thank's.
------------------------ -
Problem in Loading data for clob column using sql ldr
Hi,
I am having problem in loading data for tables having clob column.
Could anyone help me in correcting the below script for ctrl file inorder to load the data which is in mentioned format.
Any help really appreciated.
Table Script
Create table samp
no number,
col1 clob,
col2 clob
Ctrl File
options (skip =1)
load data
infile 'c:\1.csv'
Replace into table samp
fields terminated by ","
trailing nullcols
no,
col1 Char(100000000) ,
col2 Char(100000000) enclosed by '"' and '"'
Data File(1.csv)
1,asdf,"assasadsdsdsd""sfasdfadf""sdsdsa,ssfsf"
2,sfjass,"dksadk,kd,ss""dfdfjkdjfdk""sasfjaslaljs"
Error Encountered
ORA-01461: can bind a LONG value only for insert into a LONG column
Table sampThanks in advanceI can't reproduce it on my 10.2.0.4.0. CTL file:
load data
INFILE *
Replace into table samp
fields terminated by ","
trailing nullcols
no,
col1 Char(100000000) ,
col2 Char(100000000) enclosed by '"' and '"'
BEGINDATA
1,asdf,"assasadsdsdsd""sfasdfadf""sdsdsa,ssfsf"
2,sfjass,"dksadk,kd,ss""dfdfjkdjfdk""sasfjaslaljs"Loading:
SQL> Create table samp
2 (
3 no number,
4 col1 clob,
5 col2 clob
6 );
Table created.
SQL> host sqlldr scott/tiger control=c:\temp\samp.ctl log=c:\temp\samp.log
SQL> select * from samp
2 /
NO
COL1
COL2
1
asdf
assasadsdsdsd"sfasdfadf"sdsdsa,ssfsf
2
sfjass
dksadk,kd,ss"dfdfjkdjfdk"sasfjaslaljs
NO
COL1
COL2
SQL> SY. -
SQL*Loader - How to load only a few columns from a .csv file to ora table
Hi there,
Could anyone please let me know how to load few columns from a .csv
file into a oracle table using SQL*Loader.
I know how to create a .dat and .ctl file and run the sql loader.
Suppose I have a .csv file with
col1, col2, col3, col4
and I only need to load col1 and col3 into col_a and col_b respectively
in table_a?
structure of table_ a
col_a,
col_b
Please adviceTry like..it i will work..
LOAD DATA
INFILE 'test.txt'
LOAD DATA
TRUNCATE INTO TABLE T1
FIELDS TERMINATED BY ','
(col1,
col2 FILLER,
col3,
col4 FILLER
) -
Loading Images into LONG RAW column using SQL or PL/SQL
Hi!
I am trying to load images into a LONG RAW column. Can anybody tell me how to do this using SQL or PL/SQL. I do not want to use Forms to do this. And, I have a limitation using BLOBs.
Thanks in Advance,
Kotesh.You wrote that you cannot use a java class to insert a picture. We are working on a school project and HAVE to use java as a client and Oracle 7 as a server.
Can you tell us how this is to be done?
Thank you in advance,
Bart van der Heijden -
Loading data into a CLOB column
I need to find out how to load about ten sentences of data into a clob column for a table in the database. I have a pl/sql procedure that loads data from an xml file into various tables in the the database. Recently, we added a column (test_dummy) to one of the tables and defined it as a CLOB. There is a corresponding node (detail_info) in the XML file that maps to this column. I need to figure out how to incorporate this in the pl/sql procedure so that the data in the XML file for the node (detail_info) is loaded into "test_dummy". Any ideas?
Take it one at a time. Use 'extract' function to extract an XML snippet from a given XML. The question couldn't be more vague. Maybe an example would help?
Rahul -
SQL*Loader: How to load multi-line report data?
Hi,
is it possible to use SQL*Loader to load data from a hierarchical structured fixed column ASCII file like this
001 scott
New York 01.01.2002 1234
Chicago 15.10.2001 9876
002 smith
Los Angeles 24.12.1999 5678
Washington 01.12.1999 0000
Chicago 01.01.2000 1111
into one database table:
id name city day code
001 scott New York 01.01.2002 1234
001 scott Chicago 15.10.2001 9876
002 smith Los Angeles 24.12.1999 5678
002 smith Washington 01.12.1999 0000
002 smith Chicago 01.01.2000 1111
The number of lines per name is unlimited, the next line starts after a separating ---- line.
We cannot change the format of the text file to import.
There is an example in the documentation that shows how to load a structure like the following via insert triggers:
001 scott New York 01.01.2002 1234
Chicago 15.10.2001 9876
002 smith Los Angeles 24.12.1999 5678
Washington 01.12.1999 0000
Chicago 01.01.2000 1111
But we have the name information on a separate header line, so I don't know if we can use a similar technique here.
regards
SvenTry enclosing your strings with e.g. a double-quote. To do so, the control file needs the following (example):
LOAD DATA
REPLACE
INTO TABLE test
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
id1,
id2,
id3,
id4,
)of course this does mean that your data must change...
L. -
How to view clob data using sql
Hi,
In our database, we have one table that is having one column of CLOB datatype but now i want to view the data using sql select query but it throws error: "Datatype not supported".
Could any one please let me know how to view the clob data using select query.
Oracle DB version : 10.2.0.3
Thanksh5.
use read procedure
PROCEDURE READ (
lobsrc IN BFILE|BLOB|CLOB ,
amount IN OUT BINARY_INTEGER,
offset IN INTEGER,
buffer OUT RAW|VARCHAR2 );
example Updating LOB by Using DBMS_LOB in PL/SQL
DECLARE
lobloc CLOB; -- serves as the LOB locator
text VARCHAR2(32767):='Resigned: 5 August 2000';
amount NUMBER ; -- amount to be written
offset INTEGER; -- where to start writing
BEGIN
SELECT resume INTO lobloc
FROM employees
WHERE employee_id = 405 FOR UPDATE;
offset := DBMS_LOB.GETLENGTH(lobloc) + 2;
amount := length(text);
DBMS_LOB.WRITE (lobloc, amount, offset, text );
text := ' Resigned: 30 September 2000';
SELECT resume INTO lobloc
FROM employees
WHERE employee_id = 170 FOR UPDATE;
amount := length(text);
DBMS_LOB.WRITEAPPEND(lobloc, amount, text);
COMMIT;
END; -
ORA-22275 inserting into the CLOB column using ODBC input parameters
Hi all,
I'm having problem with INSERT into the CLOB column via bound input parameters.
After calling SQLExecDirect() I'm getting following error:
[Oracle][ODBC][Ora]ORA-22275: invalid LOB locator specified
Adding defaults to the table definitions does not help. If I embed parameter values into the SQL statement - everything works just fine.
I use Oracle 9.2 with latest Oracle ODBC driver 9.2.0.4 under Windows XP.
Any ideas appreciated...
Vlad
Code looks like this:
SQLBindParameter(hstmt,1,...);
SQLBindParameter(hstmt,2,...);
SQLBindParameter(hstmt,3,...);
SQLExecDirect(hstmt,...);
SQL statement looks like this:
insert into tst_table (id,str_fld,clob_fld1,clob_fld2) values (50, ? , ? , ?)
Table looks like this:
CREATE TABLE tst_table (
id number (10,0) NOT NULL ,
str_fld nvarchar2 (50) NOT NULL ,
clob_fld1 nclob NOT NULL ,
clob_fld2 nclob NOT NULL ,
CONSTRAINT PK_tst_table PRIMARY KEY
id
I tried to add defaults to the table, but result is the same:
CREATE TABLE tst_table (
id number (10,0) NOT NULL ,
str_fld nvarchar2 (50) NOT NULL ,
clob_fld1 nclob default EMPTY_CLOB() NOT NULL ,
clob_fld2 nclob default EMPTY_CLOB() NOT NULL ,
CONSTRAINT PK_tst_table PRIMARY KEY
idYou need to provide the data at execution time (i.e. SQL_LEN_DATA_AT_EXEC(0) in the SQLBindParameter followed by a series of SQLPutData calls). If you go to Metalink
Top Tech Docs | Oracle ODBC Driver | Scripts & Sample Code
has some sample code that shows you how to do this.
Justin -
Updating a CLOB column using C++ with ATL
Hello,
I have tables with a single CLOB or BLOB colum with the rest of the columns of type VARCHAR2.
I'm getting a result of E_FAIL when updating a single row, for which I'm attempting to change one of the VARCHAR2 columns and the CLOB column. If I set the status for the CLOB column to DBSTATUS_S_IGNORE, the update succeeds (for the other column). If I set the status for all other columns to DBSTATUS_S_IGNORE and the status for the CLOB column to DBSTATUS_S_OK, it still fails.
If I use a SQL Server data source with the same schema and the same C++ code, the original update succeeds.
The length of the data I'm attempting to store is 11487 characters.
As near as I can tell, the Oracle provider does support this kind of functionality. Perhaps there is some coding variation needed for the Oracle data source. I have so far been unable to find a suitable example (or any code example for the Oracle provider using C++/ATL).
I'm using Oracle 9i Release 2 with the latest OLE DB provider (9.2.0.2.0).
Thanks,
Daniel E. Hale
[email protected]Some additional information on the problem:
I was using the ISequentialStream interface
with a Dynamic Accessor when the problem
occurred.
Since then I've tried using a SQL command to do
the update... and I've found the 11487 characters
is too long... I get a maximum length error when
I try the command in SQL+. (BTW, SQL Server works
fine with the long command.)
I doubt that the length is the reason for the failure
of the update using the ISequentialStream interface.
I'm just looking for something that works. Right
now, the only thing that works is not to do the
update at all, but instead do delete/insert. I'd
like to find a better solution than that.
-Daniel E. Hale -
How to convert clob column to long
Hi,
Is there any way to convert clob column to long.
Here below is my scenario..
Instead of using substr function
CREATE OR REPLACE PROCEDURE proc AS
sql2 clob := '';
sqlstring1 LONG;
sqlstring2 LONG;
sqlstring3 LONG;
sqlstring4 LONG;
sqlstring5 LONG;
sqlstring6 LONG;
sqlstring7 LONG;
sqlstring8 LONG;
sqlstring9 LONG;
sqlstring10 LONG;
BEGIN
FOR sql1 IN (SELECT info FROM emp)
LOOP
sql2 := sql1.sql_string;
sqlString1 := dbms_lob.SUBSTR(sql2, 8000, 1);
sqlString2 := dbms_lob.SUBSTR(sql2, 8000, 8001);
sqlString3 := dbms_lob.SUBSTR(sql2, 8000, 16001);
sqlString4 := dbms_lob.SUBSTR(sql2, 8000, 24001);
sqlString5 := dbms_lob.SUBSTR(sql2, 8000, 32001);
sqlString6 := dbms_lob.SUBSTR(sql2, 8000, 40001);
sqlString7 := dbms_lob.SUBSTR(sql2, 8000, 48001);
sqlString8 := dbms_lob.SUBSTR(sql2, 8000, 56001);
sqlString9 := dbms_lob.SUBSTR(sql2, 8000, 64001);
sqlString10 := dbms_lob.SUBSTR(sql2, 8000, 72001);
EXECUTE IMMEDIATE sqlString1 || sqlString2 || sqlString3 ||
sqlString4 || sqlString5 || sqlString6 ||
sqlString7 || sqlString8 || sqlstring9 ||
sqlstring10;
END LOOP;
COMMIT;
END proc;
Any help really appreciated
ThanksWe cannot execute clob dynamically.That's what I said: execute immediate doesn't support CLOB!
But you can concatenate two long's:
SQL> DECLARE
l_stmt1 LONG;
l_stmt2 LONG;
BEGIN
l_stmt1 := RPAD ('BEGIN ', 32500, ' ');
l_stmt2 :=
RPAD (' dbms_output.put_line(''Hello World'');', 32500, ' ')
|| 'END;';
DBMS_OUTPUT.put_line ('Length of statement: '
|| LENGTH (l_stmt1 || l_stmt2)
EXECUTE IMMEDIATE (l_stmt1 || l_stmt2);
END;
Length of statement: 65004
Hello World
PL/SQL procedure successfully completed.So if you strip some extra spaces or try to compact your statement somehow, you might be able use above method. -
SQL Developer Export Limitation of CLOB columns
Hello Everyone,
Would anyone happen to know if there is a column size limitation when exporting data (excel, text, etc) from the results query results pane? There appears to be a 4000 byte limitation. Specifically, I am attempting to export sql results that contain clobs which are storing XML messages.
Is this a known limitation and if so, is there any expectation of this being enhanced?
I am using the following:
Windows XP SP3
SQL Developer 2.1.0.63 (also happens on the 1.5 branch)
Oracle Server 10.2.0.4
Oracle Client 10.2.0.1
Thanks,
RonnieYes, that's correct.
If you want this enhanced, add a request at the SQL Developer Exchange, so other users can vote and add weight for possible future implementation.
Regards,
K.
Maybe you are looking for
-
Database Error while refreshing webi report
Hi, I am getting following error while refreshing webi report. And also all my scheduled webi reports are getting failed because of same issue. What would be the reason for this error. Regards, PRK
-
Deauthorized all computers from my account. Which now I think I should have not done!! I reauthorized mine only BUT now I can no longer play any new songs purchased without it asking me to authorize my computer?? When I authorize it tell me my com
-
BENQ FP241W on Retina Macbook Pro - native resolution not supported?
Hi there, I have tried connecting my BENQ FP241W monitor to my new Macbook Pro with retina display via HDMI. The monitor appears to be displaying at only 1600x900 and looks very blurry since the native resolution of the monitor is 1920x1200. I have a
-
Replies to emails on I phone 5
I try to reply on emails on my Iphone 5, but the screen for replies does not open
-
Opening new tab without clicking in navigation
Every time I open a new tab in safari by clicking on the + button up top and a new tab opens I always have to click in the navigation bar to enter a new web address. on my macbook pro i never had to do this and I could just start typing as soon as a