I am getting "ORA-21560: argument 3 is null, invalid, or out of range" error on running query:
SELECT extractvalue(xmltype(blob2clob(shblobdata.blobdata)),
'/booked-order/ads/online-content[name="quantity"]/value')
FROM shblobdata
WHERE id=...;
the full error is:
ORA-21560: argument 3 is null, invalid, or out of range
ORA-06512: at "SYS.DBMS_LOB", line 978
ORA-06512: at "MORAS.BLOB2CLOB", line 14
21560 . 00000 - "argument %s is null, invalid, or out of range"
*Cause: The argument is expecting a non-null, valid value but the
argument value passed in is null, invalid, or out of range.
Examples include when the LOB/FILE positional or size
argument has a value outside the range 1 through (4GB - 1),
or when an invalid open mode is used to open a file, etc.
*Action: Check your program and correct the caller of the routine
to not pass a null, invalid or out-of-range argument value.
I have tried to change "quantity" to ''quantity'' (changing single quote to two apostrophes), but got the same error.
The content of blob is:
<?xml version="1.0" encoding="utf-8"?>
<booked-order>
<ads>
<online-content>
<name>quantity</name>
<value>19872</value>
</online-content>
</ads>
</booked-order>
The problem is in your custom function MORAS.BLOB2CLOB.
Also the error message says clearly ORA-06512: at "MORAS.BLOB2CLOB", line 14
The extract itself is ok, when you keep out BLOB2CLOB and test with
SELECT EXTRACTVALUE (xmltype ( (shblobdata.blobdata)), '/booked-order/ads/online-content[name="quantity"]/value')
FROM (SELECT '<?xml version="1.0" encoding="utf-8"?>
<booked-order>
<ads>
<online-content>
<name>quantity</name>
<value>19872</value>
</online-content>
</ads>
</booked-order>
' blobdata
FROM DUAL) shblobdata
;
it returns 19872
I'd first debug your function blob2clob with
SELECT blob2clob(shblobdata.blobdata)
FROM shblobdata
WHERE id=...;
And if that works ok continue on to the XML parts.
The exception is clearly hurled by BLOB2CLOB(), which is not an Oracle built-in. It's something you've written yourself or lifted from somewhere on the interwebs. So there's not much we can do to help regarding it.
The more general point is, why are you storing XML in a BLOB? The best apporach is to store it in a column defined as Oracle's XMLTYPE datatype. Otherwise store it as a CLOB.
Related
I have a DB with a large number of CLOB columns. Each of these columns contains a repeated set of characters, which are fillers designed to designate a paragraph break (I didn't design the tables).
Is there a way to write the script so that each time the script finds these characters it enters a paragraph or line break into the results that are returned, while still saying in the same row of the results?
The data would look like
"Hello all,XYZ!£$I can't get ... to work.XYZ!£$The error meassge says ..."
As an example:
SELECT *
FROM ALERTS
REPLACE(Alert_Text, 'XYZ!£$', CH(13))
(Obviously the above returns errors)
The ideal output of the query would be:
"Hello all,
I can't get ... to work.
The error meassge says ..."
I am using SqlDbx to connect to an Oracle DB.
The obvious error is ORA-00904: "CH": invalid identifier
The reason is, that the function name is CHR
select REPLACE(txt, 'XYZ!£$', CHR(13)) from tab;
REPLACE(TXT,'XYZ!£$',CHR(13))
--------------------------------------------------------------------------------
Hello all,
I can't get ... to work.
The error meassge says ...
I'm trying to run the below sql query.
SELECT sr.resultid, xt2.*
FROM RESULTS sr,
XMLTABLE('/extraInfo/resultsViewData'
PASSING XMLType(sr.extrainfo)
COLUMNS
docketNumber VARCHAR2(35) PATH 'docketNumber',
dateFiled VARCHAR2(35) PATH 'dateFiled',
nosDescription VARCHAR2(70) PATH 'nosDescription',
courtname VARCHAR2(100) PATH 'courtname',
chapter VARCHAR2(35) PATH 'chapter'
) xt2
WHERE sr.profileId = '7dd76222';
NOTE: sr.extrainfo has the value
'<extraInfo><resultsViewData><courtname>FL Circuit & County - Santa Rosa</courtname></resultsViewData></extraInfo>'
Even though I use '& amp ;' instead of '&', I still get the below error,
ORA-31011: XML parsing failed
ORA-19213: error occurred in XML processing at lines 1
LPX-00242: invalid use of ampersand ('&') character (use &)
ORA-06512: at "SYS.XMLTYPE", line 272
ORA-06512: at line 1
31011. 00000 - "XML parsing failed"
*Cause: XML parser returned an error while trying to parse the document.
*Action: Check if the document to be parsed is valid.
Sometimes I even get the error,
LPX-00242: invalid use of ampersand ('&') character (use &)
Is there any way to overcome this issue?
Try:
set define off;
Then execute your query;
If you want more info on what set define off; does: When or Why to use a "SET DEFINE OFF" in Oracle Database
I am not able to reproduce your issue at first place.
But still if you are getting the issue then try to use dbms_xmlgen.convert to convert your string as following:
'<extraInfo><resultsViewData><courtname>'
|| dbms_xmlgen.convert('FL Circuit & County - Santa Rosa')
|| '</courtname></resultsViewData></extraInfo>'
db<>fiddle demo
Cheers!!
I want to check if valid phone number is inserting in table, so my trigger code is here:
select start_index
into mob_index
from gmarg_mobile_operators
where START_INDEX = substr(:new.contact_info,0,3);
if (REGEXP_LIKE (:NEW.CONTACT_INFO,'^(?:'|| mob_index ||')[\-,\:]{0,1}[0-9][0-9][\-,\:]{0,1}[0-9][0-9][\-,\:]{0,1}[0-9][0-9]')) then
found := 1;
end if;
I've checked my regex: "^(?:555)[-,:]{0,1}[0-9][0-9][-,:]{0,1}[0-9][0-9][-,:]{0,1}[0-9][0-9]" on several online tools and it is correct.
When I run my trigger, it compiles successfully, but during inserting a row following error is shown:
insert into GMARG_CONTACTS
(CLINET_ID,CONTACT_INFO,contact_type_id)
values
(0,'555194117','Mobile')
Error report -
SQL Error: ORA-12728: invalid range in regular expression
ORA-06512: at "HR.GMARG_TRIGGER_CONTACT", line 12
ORA-04088: error during execution of trigger 'HR.GMARG_TRIGGER_CONTACT'
12728. 00000 - "invalid range in regular expression"
*Cause: An invalid range was found in the regular expression.
*Action: Ensure a valid range is being used.
So, if my regex is correct, why does oracle shows error?
I tried to find answer, or redifine my regex, but no forward steps...
thank you in advance
Regexp don't use \ to protect - in a bracket expression. You only have to put - as the first character, just after the opening bracket:
IF REGEXP_LIKE('--,,::', '[\-,:]*')
...
=> ORA-12728: invalid range in regular expression
If you're curious, when encountering [\-,:] Oracle understand: "any character in the range from \ to , or the character :". The reason why this raises an exception is \ appears to be after , according to their ASCII value. And Oracle don't accept range having a starting value after the ending one.
On the other hand:
IF REGEXP_LIKE('--,,::', '[-,:]*')
Works as expected.
As a side note, [-,:]{0,1} meaning "zero or one occurrence of - or , or :" could be written [-,:]?.
I m using sql query in the xsql file but I have ORA-00911: invalid character error. Same query is working directly on the database.
My index.xsql:
<?xml version="1.0" encoding="ISO-8859-2" ?>
<page connection="labor" xmlns:xsql="urn:oracle-xsql">
<xsql:query>
SELECT id, iata_dep, iata_arr FROM route JOIN flight ON route.route_id=flight.route_id
</xsql:query>
</page>
My browser result:
<?xml version="1.0" encoding="ISO-8859-2" ?>
<page connection="labor" xmlns:xsql="urn:oracle-xsql">
<xsql:query>
SELECT id, iata_dep, iata_arr FROM route JOIN flight ON route.route_id=flight.route_id
</xsql:query>
</page>
Where is the character problem?
Thanks,
There are several problems that can cause such behavior :
This error occurs when you try to use a special character in a SQL
statement. If a special character other than $, _, and # is used in
the name of a column or table, the name must be enclosed in double
quotations.
This error may occur if you've pasted your SQL into your editor from
another program. Sometimes there are non-printable characters that may
be present. In this case, you should try retyping your SQL statement
and then re-execute it.
This error occurs when a special character is used in a SQL WHERE
clause and the value is not enclosed in single quotations.
I am running the SELECT query from the Oracle SQL developer IDE on my RHEL box as below
SELECT count(*)
From xyz
WHERE xmltype(xyz.xmlColumn).existsNode('//name=""') = 1;
Above query works fine if I execute for single record. But when I execute it for the whole table it fails with the error:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00210: expected '<' instead of 'C'
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 272
ORA-06512: at line 1
31011. 00000 - "XML parsing failed"
*Cause: XML parser returned an error while trying to parse the document.
*Action: Check if the document to be parsed is valid.
Any pointers on above will help me.
include /text in your xpath. like
select (COLUM_NAME).extract('//parentNode/chileNode/text()').getStringVal() as Colum_Name from TableName where UUID='Value'
Oracle is complaining that "xyz.xmlColumn" is not a valid xml column or type. It expects <element>....</element> format
Your problem is what is stored in your CLOB is not an XML document as it is missing a root node. Since you are scanning the whole document in your extract you could just wrap it in an element to ensure you have 1 and only 1 root, at which point your XMLTYPE cast would work.
SELECT
XMLTYPE(''||clob_field||'').EXTRACT('//se/text()').getStringVal()
FROM tablename