ORA-00997 - Illegal use os LONG Datatype
Hello
I'm having this error in my query, and I know I can't use one column LONG with a INSERT statement, but I can't change this column to VARCHAR2(4000) because of the short space.
Somebody have the solution for this? Or how I make this insert? Some function or procedure... anything...
Tnks
Rafael
Since you cannot use LONG into a INSERT...SELECT... statement, you may use a procedure with a loop.
By the way, what about CLOB ?
Nicolas.
Similar Messages
-
ORA-00997: illegal use of LONG datatype - while inserting a record
Hello,
I have this table:
create table TEST
USER VARCHAR2(20) not null,
WINCFG LONG RAW
There are a few records, some with user='OLDUSER'.
I want to add new records with a statement like this one:
insert into TEST
select 'NEWUSER',wincfg from TEST where user='OLDUSER'
But Oracle returns the error:
"ORA-00997: illegal use of LONG datatype"
I have no idea...
Thank youSQL> insert into TEST
2 (
3 select 'NEWUSER',wincfg from TEST where user='OLDUSER'
4 );
select 'NEWUSER',wincfg from TEST where user='OLDUSER'
ERROR at line 3:
ORA-00997: illegal use of LONG datatype
SQL> copy from scott/tiger@mydb insert test using select * from test;
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
1 rows selected from scott@mydb.
1 rows inserted into TEST.
1 rows committed into TEST at DEFAULT HOST connection.Hope it help -
ORA - 00997 Illegal Use Of Long Datatype when no Long is used
I have a query that was working fine for years. We have upgraded to 10.2.0.5 on a test instance and we now get this error.
The view in the FROM clause is an org specific view on xxc_affi_relation_headers_all. All of the fields in the view and underlying table are either VARCHAR2, NUMBER, or DATE.
I have simplified the query to one that still gives the error.
The query is:
SELECT *
FROM xxc_affi_relation_headers xarh
WHERE xarh.affi_relation_id = (select xarh.affi_relation_id
from xxc_affi_relation_headers xarh
where xarh.execute_vendor_id = 125
connect by prior xarh.affi_relation_id = xarh.parent_relation_id
start with xarh.affi_relation_id = 214
If I run the sub query by itself, as below, there is no error and the result is 214.
select xarh.affi_relation_id
from xxc_affi_relation_headers xarh
where xarh.execute_vendor_id = 125
connect by prior xarh.affi_relation_id = xarh.parent_relation_id
start with xarh.affi_relation_id = 214
If I run the main query and replace the sub query with 214, as below, thre is no error.
Is there something that would cause an implicit conversion to a LONG datatype in this query? I am not able to find a reason for this error message that fits the query.
The original query that caused the error was:
SELECT xarh.affi_relation_id
FROM
xxc_affi_relation_headers xarh
WHERE NOT EXISTS (SELECT 1 FROM xxc_oe_order_line_dist xold
WHERE xold.line_id = p_line_id AND xold.dist_type = 'I'
AND xold.affi_relation_id = xarh.affi_relation_id)-- 1704
AND v_creation_date
BETWEEN NVL(xarh.start_date,v_creation_date-1) AND NVL(xarh.end_date,v_creation_date+1) --ES fix not a valid month
AND xarh.sale_segment1 = (SELECT gcco.segment1 --RT 9631
FROM oe_transaction_types_all otty, ra_cust_trx_types_all rctt, gl_code_combinations gcco
WHERE otty.transaction_type_id = p_order_type_id
AND otty.cust_trx_type_id = rctt.cust_trx_type_id
AND rctt.gl_id_rev = gcco.code_combination_id )
AND EXISTS(SELECT 1 FROM xxc_affi_relation_lines xarl WHERE xarl.affi_relation_id = xarh.affi_relation_id
AND NVL(xarl.element_value,v_item_type) = v_item_type)
connect by prior xarh.parent_relation_id = xarh.affi_relation_id
Start with
xarh.affi_relation_id = (select xarh.affi_relation_id
from xxc_affi_relation_headers xarh
where xarh.execute_vendor_id = p_vendor_id
AND xarh.affi_relation_id != p_parent_relation_id
AND NOT EXISTS (SELECT 1 FROM xxc_affi_relation_headers xarh2
WHERE xarh2.parent_relation_id = xarh.affi_relation_id)
AND v_creation_date BETWEEN NVL(xarh.start_date,v_creation_date-1) AND NVL(xarh.end_date,v_creation_date+1)--ES fix not a valid month
start with xarh.affi_relation_id = p_parent_relation_id
connect by prior xarh.affi_relation_id = xarh.parent_relation_id)
--ORDER BY NVL(parent_relation_id,-1), NVL2(xarl.element_value,1,2)
;Its a bug
See this Oracle Document
Bug 9726739 - ORA-997 from SQL with CONNECT BY and UNION [ID 9726739.8]
Best Regards
mseberg -
While I was insert a rows into the same table I am getting an error. I am having one long column in table list. I am getting following error while I was inserting a row.
ORA-00997: illegal use of LONG datatype
Please let me know how do I insert long data type values for this kind of insert.[duplicate thread|http://forums.oracle.com/forums/message.jspa?messageID=3770321#3770321]
-
Illegal use of LONG datatype error message when i create materialized view
Hello to all
I want create read only materialized view replication environment two of our tables have LONG datatype when i create materialized view against on them
I recieve this error message
CREATE MATERIALIZED VIEW MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID AS SELECT * FROM MDB.TOAD_PLAN_TABLE@arahisto
Error report:
SQL Error: ORA-00997: illegal use of LONG datatype
00997. 00000 - "illegal use of LONG datatype"
Do you know any resort solution for it?
thanksYou can not use longs in materialized views over a database link, you can however take a part of a long over to a materialized view.
I have gotten this to work in the past l had to create a PL/SQL function that you can use to extract the character data from the long column and use that to
as part of the function you will need to pass in the columns of the table that will identify the unique records so you can pick out the long column
example function
-- you will need to make sure this funtion is in the remote location as you can not select longs accross a DB LINK.
CREATE OR REPLACE FUNCTION MDB.TOAD_PLAN_LONG_CONV
(pass in the primary key columns for the table)
RETURN VARCHAR2
IS
v_long VARCHAR2(32767) ;
BEGIN
BEGIN
-- need to select the long column into the PL/SQL variable
SELECT long_column
INTO v_long
FROM MDB.TOAD_PLAN_TABLE
WHERE key_columns = passed columns ;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = '-01406' THEN
NULL ;
ELSE
RAISE ;
END IF ;
END ;
RETURN SUBSTR(v_long,1,4000) ;
END ;
Then when you create the materialized view utilize that function on the long column.
create or replace materialized view MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID
AS
SELECT column1, .... columnx,
MDB.TOAD_PLAN_LONG_CONV@arahisto (primary key column list) as long_column_name
FROM MDB.TOAD_PLAN_TABLE@arahisto ;
See if this will work for you? Keep in mind however this solution will not get the entire long column only as much as a PL/SQL variable will hold of it.
Mike -
I create on table say "TAB" with a column as long datatype
create table tab
(name long);
now i need to create another table structure similar to "TAB" say "TMP_TAB"
create table tmp_tab
as
select * from tab;
But this gives the following error..< ORA-00997: illegal use of LONG datatype >
Can anyone please explain me the reason for the following error?If you have Oracle 9i, then
Quick and correct solution: Don't use LONG - Datattype !
It's obsolete, use CLOB instead.
If LONG- Datatype is inevitable (why ?), then
declare
v_sql VARCHAR2(32767);
begin
select dbms_metadata.get_ddl('TABLE', 'TAB', 'SCOTT') INTO v_sql
from dual;
v_sql := replace (v_sql, '"SCOTT"."TAB"', '"SCOTT"."TMP_TAB"');
execute immediate v_sql;
end;
/but it's a bit tricky .... -
Error when using LONG Datatype
Hi,
I am transferring data from oracle to oracle. In my source table and target table i have a column of "long" datatype. When i execute the interface i am getting the following error.
997 : 42000 : java.sql.SQLException: ORA-00997: illegal use of LONG datatype
Cause: A value of datatype LONG was used in a function or in a DISTINCT, WHERE, CONNECT BY, GROUP BY, or ORDER BY clause. A LONG value can only be used in a SELECT clause.
How can we resolve this issue in ODI?
Thanks in Advance,
Ram Mohan TCezar,
I am bit confused with the steps.
1) Create first interface with IKM Control append and flow_control yes but no long mapping
This is the real interface to be created with out the Long Column mapping.
2) Create second interface with IKM PL/SQL and "flow_control" NO and a "not exists "filter to "E$" (from first interface)
Do I need to duplicate the same mapping here. I couldn’t understand this line Cezar. “and a "not exists "filter to "E$" (from first interface)”
Does ODI doesnt provide any direct way to resolve this issue? When ever a table with Long datatype, do we need to do this steps?
Thanks in Advance,
Ram Mohan T -
I have created a select statement and saved it to the variable sql_str. I then Open the cursor "OPEN v_cursor FOR sql_str;".
One of the columns in the select statement has a datatype of LONG. I fetch the column into a variable that I have declared as Long. I get the following error: ORA-00997: illegal use of LONG datatype.
What am I doing wrong?One of the columns in the select statement has a datatype of LONG. I fetch the column into a variable that I have declared > as Long. I get the following error: ORA-00997: illegal use of LONG datatype.
What am I doing wrong?What are you doing differently:
SQL> desc user_views
VIEW user_views
Name Null? Type
VIEW_NAME NOT NULL VARCHAR2(30)
TEXT_LENGTH NUMBER(0)
TEXT LONG <-- Long
TYPE_TEXT_LENGTH NUMBER(0)
TYPE_TEXT VARCHAR2(4000)
OID_TEXT_LENGTH NUMBER(0)
OID_TEXT VARCHAR2(4000)
VIEW_TYPE_OWNER VARCHAR2(30)
VIEW_TYPE VARCHAR2(30)
SUPERVIEW_NAME VARCHAR2(30)
EDITIONING_VIEW VARCHAR2(1)
READ_ONLY VARCHAR2(1)
SQL> declare
t long;
begin
for c in (select text from user_views where rownum = 1)
loop
t := c.text;
dbms_output.put_line (t);
end loop;
end;
SELECT
"LIB_DYN_QUERY_ID" AS "LIB_DYN_QUERY_ID"
,"LIB_DYN_QUERY_NAME" AS "LIB_DYN_QUERY_NAME"
,"LIB_DYN_QUERY" AS "LIB_DYN_QUERY"
,"CREATED_ON" AS "CREATED_ON"
,"CREATED_BY" AS "CREATED_BY"
FROM
"UT_LIB_DYN_QUERIES"
WITH READ ONLY
PL/SQL procedure successfully completed.? -
Selecting From Column with Long Datatypes
create table temp
a long
insert into temp values ('abc');
commit;
select * from temp
where a = 'abc'
I am getting the following error while am tring to select a = 'abc';
ora-00997 : illegal use of LONG datatype
How can i select values from a column with long datatypesinsert into temp values ('abc');
cannot (must not) work, when the column is type long (thats a numeric type!!)
-> here you get an ora- 00911 errorcode
that the select doesn't work then should be clear.
mfg f.humer -
How to select data(first 10 charcters) from a LONG datatype column.?
Hi,
I am getting below error wile i am trying to select forst 10 charcter from a log datatype column. May be I am using it in a wrong way using SUBSTR function.
I dont know whether SUBSTR works for LONG columns or not as it's char function.
I am not able to find any inbuild conversion function which will work like TO_CHAR.Please revert.
My steps:-
=================================================
SQL> create table long_varchartest(
2 nirav long, sangram varchar2(30));
Table created.
SQL> insert into long_varchartest values('ns89027','sd22712');
1 row created.
SQL> insert into long_varchartest values('Nirav Shah', 'Sangram Dash');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from long_varchartest;
NIRAV SANGRAM
ns89027 sd22712
Nirav Shah Sangram Dash
SQL> insert into long_varchartest(sangram)
2 select nirav from long_varchartest;
select nirav from long_varchartest
ERROR at line 2:
ORA-00997: illegal use of LONG datatypedeclare
l_text varchar2(4000) ;
begin
select nirav into l_text from long_varchartest where sangram = 'sd22712';
dbms_output.put_line(substr(l_text,1,10));
end ;you could also follow this link [http://www.oracle.com/technology/oramag/code/tips2003/052503.html] -
Move tables (some with LONG datatypes) across tablespaces in Oracle 9i
I have a 14GB tablespace which about 3,000 tables (and only tables) in. Only 2.6GB is used so I would like to resize the tablespace to about 3GB initially.
I moved the tables with "alter table <owner>.<tablename> move tablespace <tablespace>" and this worked for most of the tables but failed on some with this kind of error:
alter table IFSAPP.COMMAND_SYS_BUFFER_TAB move tablespace IFSAPP_DATA_TEMP
ERROR at line 1:
ORA-00997: illegal use of LONG datatypeI then moved the other tables back to the original a little frustrated.
Further reading suggested exporting and importing the tables is the way to go.
I prefer the alter table because Oracle manages the lock whilst it moves. If I export and import, the table could change in between, potentially ending with me importing an old copy, couldn't it? [It seems neigh on impossible to guarantee an available window to do much!]
So I though I could you the alter table move for ALL tables and those that are left, use export/import, to minimise the risk.
How should I proceed?
1) Create TEMP_TABLESPACE as 3GB
2) "alter table ... move tablespace ..." for all tables in ORIGINAL_TABLESPACE to TEMP_TABLESPACE
3) For the remaining tables, individually:
a) lock table (not sure how)
b) export table: exp user/pass tables=tablename file=exp.dmp rows=yes
c) drop table
d) create table in TEMP_TABLESPACE*
e) import table: imp user/pass tables=tablename
* this means I need to know how to re-create the table. It also means views and indexes and packages are going to become invalid.
4) drop tablespace ORIGINAL_TABLESPACE
5) Create ORIGINAL_TABLESPACE as 3GB
6) "alter table ... move tablespace ..." for all tables in TEMP_TABLESPACE to ORIGINAL_TABLESPACE
7) For the remaining tables, individually:
a) lock table (not sure how)
b) export table: exp user/pass tables=tablename file=exp.dmp rows=yes
c) drop table
d) create table in ORIGINAL_TABLESPACE
e) import table: imp user/pass tables=tablename
This seems high risk and messy.
Has anyone advice or tips to make it simpler?
As it stands I am considering leaving alone, the risks worry me!
ThanksInteresting idea.. so this would create a temporary table in the temporary tablespace.
Rather than set the default tablespace, can I merely add the tablespace clause?
COPY FROM user/password@database CREATE TmpTblName TABLESPACE TmpTablespace USING SELECT
* FROM Table_name;
Either way - can you confirm for each table, I would need to:
COPY FROM user/password@database CREATE TmpTblName TABLESPACE temp_tablespace USING SELECT * FROM Table_name;
At this point all indexes for these will be invalid.
Drop tablespace ORIGINAL_TABLESPACE
Create ORIGINAL_TABLESPACE as 3GB
COPY FROM user/password@database CREATE TblName TABLESPACE original_tablespace USING SELECT * FROM TmpTable_name;
rebuild any indexes which are unusable.
recompile any invalid objects -
ORA-01461 error using jdbc 10.2.0.1.0
I am using the oracle jdbc 10.2.0.1.0 ( the latest version) and oracle 10g (10.1.0.4.0) database. Sometimes, the error "ORA-01461: can bind a LONG value only for insert into a LONG column' if I use a java program to insert record to a table containing a 'long raw' field. Previously, the same java program work well with oracle 9i.
Interestingly, the 'ORA-01461' only SOMETIMES happen. If the problem appears, I need to rename the table and create a new one and then the data can be inserted.After 3 days of deep analysis on my project, now I have a clear idea of the problem.
As you can find on web, newer versions of Oracle drivers for Java have the possibility to set property :
oracle.jdbc.RetainV9LongBindBehavior=true
it's considered the fix for this bug, and effectively it seems to work.
But also with this setting, drivers have one more bug!+
The problem appears in these conditions:
- Application tries to save a string into a LONG column database
- String length is more than 4000 bytes
- String has less than 4000 characters (it's possible in case of international characters, which takes more than 1 byte)
With these conditions, we have again error ORA-01461: can bind a LONG value only for insert into a LONG column.
It seems that drivers evaluate string length before saving it, and consider it as LONG only for 4000+ characters. The bug is just on this check, that must consider length in bytes, according to database character encoding, and not simply for character length.
As workaround, on my application we added a logic that appends spaces (" ") until total characters are at least 4001. In this way, string is considered correctly as LONG and storage works correctly.
The check is something similar to this:
if(value.getBytes("UTF-8").length > 4000 && value.length() < 4000)
for(int x = value.length(); x<=4000; x++)
value += " "; // always use StringBuffer for appending
This workaround works, but it's clear that it can be not acceptable in many cases, for application funcionalities. In my specific bug, it has been very useful.
My customer opened a ticket to Oracle, asking for solution of this bug. I will wait for Oracle answer.
Finally, we have to say that Oracle warned to not use anymore LONG datatype: it's deprecated since v8.0.
Bye guys ;-)
Edited by: user12274810 on 25-nov-2009 12.04 -
Using clobs and ORA-01704: string literal too long
Hi,
I am attempting to add oracle support to an existing J2ee application. The issue I am facing is the use of CLOB datatypes and the 4k string literal limitation that Oracle has.
I have dowloaded the 10.2.0.3 thin driver and am connected to a 9i release 2 database. When I execute a statement such as the following (say the table has one varchar2 field and two clob fields
Insert into my_table VALUES ('hi','something','pretend this string is 5000 characters')
I still receive the error
java.sql.SQLException: ORA-01704: string literal too long
I have read that the version 10 drivers were supposed to address this limitation. Is there something I am missing or must I change my home grown database layer to use bind variables or clob manipulation in a separate update/insert statement.? I am trying to avoid this situation since the database layer works fine for the situation of MSSQL and text fields which have no such limitation.
Any advice you have here is greatly appreciated.
Thanks,
JoeHi,
I am attempting to add oracle support to an existing J2ee application. The issue I am facing is the use of CLOB datatypes and the 4k string literal limitation that Oracle has.
I have dowloaded the 10.2.0.3 thin driver and am connected to a 9i release 2 database. When I execute a statement such as the following (say the table has one varchar2 field and two clob fields
Insert into my_table VALUES ('hi','something','pretend this string is 5000 characters')
I still receive the error
java.sql.SQLException: ORA-01704: string literal too long
I have read that the version 10 drivers were supposed to address this limitation. Is there something I am missing or must I change my home grown database layer to use bind variables or clob manipulation in a separate update/insert statement.? I am trying to avoid this situation since the database layer works fine for the situation of MSSQL and text fields which have no such limitation.
Any advice you have here is greatly appreciated.
Thanks,
Joe -
ORA-09100 specified length too long for its datatype with Usage Tracking.
Hello Everyone,
I'm getting an (ORA-09100 specified length too long for its datatype) (a sample error is provided below) when viewing the "Long-Running Queries" from the default Usage Tracking Dashboard. I've isolated the problem to the logical column "Logical SQL" corresponding to the physical column "QUERY_TEXT" in the table S_NQ_ACCT. Everything else is working correctly. The logical column "Logical SQL" is configured as a VARCHAR of length 1024 and the physical column "QUERY_TEXT" is configured as a VARCHAR2 of length 1024 bytes in an Oracle 11g database. Both are the default configurations and were not changed.
In the the table S_NQ_ACCT we do have record entries in the field "QUERY_TEXT" that are of length 1024 characters. I've tried various configuration such as increasing the the number of bytes or removing any special character but without any sucess. Currently, my only possible workaround is reducing the "Query_Text" data entries to roughly 700 characters. This makes the error go away. Additional point my character set to WE8ISO8859P15.
- Any suggestions?
- Has anyone else ever had this problem?
- Is this potentially an issue with the ODBC drive? If so, why would ODBC not truncate the field length?
- What is the maximum length supported by BI, ODBC?
Thanks in advance for everyones help.
Regards,
FBELL
*******************************Error Message**************************************************
View Display Error
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 910, message: ORA-00910: specified length too long for its datatype at OCI call OCIStmtExecute: select distinct T38187.QUERY_TEXT as c1 from S_NQ_ACCT T38187 order by c1. [nQSError: 17011] SQL statement execution failed. (HY000)
SQL Issued: SELECT Topic."Logical SQL" saw_0 FROM "Usage Tracking" ORDER BY saw_0
*******************************************************************************************I beleieve I have found the issue for at least one report.
We have views in our production environment that call materialized views on another database via db link. They are generated nightly to reduce load for day-old reporting purposes on the Production server.
I have found that the report in question uses a view with PRODUCT_DESCRIPTION. In the remote database, this is a VARCHAR2(1995 Bytes) column. However, when we create a view in our Production environment that simply calls this materialized view, it moves the length to VARCHAR2(4000).
The oddest thing is that the longest string stored in the MV for that column is 71 characters long.
I may be missing something here.... But the view that Discoverer created on the APPS side also has a column length for the PRODUCT_DESCRIPTION column of VARCHAR2(4000) and running the report manually returns results less than that - is this a possible bug? -
Using Decode with "Long" datatypes
Hi,
I want to use a select statement in a view which uses a decode function involving a "long" datatype. But doing some raises an error "Invalid datatypes". Is there a way around?
Anupam.I'm a bit puzzled as to what it is you are trying to achieve (it has been an afternoon for vague requirements). Normally the sort of data that we would want to store in a LONG is ,er, long and therefore not susceptible to use in a DECODE. But it does not matter, because we can only manipulate LONGs in PL/SQL and that does not parse DECODE statements. We will have to use IF...ELSE constructs instead.
CREATE OR REPLACE FUNCTION l2v (pl in rowid) RETURN VARCHAR2
AS
ll LONG;
rv VARCHAR2(20);
BEGIN
SELECT col1
INTO ll
FROM T_LONG
WHERE rowid = pl;
IF ll LIKE '%text%'
THEN
rv := 'yes!';
ELSE
rv := 'noooo';
END IF;
RETURN rv;
END;
SQL> select l2v(rowid) from t_long;
L2V(ROWID)
yes!
yes!
SQL> You can use this function in a query. Note that it is doing a SELECT in its own right so this will not be a very performant solution if you build the view on a big table.
Cheers, APC
Maybe you are looking for
-
I have been using a G4 Powerbook 17-inch, 1.33 Ghz connected to an NEC VT470 LCD Projector through the S-Video output (Mirroring). It had been working just fine until recently - the s-video output stopped working. The odd part of this is that if I co
-
How to get rid of Photo Library in Photos App
Hello, Am an iPhone user with a question, when i upload new photos from iTunes, the iPhone automatically generate the Photo Library. how can i get rid of this Photo Library
-
Icc profiles and 10.4.3
Hi! I just bought the highly praised Epson Photo R2400 printer. This was my choice most of all because I´m into b&w photography - also as a professional. My problem seems to be getting the icc profiles for different papers to work properly with the p
-
My usb drive won't connect to my macbook anymore.
It says: MAC OS X can't repair the disk: you can still open or copy files on the disk, but you can't save changes to files on the disk. Back up the disk and reformat it as soon as you can. How would i go about?
-
How to use different default parameter value for different report subscriptions
In ssrs is it possible to define different default parameter values for different subscriptions? In the following example I have a report which has two subscriptions with different start date and end date values: Report name – Testsubscription.rdl Su