# Running a select statement as script using oracle\_sql module

**URL:** <https://forum.ansible.com/t/running-a-select-statement-as-script-using-oracle-sql-module/32058>\
**Category:** Ansible Developer\
**Tags:** aws\
**Created:** [January 25, 2020, 3:04pm UTC](https://forum.ansible.com/t/running-a-select-statement-as-script-using-oracle-sql-module/32058 "2020-01-25T15:04:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anand\_Solomon](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@Anand\_Solomon](https://forum.ansible.com/u/Anand_Solomon)\
**Post date:** [January 25, 2020, 3:04pm UTC](https://forum.ansible.com/t/running-a-select-statement-as-script-using-oracle-sql-module/32058/1 "2020-01-25T15:04:56Z")

</div>

Hi,  
I am trying to run a sql script which has simple select statement. (select username from dba\_users). Will oracle\_sql module run a “Select” statement and returns the results ?

My playbook is

- name: Script will creates Oracle DBA IDs and Profiles on AWS RDS.  
oracle\_sql:  
username: “{{user}}”  
password: “{{password}}”  
service\_name: “{{sname}}”  
port: “{{prt}}”  
host: “{{host}}”  
script: “/home/ansible/Compliance.sql”  
environment: “{{oracle\_env}}”  
register: query\_result  
connection: local

If I run the sql statement as sql: “select username from dba\_users”, it works. The same sql statement if I run script: /home/ansible/Compliance.sql. It is not working.

I am getting "{“changed”: false, “msg”: “Something went wrong while executing sql - ORA-00972: identifier is too long sql: "Finished running script /home/ansible/Compliance.sql \nContents: \nselect username\\n \ from dba\_users"”}

The debug output is as below:

TASK [Display the query results] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [22.174.101.30] =\> (item=msg.stdout) =\> {  
“msg”: {  
“changed”: true,  
“failed”: false,  
“msg”: “Finished running script /home/ansible/Compliance.sql \nContents: \nselect username from dba\_users”  
}  
}

---

<div class="post-metadata">

**Author:** ![td784](https://avatars.discourse-cdn.com/v4/letter/t/aeb1de/32.png) [@td784](https://forum.ansible.com/u/td784)\
**Post date:** [January 25, 2020, 3:08pm UTC](https://forum.ansible.com/t/running-a-select-statement-as-script-using-oracle-sql-module/32058/2 "2020-01-25T15:08:26Z")

</div>

Hi Anand,

I just answered the issue on the ansible oracle module github repo. Please see that answer.

---

<div class="post-metadata">

**Author:** ![Anand\_Solomon](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@Anand\_Solomon](https://forum.ansible.com/u/Anand_Solomon)\
**Post date:** [January 26, 2020, 2:37am UTC](https://forum.ansible.com/t/running-a-select-statement-as-script-using-oracle-sql-module/32058/3 "2020-01-26T02:37:05Z")

</div>

Thank you so much.
