ANT sql task: How to run SQL and PL/SQL and notice execution failure?

前端 未结 2 622
感情败类
感情败类 2020-12-30 04:29

to execute an .sql script file from ANT it works fine using the following task:



        
2条回答
  •  臣服心动
    2020-12-30 05:09

    Pretty late, I guess - but I hope this will help someone:

    In general, I think we should perfer using sql rather than exec executable="sqlplus" for many reasons, such as: in case we change DB provider, you don't spend reaources in a new process with sql, "STOPPING" will work as opposed to sqlplus.exe etc.

    Anyway, here's a suggestion on how to let both PL/SQL & SQL in same script so that it will work:

    myScript.sql:


    
      
      
        
        
       
    
    

    then give the result to:

    explaination: If you have regular sql commands:

    drop table x;
    select blah from blue where bli=blee;
    

    They will be transformed to:

    drop table x
    /
    select blah from blue where bli=blee
    /
    

    which is equivlant - and the sql command with "/" delimeter can handle them.

    On the other hand,

    BEGIN
      blah
    END;
    /
    

    will be transformed to:

    BEGIN
      blas
    END/
    /
    

    and using the second regex - transformed back to

    BEGIN
      blas
    END;
    /
    

    So everybody wins! Hurray!

    Good luck.

提交回复
热议问题