不太可能是ORA 0955错误

时间:2015-02-05 02:50:11

标签: sql database oracle batch-file sqlplus

运行运行另一个SQL文件的批处理(.BAT)文件时,我收到此错误ORA 0955。

Batch File

批次代码:

@echo off
setlocal
set "SqlUserName="
set "SqlPassword="
set "SqlDatabase="
:Credentials
set /P "SqlUserName=Enter username: "
set /P "SqlPassword=Enter password: "
set /P "SqlDatabase=Enter database: "
@(
echo whenever sqlerror exit failure
echo connect %SqlUserName%/%SqlPassword%@%SqlDatabase%
echo @C:\Users\njediaz\Desktop\sql.sql
echo exit 
) | sqlplus.exe -s /nolog
if errorlevel 1 goto Credentials
echo About to exit.
timeout /t 30
endlocal

SQL.sql代码

--conn cpi/cpi12345!@fgicrcm
--conn &&username@&&DBNAME

SET HEADING OFF;
SET ECHO OFF;
SET PAGES 999;
SET LONG 999999;
SET LONGCHUNKSIZE 999999;
SET PAGESIZE 0;
SET LINESIZE 500;

/****************/
/*BACKUP Scripts*/
/****************/

--Use SPOOL then set the filename and location of the scripts to be saved.--
--Use DBMS_METADATA.get_ddl and specifiy the OBJECT_TYPE, OBJECT_NAME and OWNER_NAME--

SPOOL C:\GeniisysUpdater\Backup\Scripts\GIAC_ORDER_OF_PAYTS_PKG.pks
SELECT DBMS_METADATA.get_ddl ('PACKAGE_SPEC', 'GIAC_ORDER_OF_PAYTS_PKG', 'CPI') FROM DUAL;
SPOOL OFF
HOST ECHO / >>  C:\GeniisysUpdater\Backup\Scripts\GIAC_ORDER_OF_PAYTS_PKG.pks

SPOOL C:\GeniisysUpdater\Backup\Scripts\GIAC_ORDER_OF_PAYTS_PKG.pkb
SELECT DBMS_METADATA.get_ddl ('PACKAGE_BODY', 'GIAC_ORDER_OF_PAYTS_PKG', 'CPI') FROM DUAL;
SPOOL OFF 
HOST ECHO / >> C:\GeniisysUpdater\Backup\Scripts\GIAC_ORDER_OF_PAYTS_PKG.pkb

/*********************/
/*INSTALL New Scripts*/
/*********************/

SPOOL C:\GeniisysUpdater\Install\Scripts\Logs\GIAC_ORDER_OF_PAYTS_PKG_pks.log
@C:\GeniisysUpdater\Install\Scripts\GIAC_ORDER_OF_PAYTS_PKG.pks
SPOOL OFF

SPOOL C:\GeniisysUpdater\Install\Scripts\Logs\GIAC_ORDER_OF_PAYTS_PKG_pkb.log
@C:\GeniisysUpdater\Install\Scripts\GIAC_ORDER_OF_PAYTS_PKG.pkb
SPOOL OFF

/***************************/
/*RECOMPILE Invalid Scripts*/
/***************************/

SPOOL C:\GeniisysUpdater\Install\Scripts\Logs\recompile_scripts.log
@C:\GeniisysUpdater\Backup\rcpl.sql
SPOOL OFF

/***************************/
/*Check if batch is done*/
/***************************/

SPOOL C:\GeniisysUpdater\Install\Files\batchDone.log
SELECT 1 FROM DUAL /
SPOOL OFF

EXIT

我尝试在TOAD中运行每个数据库文件(pks,pkb,sql),但我没有收到任何错误。

以下是我对以下脚本的代码:

GIAC_ORDER_OF_PAYTS_PKG.pks

GIAC_ORDER_OF_PAYTS_PKG.pkb

rcpl.sql

1 个答案:

答案 0 :(得分:2)

问题在于注释之前的代码是否有错误的间距。例如,将此文本复制并粘贴到SQL * Plus中:

create table only_execute_once(a number);
/***************************/
/*RECOMPILE Invalid Scripts*/
/***************************/

结果如下:

SQL>     create table only_execute_once(a number);

Table created.

SQL>     /***************************/
SQL>     /*RECOMPILE Invalid Scripts*/
    create table only_execute_once(a number)
                 *
ERROR at line 1:
ORA-00955: name is already used by an existing object


SQL>     /***************************/
SQL>

来自SQL*Plus manual

  

您必须在斜杠(/ *)开头后输入一个空格   评价。

虽然记录在案,但我仍然认为这是一个错误。大多数时候这些评论都有效。 SQL * Plus解析器有一些斜杠问题。