From: "B. Randy" Date: 2009-04-21T23:21:46+09:00 Subject: Re: OCI-8, Oracle : 'ORDER BY' doesn't work with 'bind_param' Hello Robert, I've been long to reply, I'm working on other things. But I've tested your solution with success :) This solve my problem. Thanks for the solution and the explanations. Robert Klemme wrote: > > Qute from the document: > > $s = oci_parse($c, "select first_name, last_name > from employees > order by > case :ob > when 'FIRST_NAME' then first_name > else last_name > end"); > oci_bind_by_name($s, ":ob", $vs); > oci_execute($s); > > That's a bad hack and is likely to screw execution plans. Using > multiple SQL statements is superior since Oracle's CBO can then handle > this much easier. The DBA will also have a hard time optimizing this > because he sees just a single statement. Whereas with different > statements of which some are slow he immediately sees the proper SQL. > Also, you get better statistical evaluations. > > Kind regards > > robert -- Posted via http://www.ruby-forum.com/.