#1 2015-03-27 07:39:41

Shahid
Member
Registered: 2015-03-27
Posts: 2

Strange error

Hi All,

When I insert a duplicate key value I receive this strange error from remote WinHttpServer :

TSQLDBWinHTTPConnectionProperties.Process(cExecute): server raised EZSQLException with "SQL Error:  Dynamic SQL Error SQL error code = -501 Attempt to reclose a closed cursor. Error Code: -501. The cursor identified in a FETCH or CLOSE statement is not open."


here is code:

 procedure TfrmAreaAdd.btnAddClick(Sender: TObject);
var code, err: integer;
    q : TQuery;
begin

   val (edtCode.Text,code, err);
   if code <= 0 then
   begin
      Showmessage('Invalid area code');
      edtCode.SetFocus;
      exit;
   end;

   if Trim(edtName.Text) = '' then
   begin
      Showmessage('Invalid area name');
      edtCode.SetFocus;
      exit;
   end;
   q := TQuery.Create(dm.fProps.MainConnection);
   try
     dm.fProps.MainConnection.StartTransaction;
     try
        q.SQL.Add('insert into area(ano, aname) values(:code, :name) ');
        q.ParamByName('code').AsInteger := code;
        q.ParamByName('name').AsString := edtName.Text;
        q.ExecSQL;
        dm.fProps.MainConnection.Commit;
        q.Close;
        ShowMessage('Area added');
        edtCode.Text := '';
        edtName.Text := '';
     except
       on e:exception do
       begin
          dm.fProps.MainConnection.Rollback;
          ShowMessage(e.Message);
       end;
     end;
   finally
     q.free;
   end;
end;

Shahid

Offline

#2 2015-03-27 08:45:03

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

Re: Strange error

Could you run the CLIENT in the IDE debugger, and find out more about the context?
Could you run the SERVER in the IDE debugger, and find out more about the context?

What is the DB you are connected to? Firebird?
Do you have the latest version of the Zeos?
Did you try with another provider, like FireDAC?

Offline

#3 2015-03-27 10:19:59

Shahid
Member
Registered: 2015-03-27
Posts: 2

Re: Strange error

I'm using Zeos 7.0.3-stable and Interbase 7.5.1 (legacy database). Current zeos is buggy for interbase server.

Here is my server code:

 program MyHTTPServer;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  SynDB,
  SynDBZeos,
  SynDBSQLite3,
  SynSQLite3Static,
  SynDBRemote,
  SynCommons,
  SynLog;

var
  Props : TSQLDBConnectionProperties;
  HttpServer : TSQLDBServerAbstract;
begin
  with TSynLog.Family do
  begin
    Level := LOG_VERBOSE;
    EchoToConsole := LOG_VERBOSE;
  end;
  Props := TSQLDBZEOSConnectionProperties.Create('zdbc:interbase-6://localhost:3050','d:\data\inter1314.ib','sysdba','masterkey');
  HttpServer := TSQLDBServerHttpApi.Create(Props,'syndbremote','8092','user','pass');
  writeln('Server running.....');
  Readln;
  HttpServer.Free;
  Props.Free;
end.  

and here is the server log:

12:36:30 PM	Enter	 TSQLDBZEOSStatement(0134D640).0050A7C8 
12:36:30 PM	SQL	    TSQLDBZEOSStatement(0134D640) insert into area(ano, aname) values(2, 'MULTAN')
12:36:30 PM	Exception	    EZSQLException ("SQL Error:  violation of PRIMARY or UNIQUE KEY constraint \"AREA_PK\" on table \"AREA\". Error Code: -803. Invalid insert or update value(s): object columns are\nconstrained - no 2 table rows can have duplicate column values The SQL: insert into area(ano, aname) values(?, ?); ") at 004D4447  stack trace API 00434734 00404258 
12:36:30 PM	Exception	    EZSQLException ("SQL Error:  Dynamic SQL Error SQL error code = -501 Attempt to reclose a closed cursor. Error Code: -501. The cursor identified in a FETCH or CLOSE statement is not open.") at 004D4447  stack trace API 00434734 00404258

Offline

#4 2015-03-27 10:55:18

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

Re: Strange error

We support only Zeos 7.2 branch AFAIR - please see the doc.
http://synopse.info/files/html/Synopse% … #TITLE_162

You may try with other access library, e.g. FireDac or UniDac.

Offline

Board footer

Powered by FluxBB