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

Home -> Community -> Usenet -> c.d.o.server -> Re: Trouble inserting record into ORACLE TABLE having column with default values

Re: Trouble inserting record into ORACLE TABLE having column with default values

From: Timo Haatainen <Timo.Haatainen_at_tietogroup.com>
Date: 1998/01/14
Message-ID: <34BC8CFF.7269@tietogroup.com>#1/1

Hi Rich,

Richard_Popovich_at_Whittman-Hart.com wrote:
>
> Trying to build an Oracle7.3.2.2 DB with tables that have table
> column's with DEFAULT VALUES.
>
> I have a table similar to the following example:
>
> CREATE TABLE foo( id NUMBER(4),
> description VARCHAR2(20) DEFAULT 'Unassigned');
>
> When I insert the following records:
>
> [1]
> INSERT INTO foo VALUES(001, NULL);
> 1 ROW CREATED.
You are setting a NULL into description column, so DEFAULT does not apply (there will be NULL).

>
> [2]
> INSERT INTO foo VALUES(002, ' ');
> 1 ROW CREATED.
Same as above but instead of NULL a blank char is inserted.

>
> [3]
> INSERT INTO foo VALUES(003, );
> ERROR at line 1:
> ORA-00936: missing expression

Syntax error as you can see.

>
> SQL> SELECT * FROM foo;
>
> ID NAME
> --------- --------------------
> 1
> 2
>
> I am not able to get the DEFAULT VALUE for FOO.NAME.

Try INSERT INTO FOO (ID) VALUES (3). In that case DEFAULT will take place.

>
> Appreciate any/all input,
>
> Rich
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet

Hope this helps.

-- 

Timo Haatainen
TT-Tieto Oy
Received on Wed Jan 14 1998 - 00:00:00 CST

Original text of this message

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