开发者

Oracle 10g - invalid character on DB importing

I have several SQL files that I want to import.

An example:

CREATE TABLE BB_Department (
    idDepartment number(2)  ,
    DeptName varchar2(25) ,
    DeptDesc varchar2(100) ,
    DeptImage varchar2(25) ,
    CONSTRAINT dept_id_pk PRIMARY KEY(idDepartment) );
insert into bb_department 
   values(1,'Coffee','Many types of coffee beans','coffee.gif');

When importing this with http://localhost:8080/apex I continually receive the 'invalid character' error.

It seems that one can only run ONE SQL statement at a time. The error is triggered by any semi-colons.

Some online references state that it might be char conversion - but this does not seem to be the case.

How can I go about importing d开发者_运维百科ump files, in the web interface, without triggering this?


I'm still not quite sure which "Apex web tool" you're using. I'll assume it's the web interface of the Oracle 10g Express Edition (Oracle 10g XE).

If I copy your SQL statement into a text file and upload it as a SQL script, I can run it without error. It creates the table and inserts a single row. The semicolons are just fine as statement delimiters.

The same cannot be said about interactive SQL Commands page. I can successfully run a command if it's either the only command in the edit area (without a semicolon or slash) or if I first select the command (again without a semicolon or slash). However, this page seems incapable of running multiple commands (giving either ORA-00911, ORA-00910, ORA-00933 or ORA-00905).

Possibly, some of these problems are due to browser incompatibilities. With Firefox 6, I cannot run or edit SQL scripts. I can see the unformatted SQL text but it is read-only and has a red background. All buttons at the top are dead (or rather throw an exception in Firefox's Javascript error console). With IE 9, it seems to work.

In general, you can either use a semicolon or slash on a separate line to delimit commands in Oracle SQL scripts. So it's either:

insert into bb_department 
  values(1,'Coffee','Many types of coffee beans','coffee.gif');
insert into bb_department 
  values(2,'Sugar','Sweet','sugar.gif');

Or:

insert into bb_department 
  values(1,'Coffee','Many types of coffee beans','coffee.gif')
/
insert into bb_department 
  values(2,'Sugar','Sweet','sugar.gif')
/

If you have a BEGIN/END block, either for a anonymous PL/SQL block or a stored procedure / function / package, you must use the slash.

A reliable tool to run SQL scripts is the command line tool SQL*plus. It definitely supports semicolons and slashes. In addition to SQL statements and PL/SQL blocks, it also supports several additional useful commands.

A graphical, free and useful tool is SQL Developer (from Oracle). It supports SQL statements, PL/SQL blocks and most of the SQL*plus commands.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜