zendtech / IbmiToolkit

PHP frontend to XMLSERVICE for IBM i development.
BSD 3-Clause "New" or "Revised" License
46 stars 34 forks source link

Consider accessing XMLSERVICE with UDFs rather than stored procedures #131

Open alanseiden opened 3 years ago

alanseiden commented 3 years ago

Stored procedures with in/out parameters have served us fairly well, with a few drawbacks:

A user-defined function (UDF) would be well-suited for XMLSERVICE's parameters: multiple in, a single value out. Other advantages:

kadler commented 3 years ago

You may still want multiple "plug" sizes, since that constrains the size of the buffer allocated when binding the parameter from the result set. eg. if you have just one procedure that returns a 2GiB LOB, ibm_db2 will try to allocate 2GiB of data for it since that's the max size.

I believe the current code is constrained by the max size of a space pointer (16MiB - 1024) so we could probably just set it to that. You could still end up allocating a much larger buffer than you need, but in a 64-bit process, it shouldn't affect things that much.

alanseiden commented 3 years ago

Thanks, @kadler. My suggestion/request would be to start with a single-plug-size-UDF as you described above and see if it's "efficient enough." Doing it this way would reduce the learning curve for users and virtually eliminate the user error of selecting a too-small plug size and receiving accidentally truncated output XML. If peformance is acceptable then this technique would simplify calling XMLSERVICE, even to test program calls via straight SQL without a toolkit.

kadler commented 3 years ago

Agreed. Start with the common case and specialize as-needed.

alanseiden commented 3 years ago

A review of this issue still finds it a worthy endeavor, both to eliminate the impact of driver differences and to make XMLSERVICE easier to call from within SQL queries.