Home » SQL & PL/SQL » SQL & PL/SQL » ORA-04063: table has errors----
ORA-04063: table has errors---- [message #170173] Tue, 02 May 2006 07:59 Go to next message
paresql
Messages: 13
Registered: October 2005
Junior Member
Hi,
I am creating a type then a table based on it, then insert values in it, then I have to recreate the type (first I drop type force and then create or replace type ..) and then I would like to do a select * from this table but I get the ORA-04063 table mytable has errors.
I know I could drop the table and create it again, but the way I described it, its the way I need to do it.
Thanks for any help
Re: ORA-04063: table has errors---- [message #170175 is a reply to message #170173] Tue, 02 May 2006 08:00 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
And how about posting some code?

MHE
Re: ORA-04063: table has errors---- [message #170177 is a reply to message #170175] Tue, 02 May 2006 08:11 Go to previous messageGo to next message
paresql
Messages: 13
Registered: October 2005
Junior Member
well, here it is with some cuts but it contains its essence Smile

CREATE OR REPLACE TYPE bdig_type AS OBJECT (
mynumber NUMBER(1),
MEMBER FUNCTION bdig2(b IN NUMBER) RETURN NUMBER);
/

CREATE OR REPLACE TYPE BODY bdig_type AS
MEMBER FUNCTION bdig2(b IN NUMBER) RETURN NUMBER IS
BEGIN
RETURN 4;
END;
END;
/

DROP TABLE mytable;
CREATE TABLE mytable OF bdig_type ;

INSERT INTO mytable VALUES(2);

DROP TYPE bdig_type FORCE;

CREATE OR REPLACE TYPE bdig_type AS OBJECT (
mynumber NUMBER(1),
MEMBER FUNCTION bdig2(b IN NUMBER) RETURN NUMBER);
/

CREATE OR REPLACE TYPE BODY bdig_type AS
MEMBER FUNCTION bdig2(b IN NUMBER) RETURN NUMBER IS
BEGIN
RETURN 4; --this is part of the cutting Wink
END;
END;
/

SELECT * FROM mytable;
Re: ORA-04063: table has errors---- [message #170190 is a reply to message #170177] Tue, 02 May 2006 09:04 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
And why are you dropping the type? If you are just changing the type body you can do it like this:
CREATE OR REPLACE TYPE bdig_type AS OBJECT ( mynumber NUMBER(1)
                                           , MEMBER FUNCTION bdig2(b IN NUMBER) RETURN NUMBER
                                           );
/

CREATE OR REPLACE TYPE BODY bdig_type AS
  MEMBER FUNCTION bdig2(b IN NUMBER) RETURN NUMBER IS
  BEGIN
    RETURN 4;
  END;
END;
/

CREATE TABLE mytable OF bdig_type
/

DESC mytable

INSERT INTO mytable VALUES(2)
/

SELECT mynumber
FROM   mytable
/

CREATE OR REPLACE TYPE BODY bdig_type AS
  MEMBER FUNCTION bdig2(b IN NUMBER) RETURN NUMBER 
  IS
  BEGIN
    RETURN 4;
  END;
END;
/


SELECT * FROM mytable
/


DROP TABLE mytable
/

DROP TYPE bdig_type FORCE
/


MHE
Re: ORA-04063: table has errors---- [message #170197 is a reply to message #170190] Tue, 02 May 2006 09:41 Go to previous messageGo to next message
paresql
Messages: 13
Registered: October 2005
Junior Member
Well, I can not just drop the table. The reason of this weird code its that at start I create the type, the table and the inserts in SQL directly, and then, because I need to do certain and manipulations of data and functions I have a java program that connects to my DB recreate the type and need the values I just inserted on that table,
So again, the way I described it before its the way I need to do it, the ORA code table mytable has errors appears because I am deleting the type in which the existing table is created. There must be a way this table with data could be query even when I drop the type is based on
Re: ORA-04063: table has errors---- [message #170200 is a reply to message #170197] Tue, 02 May 2006 09:46 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
You didn't get it: this was the test script I used. You don't have to drop the table. You don't even have to drop the type. Just create or replace the type's body.

MHE
Re: ORA-04063: table has errors---- [message #170206 is a reply to message #170200] Tue, 02 May 2006 10:09 Go to previous messageGo to next message
paresql
Messages: 13
Registered: October 2005
Junior Member
Well, the type I create in SQL and the one I create in JAVA is the same, no matter what I have two create the type in both SQL and JAVA
Re: ORA-04063: table has errors---- [message #170250 is a reply to message #170206] Tue, 02 May 2006 19:56 Go to previous messageGo to next message
paresql
Messages: 13
Registered: October 2005
Junior Member
Isn´t anyone who could guide me on this? I´d really appreciate it and future folks..
Re: ORA-04063: table has errors---- [message #170260 is a reply to message #170250] Tue, 02 May 2006 23:54 Go to previous message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Read Maahers reply:
Do NOT drop the type; just recreate the type body!
Why would you drop it? You HAVE to create it the way it was, in order for the table to stay valid.
Previous Topic: performane problem
Next Topic: Dynamic SQL at Runtime. Oracle Version 10g
Goto Forum:
  


Current Time: Fri Apr 25 17:11:07 CDT 2025