473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Python and calling Oracle Procedures

I have a procedure (within a package) that generates a

Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PACKAGE my_pack AS
  2. TYPE my_type AS TABLE OF VARCHAR2;
  3.  
  4. PROCEDURE my_get_proc (my_records OUT my_type) AS
  5. BEGIN
  6.   SELECT NAME BULK COLLECT INTO my_records FROM my_table;
  7. END my_get_proc;
  8. END my_pack;
So my question is how do I call this from Python and get the results returned to me? Do I just need to:
Expand|Select|Wrap|Line Numbers
  1. db = DCOracle2.connect(<connect string>)
  2. c = db.cursor()
  3. my_record_list = c.prodecure.my_pack.my_get_proc ()
Do OUT params get translated into return values?
Jan 24 '08 #1
3 3918
amitpatel66
2,367 Expert 2GB
I have a procedure (within a package) that generates a

Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PACKAGE my_pack AS
  2. TYPE my_type AS TABLE OF VARCHAR2;
  3.  
  4. PROCEDURE my_get_proc (my_records OUT my_type) AS
  5. BEGIN
  6.   SELECT NAME BULK COLLECT INTO my_records FROM my_table;
  7. END my_get_proc;
  8. END my_pack;
So my question is how do I call this from Python and get the results returned to me? Do I just need to:
Expand|Select|Wrap|Line Numbers
  1. db = DCOracle2.connect(<connect string>)
  2. c = db.cursor()
  3. my_record_list = c.prodecure.my_pack.my_get_proc ()
Do OUT params get translated into return values?
Did you try running your PHP code?
Does it error out or not?
Please post back if it does not work?
Jan 24 '08 #2
amitpatel66
2,367 Expert 2GB
[quote=Benny the Guard]I have a procedure (within a package) that generates a

Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PACKAGE my_pack AS
  2. TYPE my_type AS TABLE OF VARCHAR2;
  3.  
  4. PROCEDURE my_get_proc (my_records OUT my_type) AS
  5. BEGIN
  6.   SELECT NAME BULK COLLECT INTO my_records FROM my_table;
  7. END my_get_proc;
  8. END my_pack;
So my question is how do I call this from Python and get the results returned to me? Do I just need to:
Expand|Select|Wrap|Line Numbers
  1. db = DCOracle2.connect(<connect string>)
  2. c = db.cursor()
  3. my_record_list = c.prodecure.my_pack.my_get_proc ()
Do OUT params get translated into return values?

Try this:

Expand|Select|Wrap|Line Numbers
  1. db = DCOracle2.connect(<connect string>)
  2. c = db.cursor()
  3. c.prodecure.my_pack.my_get_proc (my_record_list)
  4.  
Jan 24 '08 #3
Tried both ways and Python gives an error. Specifically I see:

Traceback (most recent call last):
File "C:\dev\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" , line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\test.py", line 19, in ?
print ("**********************************")
File "C:\Python23\lib\site-packages\DCOracle2.py", line 1526, in __call__
cursor.execute(sql,__plist=args)
File "C:\Python23\lib\site-packages\DCOracle2.py", line 1001, in execute
result = self._cursor.execute()
DatabaseError: (24358, 'ORA-00000: normal, successful completion')


Any other ideas on how to get this to work?
Jan 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

68
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
1
by: Robert Scheer | last post by:
Hi. I wrote some stored procedures used by a web application. As I am fairly new to Oracle, I am missing some concepts when creating these procedures, as a result, the application is suffering...
11
by: jrefactors | last post by:
I want to know the differences between SQL Server 2000 stored procedures and oracle stored procedures? Do they have different syntax? The concept should be the same that the stored procedures...
7
by: vb_bv | last post by:
Does Pyton PL/SQL programming language of Oracle support? Thx
2
by: Prem via DBMonster.com | last post by:
hi, i am working on a migration project from Oracle to db2 8.1. i was able to migrate the stored procedures and functions in oracle to db2 with the help of the migration tool kit. now finally...
6
by: JV | last post by:
A ref cursor data type can obviously be returned as an output parameter of a stored procedure, but can an ASP.NET application call an oracle proc that uses a ref cursor as an input parameter? If...
1
by: Chad | last post by:
Hi, I am a SQL Server programmer using Oracle for the first time. In our .NET client apps which use a SQL Server back end, we would use Stored Procedure exclusively for all database access for...
1
by: Anthony Smith | last post by:
$stmt = $dbh->prepare("begin TOOLS_PKG.getOrgCode(?); end;"); $stmt->bindParam(1, $value, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12); $stmt->execute(); Does anything look wrong? This is a...
4
by: --CELKO-- | last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any kind of tools for this?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.