# Use of bind variables using OCI8

**URL:** <https://www.ruby-forum.com/t/use-of-bind-variables-using-oci8/122484>\
**Category:** Ruby\
**Created:** [December 8, 2007, 12:38am UTC](https://www.ruby-forum.com/t/use-of-bind-variables-using-oci8/122484 "2007-12-08T00:38:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hbotadra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e9bcb4/32.png) [@hbotadra](https://www.ruby-forum.com/u/hbotadra)\
**Post date:** [December 8, 2007, 12:38am UTC](https://www.ruby-forum.com/t/use-of-bind-variables-using-oci8/122484/1 "2007-12-08T00:38:28Z")

</div>

Hey Guys,

I am having some issues with the use of bind variables…

When I use…

* * *

connFC = OCI8.new()

## connFC.exec(“SELECT \* from emp where id = #{id}”) { |row| }

it works perfectly fine…but when I modify to use bind variables for  
Number type…

* * *

connFC = OCI8.new()

cursorFC = connFC.parse(“SELECT \* from emp where id = :1”)  
cursorFC.bind\_param(1, id)

## cursorFC.exec(“SELECT \* from emp where id = #{id}”) { |row| }

I get no resultset…can you please tell me, what I might be missing?  
Do, I need to instantiate cursorFC to OCI8::Cursor or anything else,  
which I might be missing? Thanks for your help.

—Harnish

---

<div class="post-metadata">

**Author:** ![hbotadra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e9bcb4/32.png) [@hbotadra](https://www.ruby-forum.com/u/hbotadra)\
**Post date:** [December 8, 2007, 1:54am UTC](https://www.ruby-forum.com/t/use-of-bind-variables-using-oci8/122484/2 "2007-12-08T01:54:37Z")

</div>

Thanks guys…

My issue got resolved…

I was missing the fetch method…

* * *

connFC = OCI8.new()

cursorFC = connFC.parse(“SELECT \* from emp where id = :1”)  
cursorFC.bind\_param(1, id)

cursorFC.exec()

## cursorFC.fetch() { |row| }

works like a charm! Thanks…

—Harnish

Harnish B. wrote:

> Hey Guys,
> 
> I am having some issues with the use of bind variables…
> 
> When I use…
> 
> * * *
> 
> connFC = OCI8.new()
> 
> ## connFC.exec(“SELECT \* from emp where id = #{id}”) { |row| }
> 
> it works perfectly fine…but when I modify to use bind variables for  
> Number type…
> 
> * * *
> 
> connFC = OCI8.new()
> 
> cursorFC = connFC.parse(“SELECT \* from emp where id = :1”)  
> cursorFC.bind\_param(1, id)
> 
> ## cursorFC.exec(“SELECT \* from emp where id = #{id}”) { |row| }
> 
> I get no resultset…can you please tell me, what I might be missing?  
> Do, I need to instantiate cursorFC to OCI8::Cursor or anything else,  
> which I might be missing? Thanks for your help.
> 
> —Harnish
