Oracle's New INSERT Syntax
Not really Oracle's...just mine.
I'm busy debugging
VALUES
*
ERROR at line 19:
ORA-00947: not enough values
I manually count the columns and they're the same. Run it again.
VALUES
*
ERROR at line 19:
ORA-00947: not enough values
I then cut and paste both "halves" of the INSERT statement into excel so I can get a row-by-row compare.
Everything looks good, go!
VALUES
*
ERROR at line 19:
ORA-00947: not enough values
WTF?
I still haven't figured it out, but that excel picture gave me an idea...
I tend to put one column on each line, for large tables, this takes up quite a bit of vertical space. I've seen others put columns (and values) on the same line. Just looks ugly to me. Here's what this table looks like:
INSERT INTO my_table
( id,
create_date,
update_date,
col1,
col2,
col3,
col4,
col5,
col6,
col7,
col8,
col9,
col10,
col11,
col12,
col13,
col14 )
VALUES
seq.nextval,
SYSDATE,
SYSDATE,
'A',
'SOMETHING',
'SOMETHING',
'SOMETHING',
'SOMETHING',
'SOMETHING',
'SOMETHING',
'SOMETHING',
'SOMETHING',
'SOMETHING',
'SOMETHING',
'SOMETHING',
'SOMETHING',
'SOMETHING' );
Wouldn't it be cool if you could do something like this though?
INSERT INTO my_table
( id => seq.nexval,
create_date => SYSDATE,
update_date => SYSDATE,
col1 => 'A',
col2 => 'SOMETHING',
col3 => 'SOMETHING',
col4 => 'SOMETHING',
col5 => 'SOMETHING',
col6 => 'SOMETHING',
col7 => 'SOMETHING',
col8 => 'SOMETHING',
col9 => 'SOMETHING',
col10 => 'SOMETHING',
col11 => 'SOMETHING',
col12 => 'SOMETHING',
col13 => 'SOMETHING',
col14 => 'SOMETHING' );
1. You'd save space.
2. It would be easier to read and
3. It would be easier to debug
Thoughts?
update:I did solve my problem, I was missing the opening parenthesis in the VALUES clause.
update 2:I created an "Idea" over at Oracle Mix, check it out and vote for it
here.
Labels: oracle, sql