Updatexml function is returning error. Syntax problem....
I have a xmlfile which is shown below...
cat MYTEMP.xml
<?xml version="1.0" encoding = "AL32UTF8"?>
<ROWSET>
<ROW>
<EDETAIL>test</EDETAIL>
<T1>3</T1>
</ROW>
<ROW>
<EDETAIL> test1</EDETAIL>
<T1>4</T1>
</ROW>
<ROW>
<EDETAIL>test2 </EDETAIL>
<T1>2</T1>
</ROW>
<ROW>
<EDETAIL> </EDETAIL>
<T1>1</T1>
</ROW>
<ROW>
<EDETAIL> </EDETAIL>
<T1>5</T1>
</ROW>
</ROWSET>
I load this xmlfile into a xmltype column in a global temporary table.
I have to update edetail tag to '~:' if it contains only whitespace(s) in it.
I am trying the following command and its giving me error....
insert into gt_xmltype_tab(xmlfile1)
values(XMLType(bfilename('RESTOREDIR','MYTEMP.xml'),nls_charset_id('AL32UTF8')));
update gt_xmltype_tab set xmlfile1 = updatexml(xmlfile1, '/ROWSET/ROW/EDETAIL/text()','~:')
where extractvalue(xmlfile1, '/ROWSET/ROW/EDETAIL') IS NULL
I get the following error for the updatexml...
update gt_xmltype_tab set XMLFILE1 = updatexml(XMLFILE1 , '/ROWSET/ROW/EDETAIL/text()','~:')
ERROR at line 1:
ORA-19025: EXTRACTVALUE returns value of only one node
What is the correct way of doing it? What am I doing wrong?
What is the correct way of doing it? What am I doing wrong?The WHERE clause filters records from the table, not repeating elements from the XML document.
Actually, I'm not sure if you want one or the other...
If you've got multiple XML files in the table, and want to update (the table) only where there's something to update, then use existsNode in the WHERE clause to check if the XML possesses at least an "empty" element.
If there's only one XML in the table, no WHERE clause necessary.
As for the update (of the XML document), that's a little tricky.
Once into the table, whitespaces are not preserved, so there's actually no text() node to update.
A solution is to update the element as a whole :
UPDATE gt_xmltype_tab
SET xmlfile1 = updateXML( xmlfile1
, '/ROWSET/ROW/EDETAIL[not(text())]'
, XMLElement("EDETAIL", '~:') )
;
Similar Messages
-
PL/SQL function body returning SQL Query Problem
I have wandered around the forums and found quite a bit of helpful information that has gotten me to the point I am now at. Unfortuntely, PL/SQL is not my strongest point and I am getting an error when I attempt to run my report.
This is what I have for my package:
CREATE OR REPLACE PACKAGE LIB2.report_query
is
function create_report2(v1 IN varchar2) RETURN VARCHAR2;
end report_query;
CREATE OR REPLACE PACKAGE BODY LIB2.report_query
as
function create_report2(v1 in varchar2) return varchar2
is
l_vc_format HTMLDB_APPLICATION_GLOBAL.VC_ARR2 := HTMLDB_UTIL.STRING_TO_TABLE(v1);
l_format varchar2(255) := HTMLDB_UTIL.TABLE_TO_STRING(l_vc_format);
q1 varchar2(32767) := ' ';
begin
q1 :=
'select b.BOOK_ID, bk.book_id bkid, bkk.book_id bkkid, b.TITLE, b.SUBTITLE, b.SERIES, b.VOLUME, b.ISBN, f.FORMAT_RET, b.DESCRIPTION, .PUBLISHED,'
||'b.PURCHASED_FROM, b.COMMENTS, b.WEBSITE, c.LENGTH_MINS, stragg(p.last_name || '', '' || p.first_name) Author, '
||'stragg(p.person_id) person_id, '
||'pb.name PUBLISHER, decode(b.abridged, ''Y'',''Abridged'',''N'',''Unabridged'') Abridged,'
||'(nvl(d.disk01,0)+nvl(d.disk02,0)+nvl(d.disk03,0)+nvl(d.disk04,0)+nvl(d.disk05,0)+nvl(d.disk06,0)+nvl(d.disk07,0)+nvl(d.disk08,0)+'
||'nvl(d.disk09,0)+nvl(d.disk10,0)+nvl(d.disk11,0)+nvl(d.disk12,0)+nvl(d.disk13,0)+nvl(d.disk14,0)+nvl(d.disk15,0)+nvl(d.disk16,0)+nvl(d.disk17,0)+'
||'nvl(d.disk18,0)+nvl(d.disk19,0)+nvl(d.disk20,0)+nvl(d.disk21,0)+nvl(d.disk22,0)+nvl(d.disk23,0)+nvl(d.disk24,0)+nvl(d.disk25,0)+nvl(d.disk26,0)+'
||'nvl(d.disk27,0)+nvl(d.disk28,0)+nvl(d.disk29,0)+nvl(d.disk30,0)+nvl(d.disk31,0)+nvl(d.disk32,0)+nvl(d.disk33,0)+nvl(d.disk34,0)+nvl(d.disk35,0)+'
||'nvl(d.disk36,0)+nvl(d.disk37,0)+nvl(d.disk38,0)+nvl(d.disk39,0)+nvl(d.disk40,0)+nvl(d.disk41,0)+nvl(d.disk42,0)+nvl(d.disk43,0)+nvl(d.disk44,0)+'
||'nvl(d.disk45,0)+nvl(d.disk46,0)+nvl(d.disk47,0)+nvl(d.disk48,0)+nvl(d.disk49,0)+nvl(d.disk50,0)) total_tracks'
||'from book b, '
||'book bk,'
||'book bkk,'
||'person p,'
||'lkup_book_author la,'
||'lkup_book_publisher lp,'
||'lkup_book_format lkf,'
||'format f,'
||'publisher pb,'
||'conversion_info_audio c,'
||'lkup_book_disk_info d'
||'where b.book_id = la.book_id'
||'and b.book_id = bk.book_id'
||'and b.book_id = bkk.book_id'
||'and p.person_id = la.author_id'
||'and b.book_id = lp.book_id'
||'and b.book_id = c.book_id'
||'and b.book_id = d.book_id'
||'and b.book_id = lkf.book_id'
||'and lkf.format_id = f.format_id'
||'and pb.publisher_id(+) = lp.publisher_id'
||'and b.wishlist = ''N'''
||'and (upper(b.book_id) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.title) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.subtitle) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.series) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.volume) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.isbn) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.format) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.description) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.published) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.purchased_from) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.comments) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(b.website) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(p.last_name) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(p.first_name) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(pb.name) like ''%'' || upper(:P40_SEARCH) || ''%'''
||'or upper(:P40_SEARCH) is null)'
||'and ((upper(b.title) like ''%'' || upper(:P40_TITLE) || ''%'' or upper(:P40_TITLE) is null))'
||'and ((upper(b.series) like ''%'' || upper(:P40_SERIES) || ''%'' or upper(:P40_SERIES) is null))'
||'and ((upper(p.last_name) like ''%'' || upper(:P40_LASTNAME) || ''%'' or upper(:P40_LASTNAME) is null))'
||'and ((upper(p.first_name) like ''%'' || upper(:P40_FIRSTNAME) || ''%'' or upper(:P40_FIRSTNAME) is null))'
||'and ((upper(f.format_ret) in (upper(l_vc_format)) or upper(:P40_FORMAT) is null))'
||'group by b.BOOK_ID, bk.book_id, bkk.book_id, b.TITLE, b.SUBTITLE, b.SERIES, b.VOLUME, b.ISBN, f.FORMAT_ret, b.DESCRIPTION, '
||'b.PUBLISHED, b.PURCHASED_FROM, b.COMMENTS, b.WEBSITE, c.LENGTH_MINS, pb.name, b.abridged, '
||'(nvl(d.disk01,0)+nvl(d.disk02,0)+nvl(d.disk03,0)+nvl(d.disk04,0)+nvl(d.disk05,0)+nvl(d.disk06,0)+nvl(d.disk07,0)+nvl(d.disk08,0)+'
||'nvl(d.disk09,0)+nvl(d.disk10,0)+nvl(d.disk11,0)+nvl(d.disk12,0)+nvl(d.disk13,0)+nvl(d.disk14,0)+nvl(d.disk15,0)+nvl(d.disk16,0)+nvl(d.disk17,0)+'
||'nvl(d.disk18,0)+nvl(d.disk19,0)+nvl(d.disk20,0)+nvl(d.disk21,0)+nvl(d.disk22,0)+nvl(d.disk23,0)+nvl(d.disk24,0)+nvl(d.disk25,0)+nvl(d.disk26,0)+'
||'nvl(d.disk27,0)+nvl(d.disk28,0)+nvl(d.disk29,0)+nvl(d.disk30,0)+nvl(d.disk31,0)+nvl(d.disk32,0)+nvl(d.disk33,0)+nvl(d.disk34,0)+nvl(d.disk35,0)+'
||'nvl(d.disk36,0)+nvl(d.disk37,0)+nvl(d.disk38,0)+nvl(d.disk39,0)+nvl(d.disk40,0)+nvl(d.disk41,0)+nvl(d.disk42,0)+nvl(d.disk43,0)+nvl(d.disk44,0)+'
||'nvl(d.disk45,0)+nvl(d.disk46,0)+nvl(d.disk47,0)+nvl(d.disk48,0)+nvl(d.disk49,0)+nvl(d.disk50,0))';
RETURN q1;
EXCEPTION
WHEN OTHERS THEN
RETURN q1;
end create_report2;
end;
And here is what I have for my Region Source on my report:
return lib2.report_query.create_report2(v('P40_FORMAT'));
Here is my error when I run the page:
failed to parse SQL query:
ORA-00936: missing expression
I have tried the region source line in many variations, this is just my latest one. None of them have worked. I am quite obviously missing something quite important and probably extremely silly. Any ideas?
Thanks!
ChrissyChrissy,
This is what the package returns as a query:
select b.BOOK_ID, bk.book_id bkid, bkk.book_id bkkid,
b.TITLE, b.SUBTITLE, b.SERIES, b.VOLUME, b.ISBN, f.FORMAT_RET,
b.DESCRIPTION, .PUBLISHED,b.PURCHASED_FROM, b.COMMENTS, b.WEBSITE,
c.LENGTH_MINS, stragg(p.last_name || ', ' || p.first_name) Author,
stragg(p.person_id) person_id, pb.name PUBLISHER, decode(b.abridged,
'Y','Abridged','N','Unabridged') Abridged,
(nvl(d.disk01,0)+nvl(d.disk02,0)+nvl(d.disk03,0)+nvl(d.disk04,0)+nvl(d.disk05,0)
nvl(d.disk06,0)nvl(d.disk07,0)+nvl(d.disk08,0)+nvl(d.disk09,0)+nvl(d.disk10,0)
nvl(d.disk11,0)nvl(d.disk12,0)+nvl(d.disk13,0)+nvl(d.disk14,0)+nvl(d.disk15,0)
nvl(d.disk16,0)nvl(d.disk17,0)+nvl(d.disk18,0)+nvl(d.disk19,0)+nvl(d.disk20,0)
nvl(d.disk21,0)nvl(d.disk22,0)+nvl(d.disk23,0)+nvl(d.disk24,0)+nvl(d.disk25,0)
nvl(d.disk26,0)nvl(d.disk27,0)+nvl(d.disk28,0)+nvl(d.disk29,0)+nvl(d.disk30,0)
nvl(d.disk31,0)nvl(d.disk32,0)+nvl(d.disk33,0)+nvl(d.disk34,0)+nvl(d.disk35,0)
nvl(d.disk36,0)nvl(d.disk37,0)+nvl(d.disk38,0)+nvl(d.disk39,0)+nvl(d.disk40,0)
nvl(d.disk41,0)nvl(d.disk42,0)+nvl(d.disk43,0)+nvl(d.disk44,0)+nvl(d.disk45,0)
nvl(d.disk46,0)nvl(d.disk47,0)+nvl(d.disk48,0)+nvl(d.disk49,0)+nvl(d.disk50,0)) total_tracksfrom book b,
book bk,book bkk,person p,lkup_book_author la,lkup_book_publisher lp,
lkup_book_format lkf,format f,publisher pb,conversion_info_audio c,
lkup_book_disk_info dwhere b.book_id = la.book_idand b.book_id = bk.book_idand b.book_id = bkk.book_idand p.person_id = la.author_idand
b.book_id = lp.book_idand b.book_id = c.book_idand b.book_id = d.book_idand
b.book_id = lkf.book_idand lkf.format_id = f.format_idand pb.publisher_id(+) = lp.publisher_idand
b.wishlist = 'N'and (upper(b.book_id) like '%' || upper(:P40_SEARCH) || '%'
or upper(b.title) like '%' || upper(:P40_SEARCH) || '%'or upper(b.subtitle) like '%' ||
upper(:P40_SEARCH) || '%'or upper(b.series) like '%' || upper(:P40_SEARCH) || '%'or
upper(b.volume) like '%' || upper(:P40_SEARCH) || '%'or upper(b.isbn) like '%' ||
upper(:P40_SEARCH) || '%'or upper(b.format) like '%' || upper(:P40_SEARCH) || '%'or upper(b.description) like '%' || upper(:P40_SEARCH) || '%'or upper(b.published)
like '%' || upper(:P40_SEARCH) || '%'or upper(b.purchased_from) like '%' ||
upper(:P40_SEARCH) || '%'or upper(b.comments) like '%' || upper(:P40_SEARCH)
|| '%'or upper(b.website) like '%' || upper(:P40_SEARCH) || '%'or
upper(p.last_name) like '%' || upper(:P40_SEARCH) || '%'or upper(p.first_name)
like '%' || upper(:P40_SEARCH) || '%'or upper(pb.name) like '%' ||
upper(:P40_SEARCH) || '%'or upper(:P40_SEARCH) is null)and
((upper(b.title) like '%' || upper(:P40_TITLE) || '%' or
upper(:P40_TITLE) is null))and ((upper(b.series) like '%' ||
upper(:P40_SERIES) || '%' or upper(:P40_SERIES) is null))and
((upper(p.last_name) like '%' || upper(:P40_LASTNAME) || '%' or
upper(:P40_LASTNAME) is null))and ((upper(p.first_name) like '%' ||
upper(:P40_FIRSTNAME) || '%' or upper(:P40_FIRSTNAME) is null))and
((upper(f.format_ret) in (upper(l_vc_format)) or upper(:P40_FORMAT) is null))
group by b.BOOK_ID, bk.book_id, bkk.book_id, b.TITLE, b.SUBTITLE, b.SERIES, b.VOLUME,
b.ISBN, f.FORMAT_ret, b.DESCRIPTION, b.PUBLISHED, b.PURCHASED_FROM, b.COMMENTS, b.WEBSITE,
c.LENGTH_MINS, pb.name, b.abridged, (nvl(d.disk01,0)+nvl(d.disk02,0)+nvl(d.disk03,0)
nvl(d.disk04,0)nvl(d.disk05,0)+nvl(d.disk06,0)+nvl(d.disk07,0)+nvl(d.disk08,0)
nvl(d.disk09,0)nvl(d.disk10,0)+nvl(d.disk11,0)+nvl(d.disk12,0)+nvl(d.disk13,0)
nvl(d.disk14,0)nvl(d.disk15,0)+nvl(d.disk16,0)+nvl(d.disk17,0)+nvl(d.disk18,0)
nvl(d.disk19,0)nvl(d.disk20,0)+nvl(d.disk21,0)+nvl(d.disk22,0)+nvl(d.disk23,0)
nvl(d.disk24,0)nvl(d.disk25,0)+nvl(d.disk26,0)+nvl(d.disk27,0)+nvl(d.disk28,0)
nvl(d.disk29,0)nvl(d.disk30,0)+nvl(d.disk31,0)+nvl(d.disk32,0)+nvl(d.disk33,0)
nvl(d.disk34,0)nvl(d.disk35,0)+nvl(d.disk36,0)+nvl(d.disk37,0)+nvl(d.disk38,0)
nvl(d.disk39,0)nvl(d.disk40,0)+nvl(d.disk41,0)+nvl(d.disk42,0)+nvl(d.disk43,0)
nvl(d.disk44,0)nvl(d.disk45,0)+nvl(d.disk46,0)+nvl(d.disk47,0)+nvl(d.disk48,0)
nvl(d.disk49,0)nvl(d.disk50,0))
This query will never work. I marked only couple of errors you have there. Actually,
I meant "formating" errors rather than "syntactical" errors. You are missing spaces
all over the place. This is why I suggested to use a CLOB column in a test table
to return the query for debugging purposes - this is how I do it at least, when I need
to escape and concatenate a lot of code.
If you are referencing item values from a user session in a function or a procedure,
then you need to use the v('ITEM') syntax instead of :ITEM syntax. However, if the
output of this procedure will be used as a function returning SQL query, you will
be fine with :ITEM.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://htmldb.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
Old bug returns - error message: problem with play...
This results in there being no sound on my computer at all. Have tried all fixes listed previously. What to do next? and why don't the skype people iron out this bug?
Hi
In my opinion there could be something wrong with the cooling module and the replacement would be necessary.
Usually this should be done by an authorized service provider (ASP) in your country.
The technicians could replace it with a new part and also could renew the thermal grease which is placed between the cooling module and CPU.
Therefore contact the ASP in your country and ask for the further handling!!!
By the way; you can purchase the cooling module also from the ASP!!!
Good luck -
PL/SQL function body returning SQL - report error:ORA-01403: no data found
Hi,
I am working on Application Express 4.0.2.00.06, and 11G database.
I have a problem with classic report area of type - PL/SQL function body returning SQL query. Query works if I define region area as - Use Generic Column Names (parse query at runtime only), and does not when I define it - Use Query-Specific Column Names and Validate Query.
I am getting error:
report error:ORA-01403: no data found
This is my query that is returned from function, and displayed with htp.p, and it works ok and returns data in SQL Developer and SQL Workshop (in Apex).
<code>
/* select 1 from dual */ SELECT SIFPRO, NAZIV, VODITELJ, DATPZA,SUM(DECODE(TJEDAN,'2010/46',BRDJEL,null)) as "2010/46" ,SUM(DECODE(TJEDAN,'2010/49',BRDJEL,null)) as "2010/49" ,SUM(DECODE(TJEDAN,'2010/50',BRDJEL,null)) as "2010/50" ,SUM(DECODE(TJEDAN,'2010/51',BRDJEL,null)) as "2010/51" ,SUM(DECODE(TJEDAN,'2010/52',BRDJEL,null)) as "2010/52" ,SUM(DECODE(TJEDAN,'2011/01',BRDJEL,null)) as "2011/01" ,SUM(DECODE(TJEDAN,'2011/02',BRDJEL,null)) as "2011/02" ,SUM(DECODE(TJEDAN,'2011/03',BRDJEL,null)) as "2011/03" ,SUM(DECODE(TJEDAN,'2011/04',BRDJEL,null)) as "2011/04" ,SUM(DECODE(TJEDAN,'2011/05',BRDJEL,null)) as "2011/05" ,SUM(DECODE(TJEDAN,'2011/06',BRDJEL,null)) as "2011/06" ,SUM(DECODE(TJEDAN,'2011/07',BRDJEL,null)) as "2011/07" ,SUM(DECODE(TJEDAN,'2011/08',BRDJEL,null)) as "2011/08" ,SUM(DECODE(TJEDAN,'2011/09',BRDJEL,null)) as "2011/09" ,SUM(DECODE(TJEDAN,'2011/10',BRDJEL,null)) as "2011/10" FROM (SELECT * FROM PMV_PLAN_TVRTKA) GROUP BY SIFPRO, NAZIV, VODITELJ, DATPZA ORDER BY SIFPRO, NAZIV, VODITELJ, DATPZA
</code>
As you can see, I even tried with workaround that I found on the previous post on the forum, and that is to put /* select 1 from dual */ to start query.
Any help would be appriciated./* select 1 from dual */ SELECT SIFPRO, NAZIV, VODITELJ, DATPZA,SUM(DECODE(TJEDAN,'2010/46',BRDJEL,null)) as "2010/46" ,SUM(DECODE(TJEDAN,'2010/49',BRDJEL,null)) as "2010/49" ,SUM(DECODE(TJEDAN,'2010/50',BRDJEL,null)) as "2010/50" ,SUM(DECODE(TJEDAN,'2010/51',BRDJEL,null)) as "2010/51" ,SUM(DECODE(TJEDAN,'2010/52',BRDJEL,null)) as "2010/52" ,SUM(DECODE(TJEDAN,'2011/01',BRDJEL,null)) as "2011/01" ,SUM(DECODE(TJEDAN,'2011/02',BRDJEL,null)) as "2011/02" ,SUM(DECODE(TJEDAN,'2011/03',BRDJEL,null)) as "2011/03" ,SUM(DECODE(TJEDAN,'2011/04',BRDJEL,null)) as "2011/04" ,SUM(DECODE(TJEDAN,'2011/05',BRDJEL,null)) as "2011/05" ,SUM(DECODE(TJEDAN,'2011/06',BRDJEL,null)) as "2011/06" ,SUM(DECODE(TJEDAN,'2011/07',BRDJEL,null)) as "2011/07" ,SUM(DECODE(TJEDAN,'2011/08',BRDJEL,null)) as "2011/08" ,SUM(DECODE(TJEDAN,'2011/09',BRDJEL,null)) as "2011/09" ,SUM(DECODE(TJEDAN,'2011/10',BRDJEL,null)) as "2011/10" FROM (SELECT * FROM PMV_PLAN_TVRTKA) GROUP BY SIFPRO, NAZIV, VODITELJ, DATPZA ORDER BY SIFPRO, NAZIV, VODITELJ, DATPZA
-
Function returning error text validation
Hi,
I have a page where i can insert/update user, organisation, responsible.
Organisation can be nullable.
Only one user at a time can be responsible for a organisation.
To check this responsible validation i made a function returning error text validation as follow:
BEGIN
FOR c IN (SELECT usr_spa
FROM kpi_users
WHERE usr_org_id = :p22_usr_org_id
LOOP
IF upper(:p22_usr_spa) = upper('YES') and upper(c.usr_spa) = upper('YES')
THEN
RETURN 'A user is already responsible for this organisation'||'!';
END IF;
END LOOP;
END;
The validation works fine.
But it goes wrong when i want to insert a new user, without assigning him to an organisation.
I get following message:
ORA-01722: invalid number
ERR-1024 Unable to run "function body returning text" validation.
Can someone please help me solve this problem?
ThanksHi,
try:
BEGIN
FOR c IN (SELECT usr_spa
FROM kpi_users
WHERE usr_org_id = nvl(:p22_usr_org_id,-1)
LOOP
IF upper(:p22_usr_spa) = upper('YES') and upper(c.usr_spa) = upper('YES')
THEN
RETURN 'A user is already responsible for this organisation'||'!';
END IF;
END LOOP;
END;This assumes that :p22_usr_org_id could be null and converts this to -1 (pick another default value if this may exist as an id). It is possible that the statement would otherwise be seen as WHERE usr_org_id = null which is invalid.
or you could do:
BEGIN
IF :p22_usr_org_id IS NOT NULL THEN
FOR c IN (SELECT usr_spa
FROM kpi_users
WHERE usr_org_id = :p22_usr_org_id
LOOP
IF upper(:p22_usr_spa) = upper('YES') and upper(c.usr_spa) = upper('YES')
THEN
RETURN 'A user is already responsible for this organisation'||'!';
END IF;
END LOOP;
END IF;
END;As this would stop the validation running if the :p22_usr_org_id is null.
Or, you could just make your validation conditional on p22_usr_org_id not being null?
Andy -
PL/SQL function body return sql query, no data found problem
Hi all,
we are trying to build a dynamic report based on item selection by user. we are using SQL Query (PL/SQL function body returning SQL query). However when a user change the item and submit the page . The following error appears.
ORA-01403: no data found.
our query is so simple
declare
l_query varchar2(30000) default 'select id from chw';
begin
if(:P11_PARA=1) then
l_query:='select name from chw';
end if;
return l_query;
end;
any quick help please.Hello Mike,
I tried it, the problem still exists.
ORA-01403: no data found
my new code is
declare
l_query varchar2(30000) default 'select id from chw';
begin
if (nvl(TO_NUMBER(:P11_PARA),0) = 1) then
l_query:='select name from chw';
end if;
return (l_query);
end;
note, there is no process in this page.
Edited by: M.Jabr on Oct 14, 2009 6:13 AM -
Problem Description:
ODBC functions SQLExecDirectW and SQLExecute functions return error:”DIAG [22001] [Microsoft][SQL Server Native Client 10.0]String data, right
truncation (0) “. When we enable tracing in the ODBC administrator, in the SQL.log we see that values for the arguments: ColumnSize, BufferLength, and StrLen_or_IndPtr of ODBC function SQLBindParameter are not being displayed.
Environment Used:
OS: Microsoft Windows Server 2003 R2 Standard x64 Edition.
Complier: Microsoft Visual Studio 2008 SP1 for x64.
Database: Microsoft SQL Server 2008
MDAC: Microsoft Data Access Components SDK 2.8
Note: This problem is seen only in our 64bit application. However, in 32bit
SQLExecDirectW and SQLExecute functions return successfully.
As we could not find the values of 6<sup>th</sup>, 9<sup>th</sup> and 10<sup>th</sup> arguments(ColumnSize,
BufferLength, and StrLen_or_IndPtr) passed to
SQLBindParameter in the ODBC traces for 64bit, we are not sure whether the values for the above mentioned arguments are received correctly by SQLBindParameter or not. This information would help us to debug further. So, could you please let us know why
these values are not displayed.
1)Here is the extract of the SQL.log file for 32bit where the values for SQLULEN , SQLLEN and SQLLEN* are displayed properly:
PR0CNFG 1028-15f0 ENTER SQLBindParameter
HSTMT 0x006FBDD8
UWORD 1
SWORD 1 <SQL_PARAM_INPUT>
SWORD -8 <SQL_C_WCHAR>
SWORD -9 <SQL_WVARCHAR>
SQLULEN 23
SWORD 0
PTR 0x0595EBBA
SQLLEN 46
SQLLEN * 0x05A5FB00
2)Here is the extract of the SQL.log file for 64bit where the values for SQLULEN , SQLLEN are not displayed properly and
SQLExecDirectW function return error:”DIAG
[22001] [Microsoft][SQL Server Native Client 10.0]String data, right truncation (0) “. :
PR0CNFG a78-fe4 ENTER SQLBindParameter
HSTMT 000000000431D2F0
UWORD 1
SWORD 1 <SQL_PARAM_INPUT>
SWORD -8 <SQL_C_WCHAR>
SWORD -9 <SQL_WVARCHAR>
SQLULEN SQLULEN SWORD 0
PTR 0x0000000005364EFA
SQLLEN SQLLEN
SQLLEN * SQLLEN *
PR0CNFG a78-fe4 EXIT SQLBindParameter with return code 0 (SQL_SUCCESS)
HSTMT 000000000431D2F0
UWORD 1
SWORD 1 <SQL_PARAM_INPUT>
SWORD -8 <SQL_C_WCHAR>
SWORD -9 <SQL_WVARCHAR>
SQLULEN SQLULEN SWORD 0
PTR 0x0000000005364EFA
SQLLEN SQLLEN SQLLEN *Hi Nalsr,
From my research, I found:
"[Microsoft][ODBC SQL Server Driver]String
data right truncation" error may be returned from a call to
SQLBindParameter if the size of the string parameter being used is greater than the size of the column being compared to. In other words if the
string size of the <expression> to the left of the <comparison_operator> is less than the
string size of the <expression> to the
right, ODBC may return this error.
The resolution is to make the string size of the <expression> to the
right of the <comparison_operator> less than or equal to the
string size of the <expression> on the left.
It is difficult to track down this type of problem when third party development applications are being used. ODBC Trace can be used to help determine if this problem is occuring.
Here is an example where the customer has submitted a query "select count(*) from type1 where type1 = ?", type1 is varchar(5) and the
data type being passed by the application is char[9].
Here is the relevant portion of the trace. The following information from the "exit" of SQLDescribeParam
SWORD * 0x0095e898 (12)
UDWORD * 0x0095e880 (5)
Maps to the following with the actual value in parenthesis - SQL_VARCHAR Size 5:
SQLSMALLINT *DataTypePtr
SQLUINTEGER *ParameterSizePtr
The "exit" value from SQLBindParameter provides the following
information:
SWORD 1 <SQL_PARAM_INPUT>
SWORD 1 <SQL_C_CHAR>
SQL Data Type SWORD 12 <SQL_VARCHAR>
Parameter Size UDWORD 5
SWORD 0
Value PTR 0x0181c188
Value Buffer Size SDWORD 5
String Length SDWORD * 0x0181c103 (9)
The string length parameter is the length of the
string being bound to the parameter, in this instance there is a size mismatch which results in the SQLError and the SQLErrorW with the message "[Microsoft][ODBC SQL Server
Driver]String data
right truncation" .
Hope this could be helpful.
Best regards,
Halin Huang -
I'm attempting to dynamically generate a rather large SQL query via the "PL/SQL function body returning SQL query" report region option. The SQL query generated will possibly be over 32K. When I execute my page, I sometimes receive the "ORA-06502: PL/SQL: numeric or value error" which points to a larger than 32K query that was generated. I've seen other posts in the forum related to this dynamic SQL size limitation issue, but they are older (pre-2010) and point to the 32K limit of the DNS (EXECUTE IMMEDIATE) and DBMS_SQL. I found this post (dynamic sql enhancements in 11g) which discusses 11g no longer having the 32K size limitation for generating dynamic SQL. Our environment is on 11gR2 and using ApEx 4.2.1. I do not know which dynamic SQL method -- DNS or DBMS_SQL -- ApEx 4.2.1 is using. Can someone clarify for me which dynamic SQL method ApEx uses to implement the "PL/SQL function body returning SQL query" option?
As a test, I created a page on apex.oracle.com with a report region with the following source:
declare
l_stub varchar2(25) := 'select * from sys.dual ';
l_sql clob := l_stub || 'union all ';
br number(3) := 33;
begin
while length ( l_sql ) < 34000 loop
l_sql := l_sql || l_stub || 'union all ';
end loop;
l_sql := l_sql || l_stub;
for i in 1 .. ceil ( length ( l_sql ) / br ) loop
dbms_output.put_line ( dbms_lob.substr ( l_sql, br, ( ( i - 1 ) * br ) + 1 ) );
end loop;
return l_sql;
end;
The dbms_output section is there to be able to run this code in SQL*Plus and confirm the size of the SQL is indeed larger than 32K. When running this in SQL*Plus, the procedure is successful and produces a proper SQL statement which can be executed. When I put this into the report region on apex.oracle.com, I get the ORA-06502 error.
I can certainly implement a work-around for my issue by creating a 'Before Header' process on the page which populates an ApEx collection with the data I am returning and then the report can simply select from the collection, but according to documentation, the above 32K limitation should be resolved in 11g. Thoughts?
Shane.What setting do you use in your report properties - especially in Type and in Region Source?
If you have Type="SQL Query", then you should have a SELECT statement in the Region Source. Something like: SELECT .... FROM ... WHERE
According to the ERR-1101 error message, you have probably set Type to "SQL Query (PL/SQL function body returning SQL query)". In this situation APEX expects you to write a body of a PL/SQL function, that will generate the text of a SQL query that APEX should run. So it can be something like:
declare
mycond varchar2(4000);
begin
if :P1_REPORT_SEARCH is not null THEN
mycond:='WHERE LAST_NAME like :P1_REPORT_SEARCH ||''%''';
end if;
return 'select EMPLOYEE_ID, FIRST_NAME, LAST_NAME from EMPLOYEES ' ||mycond;
end;
And for escaping - are you interested in escaping the LIKE wildcards, or the quotes?
For escaping the wildcards in LIKE function so that when the user enters % you will find a record with % and not all functions, look into the SQL Reference:
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm
(You would than need to change the code of your function accordingly).
If you are interested in escaping the quotes, try to avoid concatenating the values entered by the user into the SQL. If you can, use bind variables instead - as I have in my example above. If you start concatenating the values into the text of SQL, you are open to SQLInjection - user can enter anything, even things that will break your SQL. If you really need to allow users to choose the operator, I would probably give them a separate combo for operators and a textfield for values, than you could check if the operator is one of the allowed ones and create the condition accordingly - and than still use bind variable for inserting the filtering value into the query. -
Error in report when executing pl/sql function body returning sql query.
Hi,
I have used the pl/sql function body returning sql query for creating a report. I have created a datepicker(
P10_TASK_DATE) which can be submitted.The code is as below
DECLARE
v_sql varchar2(3000);
BEGIN
if :P10_TASK_DATE is not null THEN
v_sql:='select
* from tasks';
return v_sql;
else
v_sql:='select * from discovery';
return v_sql;
END IF;
END;if the date field is empty "select * from discovery" is executed and report is getting generated. But when we give a
date using date picker the page is submitted and i get "report error: ORA-01403: no data found" even
though the "tasks" table has data in it. Plz help
Thanks,
TJhi
Please try this
1. Create 2 region
1st region source=
select * from tasks'
go to the tab -> condition =
item NOT NULL
EXpression1 =:P10_TASK_DATE
this will run whenever the item have any date
2. open your 2 nd region source code= select * from discovery
put the condition
item is NULL
EXpression1 =:P10_TASK_DATE
thanks
Mark Wyatt -
Function returning error - change notification
I have a function returning error text. When error occurs I get the message
'xx error has occurred' on the screen (in notification). Is there a way to control the message text so I can display different text?It's something like this:
DECLARE l_code zip.code%TYPE;
got_error varchar2(1) := 'N';
l_check_fld varchar2(30000);
l_error_fld varchar2(32000);
vErrorFields varchar2(1000);
CURSOR check_zip IS
select ''
from zip
where code = l_code;
BEGIN
apex_collection.create_or_truncate_collection('ZIP');
FOR i IN 1 .. apex_application.g_f03.COUNT LOOP
vErrorFields := '';
/* Code MUST be entered */
if (apex_application.g_f03(i) is null and
(apex_application.g_f04(i) is not null or
apex_application.g_f05(i) is not null))then
got_error := 'Y';
vErrorFields := vErrorFields || ',f03';
l_error_fld := l_error_fld || 'Row ' || to_char(i) || ':' ||' <span style="color: red">Code cannot be <strong>blank.</strong></span><br>';
end if;
END LOOP;
if got_error = 'N' then
apex_collection.delete_collection('ZIP');
end if;
RETURN l_error_fld;
END; -
To_numer function return error in pl/sql
Hello,
I don't have a prob when running select to_number('1234.56') from dual, the numer contains digit decimal
But this stm return error Invalid number in procedure unless I use to_number('1234.56','9999999.99')
Please help me out.
Do I have to set parameter in DB ?
BTW: my NLS_NUMERIC_CHARACTER is set to '.,'
Thanks.to_numer function return error in pl/sql
hlthanh wrote:
Hello,
I don't have a prob when running select to_number('1234.56') from dual, the numer contains digit decimal
But this stm return error Invalid number in procedure unless I use to_number('1234.56','9999999.99')
Please help me out.
Do I have to set parameter in DB ?
BTW: my NLS_NUMERIC_CHARACTER is set to '.,'
Thanks.Handle: hlthanh
Status Level: Newbie
Registered: Mar 7, 1999
Total Posts: 94
Total Questions: 60 (38 unresolved)
so many questions & so few answers.
How SAD! -
UDPWrite in a loop. "A Windows Sockets function call returned an unexpected error."
Hello together,
i use UDP Support Library in NI CVI 9.0. When i wait for receiving a packet at the pc to send then a packet from the pc, the functions UDPRead and UDPWrite work fine. If i want to test the maximum throughput, i put the UDPWrite in a loop, but then an error occurs. It is "kUDP_UnexpectedWinsockError"
Error Popup:
"NON-FATAL RUN-TIME ERROR: "main.c", line 53, col 22, thread id
0x00000C18: Library function error (return value == -6822
[0xffffe55a]). A Windows Sockets function call returned an unexpected
error."
Line 53:
status = UDPWrite (channel, 60100, "192.168.1.10", pOutputBuffer, 1458);
the whole loop:
while(1)
status = UDPWrite (channel, 60100, "192.168.1.10", pOutputBuffer, 1458);
counter++;
if(counter>50)
break;
else{;}
The error occurs after 3-16 packets have been sent. If i step through the programm, no error occurs. So i guess its because the UDPWrite command is invoked too fast. pOutputBuffer has static data. I could use a delay in the loop, but then i dont know how to configure for maximal throughput.
Any ideas how to avoid this error?
Regards FlorianHello and thank you for your answer. Sorry that i reply a month later.
I dont know what you mean by "let 'er rip approach". Do you mean something like:
status = UDPWrite (channel, 60100, "192.168.1.10", pOutputBuffer, 1458);
if(status==0)
counter++;
else
Delay(0.00005);
I did not yet try to put the packet number in the payload, but there is just a 30 cm crossover cable between the two devices, no switch, no router. So the sequence should not be interruptet. And even if they arrive in chaos, i dont mind.
I have contacted the NI support 2 weeks ago, but no response yet.
I did some tests with a delay between the execution of UDPWrite(). The code:
float time = 0.0;
for(i = 1; i < 1000; i++)
status = UDPWrite (channel, 60100, "192.168.1.10", pOutputBuffer, 1458);
time = 1.0 / i;
Delay(time);
The results:
For i between 1 and 1000: no error, the speed of the last ten packets was about 6.5 MBit/s
For i between 1000 and 2000: error occured at i = 1585 (variable time in Delay was 0.0006313), the speed of the last ten packets was about 8 MBit/s
Then i put some constant values in Delay and ran 100 UDPWrite iterations:
Delay(0.0006): 7.48 MBit/s
Delay(0.0001): 10.7 MBit/s
Delay(0.00001): error occured at i=31, speed of 31 packets was 12.0 MBit/s
Delay(0.00008): 100 of 100 packets, speed 10.9 MBit/s
Delay(0.00005): error at i=41, speed of 41 packets 11.1 MBit/s -
Error while calling the function which returns SQL Query!!!
Hi,
I have a Function which returns SQL query. I am calling this function in my APEX report region source.
The query is dynamic SQL and its size varies based on the dynamic "where clause" condition.
But I am not able to execute this function.It gives me the following error in APEX region source.
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Even in SQL* Plus or SQL developer also same error .
The length of my query is more than 4000. I tried changing the variable size which holds my query in the function.
Earlier it was
l_query varchar2(4000)
Now I changed to
l_query varchar2(32767).
Still it is throwing the same error.
Can anybody help me to resolve this.???
Thanks
AlakaHi Varad,
I am already using 32k of varchar2. Then also it is not working.
It is giving the same error. I think there is something to do with buffer size.
My query size is not more than 4200. Even if i give 32k of varchar2 also buffer is able to hold only 3997 size of the query only.
Error is
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Tried CLOB also. It is not working.
Any other solution for this.
Thanks
Alaka -
Why MATLAB Language Syntax Return Error 1048?
Why Does My Script Written in The MathWorks, Inc. MATLAB® Language Syntax Return Error 1048?
x = (0:0.1:10)';
y = sin(2*x)./exp(x/5);
trnData = [x y];
numMFs = 5;
mfType = 'gbellmf';
epoch_n = 20;
in_fis = genfis1(trnData,numMFs,mfType);
out_fis = anfis(trnData,in_fis,20);
aa = evalfis([x x1],out_fis);
http://www.mathworks.com/help/fuzzy/anfis.htmlWhat do you get if you define the output as a 2D array?
(Or transpose the vector. Remember that matlab has a distinction between row and column vectors and LabVIEW does not). If you create a 2D array, it can be 1xN or Nx1 and you get all elements either way.)
LabVIEW Champion . Do more with less code and in less time . -
Bpel variables return Http 503 (problem building schema) error
First of all if I have posted this in the wrong forum, I apologise in advance.
I have recently installed the Oracle SOA suite and I have downloaded JDeveloper 10.1.3.3, I am running the (http://download.oracle.com/otndocs/products/bpel/orderbooking.pdf) Oracle® BPEL Process Manager Tutorial and when attempting to create a copy rule I have noticed that some of my variables return the following error:
Exception - Problem building schema
expanded error:
Exception: Server returned HTTP response code: 503 for URL: http://MYID.MYDOMAIN.com:80/orabpel/default/CreditRatingService/CreditRatingService?wsdl
I can access the WSDL directly and it is visible in my Bpel console window too, yet JDeveloper seems to be having trouble with it. I have setup an integration server connection to the BPEL server and from there, when I attempt to validate WSDL I don't get any problems.
I was wondering if anyone could help as this has got me stuck and I can't continue any further.
Edited by: Saheem on Jun 8, 2009 3:33 PMDisable the proxy settings in JDeveloper.
Marc
Maybe you are looking for
-
How to populate multiple text boxes by selecting a value from drop down
I apologize in advance if this is redundant, but I have searched this forum relentlessly to no avail. I have a form connected to an MS Access database. The database is linked to another datadase on an Advantage server. This is dynamic data that has
-
I am using Acrobat 9 Pro. Update 9.2.0 - CPSID_50026
I installed this update yesterday and since then I have not been able to use Acrobat. I cannot uninstall the UPdate (help anyone?) and I cannot uninstall Acrobat either . Help again please? Thanks for any guisdance on this.
-
After I formatted my hardri've, I am unable to re-install or find the original CD drivers for WinXP...where/how can I get these files so Napster can see my device?
-
Org model for sales and service
Hi, I have an issue while creating org model, I want to maintain organization for sales and service differently under a org unit, but in service org element when I have selected service radio button and type also as service in Function tab, it is ef
-
POP3 Apple Mail vs M-Me Mail - any conflicts? (besides bandwidth overload.)
As long-time user, with four year's traffic totaling over 10 MB of mail folders and posts (not including media or downloads), I love the idea of having it both ways:: MobileMe web access, when on the move, and traditional local storage of posts, for