I have a problem to call an stored procedure with dynamic sql in php.
The next PL/SQL Part shows only a simple Version of my procedure.
Database is an Oracle 9iR2.
I have created the procedure in a package like this:
create or replace package xxx as
TYPE searchresultTCurTyp is REF Cursor;
-- i also replaced the last var of the procedure in the head and
-- body of the package with
-- searchresult_cv_inout out sys_refcursor but this also doesn't
show any result in php.
procedure search(row_in in varchar2,searchtext_in in varchar2,
searchresult_cv_inout IN OUT searchresultTCurTyp);
end xxx;
create or replace package body xxx as
procedure search(
row_in in varchar2,
searchtext_in in varchar2,
searchresult_cv_inout IN OUT searchresultTCurTyp)
is
begin
stmt := 1;
open searchresult_cv_inout for
'select myrow from
(select rownum myrow,'||row_in||' from xxx order by xxx asc)
where lower('||row_in||') = lower(searchtext_in)';
end search;
end xxx;
the problem is that i don't get any result from this procedure. I have tried many versions and changes, but till now I can't find a solution.
ID CAR DOORS
----------- ---------
1 BMW 4
2 MERCEDES 4
3 LOTUS 2
Now I try to execute my "search procedure" on that table.
procedure car(
spalten_in in varchar2,
searchtext_in in varchar2,
car_cv_inout IN OUT sys_refcursor)
is
begin
stmt := 0;
open car_cv_inout for
'select myrow from (select rownum myrow,:s from testtable order by car asc)
where lower(:s) = lower(:search)' USING in spalten_in,spalten_in,searchtext_in;
end car;
In SQL Plus I created a var cv refcursor to get the result of this procedure.
After that I execute the procedure with
exec car('CAR','BMW',:cv);
And i checked the result with print cv. But there is always: "no rows selected" (as in PHP)
If I start the Query without the procedure like this:
select myrow from (select rownum myrow,CAR from testtable order by car asc)where lower(CAR) = lower('BMW');
Then it works fine.
But I can't find the error, why this procedure always shows no rows.
Bookmarks