Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> PL/SQL: Constants in TYPE declarations?

PL/SQL: Constants in TYPE declarations?

From: FlameDance <flamedance_at_gmx.de>
Date: Sun, 09 Nov 2003 00:16:49 +0100
Message-ID: <bojtjf$99d$05$1@news.t-online.com>


Hello everyone,

as I am used to from other ada-like languages I want to declare my global constants in one file/package and use them in other packages, among other purposes to tailor my declarations. So I tried this code:

CREATE OR REPLACE PACKAGE basicConstants IS

    maxLineLength     constant int          := 32767;
    maxFieldLength    constant int          := 255;
END basicConstants;
/

show errors

CREATE OR REPLACE PACKAGE dosomethingelse IS

    SUBTYPE t_aLine is VARCHAR2(basicConstants.maxLineLength);

...

END dosomethingelse;
/

show errors

On compiling the second package I got error messages: 3/51 PLS-00491: Numerisches Literal erforderlich 8/60 PLS-00491: Numerisches Literal erforderlich

This german message translates to (numeric literal necessary).

Inserting the numbers directly worked:

    SUBTYPE t_aLine is VARCHAR2(32767);

But I don't want to have to change the dimension of this and other types every time I change the global settings. I could declare the subtypes and types in the basicConstants package - but I don't want that either, it doesn't conform with my design.

How can I do what I want? Am I missing something? Any workarounds? Or is it simply not supported by PL/SQL?

Thanks for any insights,
Stephan Received on Sat Nov 08 2003 - 17:16:49 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US