Use of bind variables using OCI8

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs