Chrisdaems
Member
Hi,
I have some problems with sorting columns of a DBGrid in Delphi. I have a Dataset that executes a stored procedure on the Oracle server. The stored procedure has a out parameter with datatype Ref Cursor. The order by in the SQL is filled with a parameter. But I know that this is the problem. What I can do is using substition variables but then I can't create my select statement on the server. I also tried to create a WEAK REF CURSOR, in that case I write a concatenated SQL. But DOA has problems with this WEAK REF CURSORs.
Here are some examples about the case I am trying.
ORACLE
Type empRec IS RECORD
name emp.Name%Type,
loc emp.loc%type
end;
-- strong ref cursor
type rc_emp is ref cursor return emprec;
Procedure Select_Record(p_cursor IN OUT rc_emp,
p_Order IN p_Order) is
begin
open p_Cursor for Select name, loc from emp order by p_Order;
end;
Delphi
Setvariable('p_Order', 'name');
This doesn't work. Orcale can handle dynamic SQL like this.
If I Do it like this :
type c_emp is ref cursor; -- weak ref cursor
Procedure Select_Record(p_cursor IN OUT rc_emp,
p_Order IN p_Order) is
begin
open p_Cursor for 'Select name, loc from emp order by ' || p_Order;
end;
Then it is possible on the oracle site but I believe that DOA Has problems with ref cursors.
What I can do is using substitution on the doa site but I like to keep all DB actions on the oracle server and try to work only with stored procedures.
Is there anyone who can give me a tip to sort records in a DBGrid filled by a dataset that executes a stored procedure, without using another component?
Another question is also, HOW can I Use dynamic sql??
thanks chris
I have some problems with sorting columns of a DBGrid in Delphi. I have a Dataset that executes a stored procedure on the Oracle server. The stored procedure has a out parameter with datatype Ref Cursor. The order by in the SQL is filled with a parameter. But I know that this is the problem. What I can do is using substition variables but then I can't create my select statement on the server. I also tried to create a WEAK REF CURSOR, in that case I write a concatenated SQL. But DOA has problems with this WEAK REF CURSORs.
Here are some examples about the case I am trying.
ORACLE
Type empRec IS RECORD
name emp.Name%Type,
loc emp.loc%type
end;
-- strong ref cursor
type rc_emp is ref cursor return emprec;
Procedure Select_Record(p_cursor IN OUT rc_emp,
p_Order IN p_Order) is
begin
open p_Cursor for Select name, loc from emp order by p_Order;
end;
Delphi
Setvariable('p_Order', 'name');
This doesn't work. Orcale can handle dynamic SQL like this.
If I Do it like this :
type c_emp is ref cursor; -- weak ref cursor
Procedure Select_Record(p_cursor IN OUT rc_emp,
p_Order IN p_Order) is
begin
open p_Cursor for 'Select name, loc from emp order by ' || p_Order;
end;
Then it is possible on the oracle site but I believe that DOA Has problems with ref cursors.
What I can do is using substitution on the doa site but I like to keep all DB actions on the oracle server and try to work only with stored procedures.
Is there anyone who can give me a tip to sort records in a DBGrid filled by a dataset that executes a stored procedure, without using another component?
Another question is also, HOW can I Use dynamic sql??
thanks chris