Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

varargs in PL/SQL

jnicholas330Jul 5 2016 — edited Jul 5 2016

It's already there, just make it available for user defined units. Look at the definition of this package, and take note of the ellipsis:

CREATE OR REPLACE PACKAGE SYS.utl_lms AS

   /*

    *  FUNCTION:

    *  Format the retrieved LMS message.

    *

    *  Format string special characters

    *    '%s'   - substitute next string argument

    *    '%d'   - substitute next integer argument

    *    '%%'   - special character '%'

    *

    *  PARAMETERS

    *    format - Formatting string.

    *    args   - Subtitution arguments list.

    *  RETURN

    *    Fomatted result    on success.

    *    NULL               on failure.

    * EXCEPTIONS

    *   miscellaneous runtime exceptions.

    */

    FUNCTION format_message(format IN VARCHAR2 CHARACTER SET ANY_CS,

                           args ...)

      RETURN VARCHAR2 CHARACTER SET format%CHARSET;

END utl_lms;

/

This allows code in the form of format_message('%s %s','first string','second string'). This can be useful in many other contexts. Unfortunately, if you try to use the ellipsis in your own code, you will get the following error:

SQL> CREATE OR REPLACE FUNCTION my_parameter_array_func (FORMAT IN VARCHAR2, arg

s ...) RETURN VARCHAR2 AS

  2                             BEGIN

  3                             RETURN '';

  4                             END;

  5  /

Warning: Function created with compilation errors.

SQL> show err

Errors for FUNCTION MY_PARAMETER_ARRAY_FUNC:

LINE/COL   ERROR

---------- ---------------------------------------------------------------------

------------------------------

1/55       PLS-00999: implementation restriction (may be temporary) ellipsis not

allowed in this context

SQL>

Comments
Post Details
Added on Jul 5 2016
7 comments
3,023 views