Help with Oracle DEFAULT with strange error, it makes no sense

Hi, i’m working on a lil project and basically, i’m trying to add a DEFAULT value for when the insert is empty but am getting an error and literally have no reason why.

What i want to happen is if you don’t fill out the description column, i want the default value to be inserted otherwise insert the custom value but an error is produced. All help much appreciated!

My create table code:

CREATE TABLE project_details (
    pid NUMBER(11),
    pname VARCHAR(50) NOT NULL,
    pdesc VARCHAR(500) DEFAULT 'N/A',
    
    CONSTRAINT pid_pk PRIMARY KEY (pid),
    CONSTRAINT pname_check CHECK(pname != ''),
    CONSTRAINT pdesc_check CHECK(pdesc != '')
);
Error starting at line : 107 in command -
INSERT INTO project_details (pid, pname) VALUES (4, 'Baker Dozen Website', '')
Error at Command Line : 107 Column : 13
Error report -
SQL Error: ORA-00913: too many values
00913. 00000 -  "too many values"
*Cause:    
*Action:

What i am trying to insert:

INSERT INTO project_details (pid, pname) VALUES (3, 'Local Shop POS', 'A Pos');
INSERT INTO project_details (pid, pname) VALUES (4, 'Baker Dozen Website');

Did you realise you have an extra value? in:

INSERT INTO project_details (pid, pname) VALUES (3, 'Local Shop POS', 'A Pos');

try:

INSERT INTO project_details (pid, pname) VALUES (3, 'Local Shop POS');

omg, i am a thicko. apologies!!!

Nah, a pair of fresh eyes is what you needed, as it often happens in this profession :wink:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.