Uni Me
Uni Me

Reputation: 1

Oracle missing comma error

I am trying to insert data into a subtype table here is the code:

insert into person_tab 
 values( salesman_t( 's001', 'williams', 'john', 1990-02-01 , appoint_list_t() );

I am getting an error suggesting there is a missing comma, I've no idea where else a comma would go? If you could help please.

Upvotes: 0

Views: 291

Answers (4)

Gordon Linoff
Gordon Linoff

Reputation: 1270843

Presumably, you intend for the string that looks like a date to be a date:

insert into person_tab
    values(salesman_t('s001', 'williams', 'john', '1990-02-01', appoint_list_t());
--------------------------------------------------^

If this is Oracle and you intend for this to be a date, then you should use the date keyword and put in the missing parenthesis:

insert into person_tab
    values(salesman_t('s001', 'williams', 'john', date '1990-02-01', appoint_list_t()) );

Also, when you are inserting into a table, you should (almost) always use explicit columns. This structure assumes that hte table has only one column, which seems unlikely.

Upvotes: 0

mmmmmpie
mmmmmpie

Reputation: 3039

Lets clean your code up a bit and we'll see where the problem is:

INSERT
INTO person_tab 
VALUES (
    salesman_t( 's001', 
                 'williams', 
                 'john', 
                 1990-02-01 , 
                 appoint_list_t()) 
  );

Now one big red-flag for me is the date in the 4th entry 1990-02-01. In oracle if you want you use a date you should really wrap it in a to_date function so you know it gets passed in properly. You can check and see if the column is of type DATE by executing desc person_tab.

...
                 TO_DATE('1990-02-01','YYYY-MM-DD') , 
                 appoint_list_t()) 
...

Now the biggest problem with the code is probably that you are not describing the columns you want to insert this date into which will provide results you really don't want. What you want to do is this:

INSERT INTO table
(column1, column2, ... )
VALUES
(expression1, expression2, ... );

Matching each column up to its respective expression.
Good luck!

Upvotes: 2

stwalkerster
stwalkerster

Reputation: 1828

There's three opening bracket (() and two closing brackets ()). I suggest that this may be your issue.

insert into person_tab 
 values( salesman_t( 's001', 'williams', 'john', 1990-02-01 , appoint_list_t() );
-------^-----------^--------------------------------------------------------^

Upvotes: 1

user2930590
user2930590

Reputation:

Put the date also in single quotes

Upvotes: 1

Related Questions