Home » SQL & PL/SQL » SQL & PL/SQL » Call a function with parameters passed as a XML
Call a function with parameters passed as a XML [message #191185] Tue, 05 September 2006 02:23 Go to next message
ltomovski
Messages: 1
Registered: September 2006
Junior Member
Hi
I want to make a procedure that calls a function depending on a XML that is passed to the procedure. For example the XML has the function name and the parameters the function needs (different data types)
Can you give me an example or some directions
Thanks in advance
Re: Call a function with parameters passed as a XML [message #191244 is a reply to message #191185] Tue, 05 September 2006 05:59 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Extract the function and parameters from your xml and build a plsql block with it (stored in a string).
Use dynamic sql to execute this block.

Warning: can easily become monstrous, can be difficult to debug, security issues, maintainability.

[Updated on: Tue, 05 September 2006 06:00]

Report message to a moderator

Re: Call a function with parameters passed as a XML [message #191391 is a reply to message #191244] Wed, 06 September 2006 01:58 Go to previous messageGo to next message
orafaqer
Messages: 48
Registered: July 2006
Member
Frank wrote on Tue, 05 September 2006 14:59

..
Warning: can easily become monstrous, can be difficult to debug, security issues, maintainability.

Java Stored Procedure is one of the possible alternatives for PL, and it seems to be an appropriate approach for this task.
Re: Call a function with parameters passed as a XML [message #191392 is a reply to message #191391] Wed, 06 September 2006 02:02 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
orafaqer wrote on Wed, 06 September 2006 08:58

Java Stored Procedure is one of the possible alternatives for PL, and it seems to be an appropriate approach for this task.


Hmm, why is that?
It would just as well require you to extract the necessary parts from your xml and build the procedure-call.
Looks to me like an unnecessary overhead to do that in java.
Re: Call a function with parameters passed as a XML [message #191418 is a reply to message #191392] Wed, 06 September 2006 05:09 Go to previous messageGo to next message
orafaqer
Messages: 48
Registered: July 2006
Member
Frank wrote on Wed, 06 September 2006 11:02

orafaqer wrote on Wed, 06 September 2006 08:58

Java Stored Procedure is one of the possible alternatives for PL, and it seems to be an appropriate approach for this task.


Hmm, why is that?
It would just as well require you to extract the necessary parts from your xml and build the procedure-call.
Looks to me like an unnecessary overhead to do that in java.

Only the one (and maybe important) reason: SAX parser, which is unavailable in pure PL/SQL due to absence of callback functions Smile
For information: DOM parser may consume up to 30 (or even more, depends on implementation) times more memory than input XML.
And of course instruments strongly depends on requirements (and performance testing)
Re: Call a function with parameters passed as a XML [message #191432 is a reply to message #191185] Wed, 06 September 2006 06:19 Go to previous messageGo to next message
hobbes
Messages: 173
Registered: January 2006
Senior Member
Given that the XML contains only the function name and its parameters, I don't see parsing as a major issue - SQLX extract functions within PL/SQL would suffice.

The concern here is building and executing the function call dynamically, which is prone to errors and security issues.

[Updated on: Wed, 06 September 2006 06:45]

Report message to a moderator

Re: Call a function with parameters passed as a XML [message #191445 is a reply to message #191418] Wed, 06 September 2006 06:57 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
orafaqer wrote on Wed, 06 September 2006 12:09

SAX parser, which is unavailable in pure PL/SQL due to absence of callback functions Smile

XDK seems to provide SAX support.

But my real point is what Hobbes mentioned.

[Edit: messed up URL]

[Updated on: Wed, 06 September 2006 07:01]

Report message to a moderator

Re: Call a function with parameters passed as a XML [message #191464 is a reply to message #191445] Wed, 06 September 2006 07:52 Go to previous message
orafaqer
Messages: 48
Registered: July 2006
Member
Frank wrote on Wed, 06 September 2006 15:57

orafaqer wrote on Wed, 06 September 2006 12:09

SAX parser, which is unavailable in pure PL/SQL due to absence of callback functions Smile

XDK seems to provide SAX support.

But my real point is what Hobbes mentioned.

[Edit: messed up URL]

Unfortunately Oracle docs sometimes are very strange... PL/SQL has no SAX Parser, indeed (it's simply impossible).
Previous Topic: Handing null nested table
Next Topic: substr and instr
Goto Forum:
  


Current Time: Tue Dec 06 02:29:22 CST 2016

Total time taken to generate the page: 0.07235 seconds