Again? ORA-00911: invalid character Error [message #344924] |
Mon, 01 September 2008 21:39 |
xeophillus
Messages: 6 Registered: September 2008
|
Junior Member |
|
|
I know this is a common error in oracle and many people has asked this before, but this one is quite annoying.
Background: I have to import data from another Oracle database which has multiple schemas in it, and the tables in each schema is identical each other.
I want to make an Procedure that can automatically import all data from specific table from all schemas with dynamic SQL(so I don't have to hard code the schema name).
REFCURSOR is used but there is an error in SQL Statement
DECLARE
-- Local variables here
CURSOR C_SCHEMA IS
SELECT SCHEMA
FROM IFSAPP.M_ENTITY_TAB;
TYPE C_REF IS REF CURSOR;
DATA C_REF;
TOTAL_HECTARAGE NUMBER;
SCHEMA_CODE VARCHAR2(30 CHAR);
FIELD_CODE VARCHAR2(30 CHAR);
BEGIN
-- Test statements here
FOR REC_ IN C_SCHEMA LOOP
BEGIN
OPEN DATA FOR 'SELECT FIELDCODE,TOTALHECTARAGE FROM '||REC_.SCHEMA'||'.IBU_FIELDHISTORY@TDCONSOL;';
FETCH DATA INTO FIELD_CODE, TOTAL_HECTARAGE;
INSERT INTO IFSAPP.PARAMETER_TABLE(CODE, HECTARAGE)
VALUES (FIELD_CODE, TOTAL_HECTARAGE);
COMMIT;
CLOSE DATA;
END;
END LOOP;
END;
When I compile it, there is an error message, ORA-00911: invalid character right on the OPEN DATA FOR etc..
Can anyone help me? thanks before for any answer
[Updated on: Mon, 01 September 2008 22:06] by Moderator Report message to a moderator
|
|
|
Re: Again? ORA-00911: invalid character Error [message #344927 is a reply to message #344924] |
Mon, 01 September 2008 22:12 |
|
BlackSwan
Messages: 26766 Registered: January 2009 Location: SoCal
|
Senior Member |
|
|
http://www.orafaq.com/forum/t/88153/0/
Please read & FOLLOW the Posting Guidelines as stated in URL above
>OPEN DATA FOR 'SELECT FIELDCODE,TOTALHECTARAGE FROM '||REC_.SCHEMA'||'.IBU_FIELDHISTORY@TDCONSOL;';
Single quote marks are supposed to happen in pairs. Right?
In other words SQL statement should not have an odd number of single quote marks.
What about (ab)using:
ALTER SESSION SET CURRENT_SCHEMA=NEW_SCHEMA;
PL/SQL is NOT required.
You can write SQL to write SQL.
[Updated on: Mon, 01 September 2008 22:15] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|