| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Designing Default Value
>> I do NOT want to know about setting default values for CREATE TABLE
statements when adding data, the question is how to design this
information so that it can be read into my application. <<
I'll take a guess at this:
CREATE TABLE Foobar
(...
currency_code CHAR(3) NOT NULL
REFERENCES Currencies(currency_code), ...);
CREATE TABLE Currencies
(currency_code CHAR(3) NOT NULL PRIMARY KEY,
priority_nbr INTEGER NOT CHECK (priority_nbr IN (1,0),
Then use a scalar subquery to find the #1 code when a NULL is given instead of an explicit currency code to the input procedure:
INSERT INTO Foobar
VALUES (..., COALESCE (:explicit_curency_code,
(SELECT curency_code FROM Currencies WHERE
priority_nbr = 1)), ...);
Received on Mon Oct 20 2003 - 18:16:39 CDT
![]() |
![]() |