My Oracle Support Banner

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

Last updated on APRIL 12, 2022

Applies to:

Oracle Database - Enterprise Edition - Version to [Release 10.2 to 11.1]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Information in this document applies to any platform.


-- 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;


Nextval = 1
Nextval = 2


To view full details, sign in with your My Oracle Support account.

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

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.