Home » SQL & PL/SQL » SQL & PL/SQL » Error inserting values in ORDBMS table
Error inserting values in ORDBMS table [message #425304] Thu, 08 October 2009 09:33 Go to next message
lazyme
Messages: 3
Registered: October 2009
Junior Member
Hi,

I am creating a table of chats. The chat can be either a private chat or a public chat and so I have created a chat_type object and created types private_chat_type and public_chat_type under chat type as below

CREATE TYPE chat_type AS OBJECT
(
chat_id VARCHAR(20), 
content VARCHAR(100), 
user_id VARCHAR(20),
ditto NUMBER, 
ditto_user_id VARCHAR(20), 
datechat DATE,  
time_zone VARCHAR(20), 
tags VARCHAR(100)
) NOT FINAL;
/

CREATE TYPE private_chat_type UNDER chat_type
(
receiver_user_id VARCHAR(20), 
parent_chat_id VARCHAR(20), 
reply_flag VARCHAR(10)
);
/

CREATE TYPE public_chat_type UNDER chat_type
(
);
/

create TABLE chat_table OF chat_type
(
PRIMARY KEY(chat_id)
);

Now, when I insert values in the chat_table I get an error saying
ERROR at line 1:
ORA-02315: incorrect number of arguments for default constructor

The syntax I have used to insert values are as below.

INSERT INTO chat_table VALUES(
 public_chat_type( NULL, NULL, NULL), 
chat_type( 'p1', 'I lost', 'u26', 1, 'u26', to_date('9/30/2009 5:00','MM/DD/YYYY mi:ss'), -5, 'hello' ) 
);

INSERT INTO chat_table VALUES( 
private_chat_type( u2, NULL, F), 
chat_type( 'p1', 'Hi there', 'u21', 1, 'u36', to_date('9/30/2009 5:00','MM/DD/YYYY mi:ss'), -5, 'welcome' ) 
);

Could you please help me figure out the problem in my statements.

Thanks.

[Updated on: Thu, 08 October 2009 10:01] by Moderator

Report message to a moderator

Re: Error inserting values in ORDBMS table [message #425307 is a reply to message #425304] Thu, 08 October 2009 09:57 Go to previous messageGo to next message
BlackSwan
Messages: 25041
Registered: January 2009
Location: SoCal
Senior Member
Oracle RDBMS is NOT an Object Oriented Programming (OOP) platform.
What you are attempting is like trying to use a hammer to make 2 pieces of lumber out of 1 board.
Your life will be easier of you used an OOP DB or avoided doing OOP inside Oracle.
Re: Error inserting values in ORDBMS table [message #425309 is a reply to message #425304] Thu, 08 October 2009 10:20 Go to previous messageGo to next message
_jum
Messages: 508
Registered: February 2008
Senior Member
You can INSERT INTO chat_table with:
INSERT INTO chat_table VALUES(
chat_type( 'p1', 'I lost', 'u26', 1, 'u26', to_date('9/30/2009 5:00','MM/DD/YYYY mi:ss'), -5, 'hello' ) 
);
Re: Error inserting values in ORDBMS table [message #425318 is a reply to message #425304] Thu, 08 October 2009 10:46 Go to previous messageGo to next message
lazyme
Messages: 3
Registered: October 2009
Junior Member
Hi Jum,

Yes this works but this wont insert the private_chat_type and public_chat_type TYPES in the table.

Is there any workaround for this using oracle ORDBMS?
Re: Error inserting values in ORDBMS table [message #425326 is a reply to message #425304] Thu, 08 October 2009 11:13 Go to previous messageGo to next message
Kevin Meade
Messages: 2101
Registered: December 1999
Location: Connecticut USA
Senior Member
I am no fan of object tables, but seems to me the error is pretty straight forward.

What you are inserting does not match the type layout of the table you are inserting into.

Good luck, Kevin
Re: Error inserting values in ORDBMS table [message #425337 is a reply to message #425304] Thu, 08 October 2009 11:52 Go to previous messageGo to next message
lazyme
Messages: 3
Registered: October 2009
Junior Member
Yes I figured out the syntax issue.

Thanks Kevin.
Re: Error inserting values in ORDBMS table [message #425343 is a reply to message #425304] Thu, 08 October 2009 12:31 Go to previous message
Kevin Meade
Messages: 2101
Registered: December 1999
Location: Connecticut USA
Senior Member
good job.
Previous Topic: ORDER BY & GROUP BY Clauses
Next Topic: PL/SQL runtime issue
Goto Forum:
  


Current Time: Tue Dec 06 14:35:17 CST 2016

Total time taken to generate the page: 0.11570 seconds