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

Home -> Community -> Usenet -> c.d.o.tools -> Re: PL/SQL constants

Re: PL/SQL constants

From: Dmlvol <dmlvol_at_aol.comadsfadsf>
Date: 05 Nov 2000 16:43:12 GMT
Message-ID: <20001105114312.01148.00000777@ng-cc1.aol.com>

Leo,

First, let me state I am no PL/SQL expert, but here is my two cents.

A word about constants...they are always constant which means they never change. They are typically used to create mnemonics for hard to remember stuff in order to make it easier to remember.

 Simple example: con_FreezingPoint CONSTANT NUMBER(2) := 32 (Uhh, guess that would be 0 for non Fahrenheit countries)

The point is, like the freezing point for water, constants NEVER change.

I use constants to make mnenonics for long strings of numbers which represent background colors. If the color number is 123533432354...and they are often long numbers, you can assign it to a constant such as conBlue. So instead of typing the long string of numbers, you just type conBlue. The number representing blue NEVER changes.

I think what you are refering to is what I call semi-static values. These are values that can change, but do not change very frequently. I always put these values in a table (you can call it setup data, variable data, or whatever), and look them up at runtime. I NEVER hardcode such data because the obvious result is you have to change your code when one of these values change.

As a suggestion,store your semi-static data in a table and use SELECT INTO to retrieve into a variable at runtime.

Hope this helps.

David

>Subject: PL/SQL constants
>From: "Leo Plugge" plugge_at_cs.unimaas.nl
>Date: 11/5/00 4:15 AM Pacific Standard Time
>Message-id: <8u3j04$br$1_at_rl0001.unimaas.nl>
>
>Our programmers have been writing stuff in PL/SQL with a lot of hardcoded
>constant, such as IP numbers, gif pictures, even e-mail addresses.
>I asked why they didn't put this kind of information in a database or config
>file.
>They said that PL/SQL doesn't offer this option.
>
>I don't believe them. For one: PL/SQL at least offers the option of
>decalring constants.
>I know (found it in this newsgroup) that you can use functions in
>SQL-statements to insert constants. So, why wouldn't it be possible in
>PL/SQL?
>
>Can anyone back me up on this?
>
>TIA
>-Leo-
>BTW: I would appreciate it if you could reply directly to my email address,
>since I don't frequent this group.
Received on Sun Nov 05 2000 - 10:43:12 CST

Original text of this message

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