简体   繁体   English

SQL * Plus和SQL Developer

[英]SQL*Plus and SQL Developer

I have just a simple question regarding executing a pl/sql script inside SQL*PLUS: 关于在SQL * PLUS中执行pl / sql脚本,我只有一个简单的问题:

create or replace trigger CICD.S_ACCNT_POSTN_DELETE
   after delete on CICD.S_ACCNT_POSTN    
   FOR EACH ROW 
BEGIN
    INSERT INTO CICD.CX_PROCCHLDDEL (ROW_ID, OBJECT_TYPE, PARENT_ID,
          CHILD_ID,STATUS,CREATED,CREATED_BY,LAST_UPD,LAST_UPD_BY)
    VALUES (:old.ROW_ID,'AccountTeam', :old.OU_EXT_ID, :old.POSITION_ID
          ,'Not Synchronized', SYSDATE,:old.CREATED_BY
          ,SYSDATE,:old.LAST_UPD_BY);
END;

This script generates me the following error: 该脚本向我生成以下错误:

E- ORA-00900: invalid SQL statement

E- oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
E- oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
E- oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
E- oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
E- oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
E- oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
E- oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
E- oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:999)
E- oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
E- oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1890)
E- oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1855)
E- oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:304)
E- com.uc4.ara.feature.database.SQLFeature.executeSQLScript(SQLFeature.java:164)
E- com.uc4.ara.feature.database.SQLFeature.run(SQLFeature.java:53)
E- com.uc4.ara.feature.AraFileCmd.main(AraFileCmd.java:120)

I have also tried executing the script with DECLARE in the top. 我也尝试过在顶部使用DECLARE执行脚本。 When doing this i get the following error: 这样做时,出现以下错误:

 E- ORA-06550: line 2, column 1:
PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:

   ( begin case declare exit for goto if loop mod null pragma
   raise return select update while with <an identifier>
   <a double-quoted delimited-identifier> <a bind variable> <<
   continue close current delete fetch lock insert open rollback
   savepoint set sql execute commit forall merge pipe purge

E- oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
E- oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
E- oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
E- oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
E- oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
E- oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
E- oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
E- oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:999)
E- oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
E- oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1890)
E- oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1855)
E- oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:304)
E- com.uc4.ara.feature.database.SQLFeature.executeSQLScript(SQLFeature.java:164)
E- com.uc4.ara.feature.database.SQLFeature.run(SQLFeature.java:53)
E- com.uc4.ara.feature.AraFileCmd.main(AraFileCmd.java:120)

The funny thing is when I paste either one of the two scripts in SQL Developer it executes the script perfectly fine. 有趣的是,当我将两个脚本之一粘贴到SQL Developer中时,它可以很好地执行脚本。 This is what confuses me. 这就是令我困惑的地方。

Now I want to know if I somehow can transform these scripts into a valid PL/SQL script which can be executed in SQL*PLUS or is there another way ? 现在,我想知道是否可以将这些脚本转换为可以在SQL * PLUS中执行的有效PL / SQL脚本,或者还有其他方法吗?

ps running Sun Solaris. ps运行Sun Solaris。

SQL PLUS: SQL Plus: Release 11.2.0.2.0 SQL PLUS:SQL Plus:11.2.0.2.0版

Thanks a lot. 非常感谢。

"The funny thing is when I paste either one of the two scripts in SQL Developer it executes the script perfectly fine." “有趣的是,当我将两个脚本之一粘贴到SQL Developer中时,它可以很好地执行脚本。”

You have shown only one script. 您只显示了一个脚本。 However the one you have posted lacks a trailing / . 但是,您发布的那个缺少尾随/ SQL Plus uses a slash to indicate the end of an PL/SQL executable statement. SQL Plus使用斜杠表示PL / SQL可执行语句的结尾。 So, assuming this is not just a posting error, you have two scripts without slashes at the end of the PL/SQL statement. 因此,假设这不仅是一个发布错误,您在PL / SQL语句的末尾有两个没有斜杠的脚本。 This means the SQL Plus engine can't separate them, and that could cause SQL Plus to hurl an ora-00900 exception. 这意味着SQL Plus引擎无法将它们分开,这可能导致SQL Plus抛出ora-00900异常。

Of course if you were running these scripts manually you would see SQL Plus hang, waiting for you to type in the terminating slash. 当然,如果您手动运行这些脚本,则会看到SQL Plus挂起,等待您键入终止斜杠。 I presume the Java error stack means you're running the scripts through some form of build runner. 我认为Java错误堆栈意味着您正在通过某种形式的构建运行器运行脚本。

IDEs such as SQL Developer will run an individual script without a trailing slash because they handle it; 诸如SQL Developer之类的IDE将运行单个脚本而不会在其后加上斜杠,因为它们可以处理它们。 by highlighting some code and pressing [F8] they can figure out the statement and simulate the trailing slash. 通过突出显示一些代码并按[F8],他们可以找出该语句并模拟结尾的斜杠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM