# Oracle stored procs

**URL:** <https://www.ruby-forum.com/t/oracle-stored-procs/100048>\
**Category:** Ruby\
**Created:** [July 26, 2006, 8:48pm UTC](https://www.ruby-forum.com/t/oracle-stored-procs/100048 "2006-07-26T20:48:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndrewMcDonagh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@AndrewMcDonagh](https://www.ruby-forum.com/u/AndrewMcDonagh)\
**Post date:** [July 26, 2006, 8:48pm UTC](https://www.ruby-forum.com/t/oracle-stored-procs/100048/1 "2006-07-26T20:48:37Z")

</div>

Hi,

Has anyone managed to get calls to oracle stored procs to work yet?

Cheers

Andrew

---

<div class="post-metadata">

**Author:** ![AndrewMcDonagh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@AndrewMcDonagh](https://www.ruby-forum.com/u/AndrewMcDonagh)\
**Post date:** [July 26, 2006, 9:01pm UTC](https://www.ruby-forum.com/t/oracle-stored-procs/100048/2 "2006-07-26T21:01:15Z")

</div>

AndrewMcDonagh wrote:

> Hi,
> 
> Has anyone managed to get calls to oracle stored procs to work yet?
> 
> Cheers
> 
> Andrew

Sure. Using DBI with OCI8:

dbh = DBI.connect(dsn, user, pass)  
sth = dbh.prepare(“begin foo.some\_proc; end;”)  
sth.execute

I don’t think Kubo supports in/out parameters yet, though it has been  
discussed.

Regards,

Dan

This communication is the property of Qwest and may contain confidential  
or  
privileged information. Unauthorized use of this communication is  
strictly  
prohibited and may be unlawful. If you have received this communication  
in error, please immediately notify the sender by reply e-mail and  
destroy  
all copies of the communication and any attachments.

---

<div class="post-metadata">

**Author:** ![AndrewMcDonagh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@AndrewMcDonagh](https://www.ruby-forum.com/u/AndrewMcDonagh)\
**Post date:** [July 26, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/oracle-stored-procs/100048/3 "2006-07-26T21:07:42Z")

</div>

On 7/26/06, AndrewMcDonagh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> Has anyone managed to get calls to oracle stored procs to work yet?

Works fine for me out of the box. Here are some extentions I made to  
the OCI8 class to make it easier for me to deal with a ref cursor  
returned from a package function:

class OCI8  
class Cursor  
def get\_array  
ret = []  
while row = self.fetch\_hash  
ret \<\< row  
end  
ret  
end  
def bind(binds)  
binds.each\_pair do |k,v|  
if v.respond\_to? :indices  
self.bind\_param(k, v[0], v[1], v[2])  
else  
self.bind\_param(k, v)  
end  
end if binds  
end  
end

def get\_ref(plsql, binds=false, &block)  
cur = self.parse(‘begin :rs := ‘+plsql+’; end;’)  
cur.bind\_param(‘:rs’, OCI8::Cursor)  
cur.bind(binds)  
cur.exec  
if block\_given?  
arr = cur[‘:rs’].get\_array.collect &block  
else  
cur[‘:rs’].get\_array  
end  
end  
end

---

<div class="post-metadata">

**Author:** ![AndrewMcDonagh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@AndrewMcDonagh](https://www.ruby-forum.com/u/AndrewMcDonagh)\
**Post date:** [July 26, 2006, 9:47pm UTC](https://www.ruby-forum.com/t/oracle-stored-procs/100048/4 "2006-07-26T21:47:00Z")

</div>

Daniel B. wrote:

> Sure. Using DBI with OCI8:  
> Dan
> 
> This communication is the property of Qwest and may contain confidential or  
> privileged information. Unauthorized use of this communication is  
> strictly prohibited and may be unlawful. If you have received this  
> communication in error, please immediately notify the sender by reply  
> e-mail and destroy all copies of the communication and any attachments.

sweet cheers!

last time I looked it didn’t work or work well - hence the question.

Andrew
