ansible-oracle-modules icon indicating copy to clipboard operation
ansible-oracle-modules copied to clipboard

oracle_sql run pl/sql package issue

Open matthiaslink77 opened this issue 6 years ago • 6 comments

Hi,

I am trying to run a basic sql package, but to me it seems, the parser is cutting off the line after the first semicolon. Did I miss something here again?

 - name: apply application fixes by SQL
   oracle_sql:
     username: "{{ user_name }}"
     mode: "{{ user_mode }}"
     password: "{{ user_password }}"
     service_name: "{{ service_name }}"
     script: "{{ script_name }}"
   environment: "{{oracle_env}}"

The script currently only consists of this one command:

BEGIN DBMS_STATS.set_global_prefs ( pname => 'CONCURRENT', pvalue => 'ALL'); END; /

The output is as follows:

TASK [apply application fixes by SQL] ************************************************************************************************************************************ fatal: []: FAILED! => {"changed": false, "msg": "Something went wrong while executing sql - ORA-06550: line 3, column 71:\nPLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:\n\n := . ( % ; sql: \nBEGIN\n DBMS_STATS.set_global_prefs ( pname => 'CONCURRENT', pvalue => 'ALL')"}

I already tried several syntax variations, but none made it work for me. What am I missing?

Best regards, Matthias.

matthiaslink77 avatar Jan 15 '19 21:01 matthiaslink77

Hi,

The oracle_sql module is pretty much in a perpetual alpha state as I haven't really done anything with it for about 2 years. I will look into this, but it's unfortunately not a priority at the moment.

There is a oracle_stat_prefs module that should be able to help with at least the stats prefs issue.

oravirt avatar Jan 15 '19 22:01 oravirt

Thanks - I will take a look at it!

I assume the part to check would be here:

... else: sqlfile = read_file(module, script) sqlfile = clean_sqlfile(sqlfile) sqldelim = ';' if 'create or replace' in sqlfile.lower(): sqldelim = '/'

So this might need a modification?

Best regards, Matthias.

matthiaslink77 avatar Jan 16 '19 13:01 matthiaslink77

Hi Mikael, did you have a chance to look at this? Would be highly appreciated? Best regards, Matthias.

matthiaslink77 avatar Jan 24 '19 17:01 matthiaslink77

Hi, I (hopefully) did a quick fix for this. Try it and let me know if it works out.

And just a note: If you want to manage database objects, you definitely should look into something like liquibase or flyway instead of using this module.

oravirt avatar Jan 25 '19 12:01 oravirt

Also getting the same error. Any chances on this being fixed?

serpro69 avatar Mar 09 '20 08:03 serpro69

Hi,

I refactored oracle_sql module. You can find it here : https://github.com/ari-stark/ansible-oracle-modules/blob/devel/plugins/modules/oracle_sql.py.

It works for me, from simple request to several procedures. Tell me if it helps.

ari-stark avatar Feb 15 '21 21:02 ari-stark