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 -> Re: PL/SQL: Constants in TYPE declarations?

Re: PL/SQL: Constants in TYPE declarations?

From: Daniel Morgan <damorgan_at_x.washington.edu>
Date: Sun, 09 Nov 2003 10:18:04 -0800
Message-ID: <1068401904.950300@yasure>


FlameDance wrote:

> 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);
> -- Table of Varchars, z.B. Lines:
> TYPE t_VarcharTable IS TABLE OF t_aLine;
> -- Table of Field:
> TYPE t_FieldTable IS TABLE OF
> VARCHAR2(basicConstants.maxFieldLength);
>
> ...
>
> 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
>

To the best of my knowledge ... not supported. Consider the problem if you changed the definition in the package. Type headers can not be altered dynamically.
Type bodies can be altered but not column definitions.

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Sun Nov 09 2003 - 12:18:04 CST

Original text of this message

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