Array or collection as input parameter to function/procedure
474241Jun 8 2007 — edited Jun 9 2007I am a newbe to PL/SQL, but need to solve the following issue:
In my Java class I have a potentially very large List/array of user id's. For every user, I have to do a check if the user exist, and depending on the result, the logic will perform two alternative actions. Since my experience tells me network traffic is usually the most expensive operation you can perform in a system with many users, I want to keep this at a minimum. Therefore I want to move this check-and-act logic to the database, preferably in a function as I want returned the number of users that did not exist. By implementing it this way I am down to two network calls instead of 14-30 thousand..
My problem is that I have no experience using Pl/sql other than creating simple procedures functions that insert some data here and selects some data there.. Being such a newbie, I do not even know the domain terminology well enough to get relevant/ understandable hits when using google..
So how do I declare an array as an input parameter for a pl/sql function, when I do not yet know the size of that array? Do I need to use a cursor as input parameter instead of array? In that case, how to I set a cursor as input parameter in JDBC, and how do you iterate a cursor in a loop?
My mind have come across some rather fussy hacks, like sending in a delimeter separated String and use that as the array.. But that will force the procedure to take a heck of a large varchar in, and that would probably give poor performance and the lack of robustness as the list can grow very long with time - potentially outgrowing the max size of the varchar input parameter.
Any input on this would be greatly appreciated!!
K