#1 2015-05-27 14:42:56

LuizLH
Member
From: Brazil
Registered: 2015-05-27
Posts: 3

TSQLDBStatement.FetchAllAsJSON ORA-24391 invalid fetch operation

Hi,

I have a Server Oracle on Linux
Oracle Database 11g Release 11.2.0.4.0 - 64bit Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

My Application
Lib: mORMotNightlyBuild.zip
Delphi XE7 - Target Platforms (Win32)
Windows 7

Test Code:

function TTestServer.ExecQuery(prFileName: String; prParams: TStrings): RawUTF8;
var
  q: TQuery;
  i: Integer;
  ct: SynCommons.PPtrInt;
begin
  q := TQuery.Create(fProps.ThreadSafeConnection);
  try
    Q.SQL.Clear; 
    Q.SQL.LoadFromFile(prFileName);
    for i := 0 to prParams.Count-1 do
      Q.ParamByName(prParams.Names[i]).AsString := prParams.Values[prParams.Names[i]];
    Q.Open;
    Q.First;    
    Result:= Q.PreparedSQLDBStatement.FetchAllAsJSON(True, ct, True);
  finally
    q.Free;
  end;
end;

The Problem:
Line -> Result:= Q.PreparedSQLDBStatement.FetchAllAsJSON(True, ct, True);

When I execute the function with these parameters FetchAllAsJSON(True, ct, True)
I get the error ORA-24391

When I execute the function with these parameters FetchAllAsJSON(True)
Thats OK, but the first row of data is missing

What am I doing wrong?

TIA

Offline

#2 2015-05-27 15:34:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,662
Website

Re: TSQLDBStatement.FetchAllAsJSON ORA-24391 invalid fetch operation

You are missing things up with your ct parameter.

Just pass nil instead:

Result:= Q.PreparedSQLDBStatement.FetchAllAsJSON(True, nil, True);

In you case, you are passing a random pointer.

Offline

#3 2015-05-27 17:06:27

LuizLH
Member
From: Brazil
Registered: 2015-05-27
Posts: 3

Re: TSQLDBStatement.FetchAllAsJSON ORA-24391 invalid fetch operation

Hi,

Thank you for responding so quickly, I Changed to:

 Result:= Q.PreparedSQLDBStatement.FetchAllAsJSON(True, nil, True); 

and the error ORA-24391 remains

I tested with:

 Result:= Q.PreparedSQLDBStatement.FetchAllAsJSON(True, nil, False); 

and work correctly, but the first raw data is missing

TIA

Offline

#4 2015-05-27 17:38:06

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,662
Website

Re: TSQLDBStatement.FetchAllAsJSON ORA-24391 invalid fetch operation

Do not use a TQuery, but a regular TSynDBStatement.

Offline

#5 2015-05-27 19:53:20

LuizLH
Member
From: Brazil
Registered: 2015-05-27
Posts: 3

Re: TSQLDBStatement.FetchAllAsJSON ORA-24391 invalid fetch operation

Hi,

Changed to:

 TSQLDBOracleStatement 

now work 100%, very fast.

Thank You

Offline

#6 2015-05-27 21:02:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,662
Website

Re: TSQLDBStatement.FetchAllAsJSON ORA-24391 invalid fetch operation

:-)

Offline

Board footer

Powered by FluxBB