Select to view content in your preferred language

Run PL/SQL stored procedure (in Oracle) using arcpy

5268
3
Jump to solution
03-04-2014 01:25 AM
LinaAl-Jadir
Deactivated User
Using arcpy in a Python script, I can connect to an Oracle database (I use ArcSDESQLExecute) and then run an SQL statement (I use execute).
My question is: is there a way to run a PL/SQL stored procedure using arcpy ?
Thank you.
Tags (2)
1 Solution

Accepted Solutions
CarrieButler
New Contributor

I was able to do this with an existing SDE connection and arcpy.

import arcpy

myConn = arcpy.ArcSDESQLExecute('Database Connections/myConnectionName.sde')

mySQL = 'Call myOraPackageName.myOraProcedure()'

myReturn = myConn.execute(mySQL)

print myReturn

View solution in original post

3 Replies
JamesCrandall
MVP Frequent Contributor
I don't think this is possible with arcpy.  You would have to implement a 3rd party library like cx_Oracle to do this.  We use this library but are simply building the SQL and invoking it runtime, so I don't have specific examples for PL/SQL packages or procedures.  But there is plenty of info and examples out there: http://stackoverflow.com/questions/18267935/return-variable-from-cx-oracle-pl-sql-call-in-python
0 Kudos
CarrieButler
New Contributor

I was able to do this with an existing SDE connection and arcpy.

import arcpy

myConn = arcpy.ArcSDESQLExecute('Database Connections/myConnectionName.sde')

mySQL = 'Call myOraPackageName.myOraProcedure()'

myReturn = myConn.execute(mySQL)

print myReturn