1

I'm writting a script (000-Install.sql) to execute several sql scripts (001-sys.tab, 002-enca.tab and others), in a console.

So to start, I add just two script:

-- 000-Install.sql
spool upgradeSP1Ora.log

start 001-sys.tab;
start 002-enca.tab;

commit;

Here the content of the included scripts:

-- 001-sys.tab
select * from empr;
/


-- start 002-enca.tab
select * from dte_enca_docu;
/

But for some reason, the execution prompt something like:

CODI_EMPR NOMB_EMPR                                GIR
---------- ---------------------------------------- ---
DIRE_EMPR                                      CODI_COM CODI_CIU  RUTT_EMPR
-------------------------------------------------- -------- -------- -------
D CODI_RAMO    NFAN_EMPR                                CODI_PERS
- ------------ ---------------------------------------- ----------------
 EMPR_CODG EMPR_NOMB                                FONO_EMPR
---------- ---------------------------------------- --------------------
 RUTT_REPL D NOMB_REPL                       CAC MUT  POMU_EMPR  POCA_EMPR
---------- - ----------------------------------- --- --- ---------- -------
FECA_EMP FEMU_EMP CIN CUEN_EMPR    CAJ COLOR_EMPR      LOGO_EMPR
-------- -------- --- ------------ --- --------------- ---------------
CODI_EMEX                      CLAV_ENCR
------------------------------ ------------------------------
ASUN_FACT_EMPR
---------------------------------------------------------------------------
TEXT_FACT_EMPR
----------------------------------------------------------------------------
385

And the second script (start 002-enca.tab) is never executed.

The problem is that the execution of the my script file is not finishing properly (at least that is what it looks like), and that prevents that my second script is running.

NOTE: If I press enter the number 385 is incremented by one, and if I hit CTRL + c the execution is cancelled.

Alejandro Montilla
  • 2,626
  • 3
  • 31
  • 35

1 Answers1

2

Try following contents of the scripts:

  • 000-Install.sql

    set termout off
    spool upgradeSP1Ora.log
    
    @ 001-sys.tab;
    @ 002-enca.tab;
    
    spool off
    commit;
    exit;
    
  • 001-sys.tab

    select * from empr;
    
  • 002-enca.tab

    select * from dte_enca_docu;
    

Execute SQL*Plus as:

sqlplus -l -s user/pass@tnsname @ 000-Install
0xdb
  • 3,539
  • 1
  • 21
  • 37
  • Thank you @0xdb, your answer put me in the right track, but the actual solution was adding `/` after some scripts (not every script needed one). Here is the solution that helped me to understand the need of `/`: https://stackoverflow.com/a/10207695/6780663. – Alejandro Montilla Aug 29 '17 at 14:20
  • @AlejandroMontilla you're welcome. Only a statement with embeded block needs slash because semicolon ends a block not a complete statement. The select needs it never because semicolon ends and executes underlined statement. Therefore i have removed the slashes. – 0xdb Aug 29 '17 at 14:56
  • I see, thank you for the clarification, you are right the `select`s do not need `/`, in my case only the scripts with `CREATE PROCEDURE` requiere it. – Alejandro Montilla Aug 29 '17 at 15:03