When Calling A Function In Xmlforest The Function Is Called Twice (Doc ID 752072.1)

Last updated on FEBRUARY 08, 2017

Applies to:

Oracle Server - Enterprise Edition - Version: 10.2.0.3 to 11.1.0.7 - Release: 10.2 to 11.1
Information in this document applies to any platform.

Symptoms

-- Problem Statement:
When Calling A function in XMLFOREST the function is called twice.

SQL> create sequence seq1;

Sequence created.
SQL> create or replace function get_nextval return number
2 is
3 v_return_value number := 1;
4 begin
5 select seq1.nextval
6 into v_return_value
7 from dual
8 ;
9 dbms_output.put_line('Nextval = ' || v_return_value );
10 return( v_return_value );
11 end;
12 /

Function created.

SQL> set serveroutput on size 100000
SQL> select xmlForest( get_nextval as "Id").getStringVal() xml from dual;

XML
--------------------------------------------------------------------------------
<Id>2</Id>

Nextval = 1
Nextval = 2

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms