Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Error 11949 in INSERT query
Mon, Apr 14 2008 7:39 AMPermanent Link

Gerard Visent
Hi all,

I'm adapting an existing app wich uses DBISAM 4 to use a home-made ORM.
I wrote a DBISAM4 db adapter for the ORM, wich encapsulates a DBISAM 4
database and all what is needed to retrieve data and execute querys.
I get a strange SQL error on a specific query.
The code that executes the query is the following:


procedure TDBISAM4Persister.InternalExecQuery(aSQL: string; aParams:
TParams);
var
  Q: TDBISAMQuery;
begin
  Q := TDBISAMQuery.Create(nil);
  Q.DatabaseName := FDatabase.DatabaseName;
  Q.SQl.Text := aSQL;
  Q.Params.AssignValues(aParams);
  Q.Prepare;
  Q.ExecSQL;
  Q.Free;
end;

The error I get is:

DBISAM Engine Error # 11949 SQL parsing error - Expected NULL, Boolean,
SmallInt, Word, AutoInc, Integer, or LargeInt expression but instead
found ? in INSERT SQL statement at line 1, column 371

The auto-generated SQL text (one long line, no line breaks) is:

INSERT INTO COMPTES (C1, C10, C11, C12, C2, C3, C4, C5, C6, C7, C8, C9,
CANVIINICIAL, CODI, EMPRESA, EXERCICI, CONSOLIDARCANVI, CREDIT,
CREDITINICIAL, CREDITTANCAMENT, CTEDIFNEGCANVI, CTEDIFPOSCANVI, D1, D10,
D11, D12, D2, D3, D4, D5, D6, D7, D8, D9, DEBIT, DEBITINICIAL,
DEBITTANCAMENT, ESDEMAJOR, MONEDA, TITOL) VALUES (:C1, :C10, :C11, :C12,
:C2, :C3, :C4, :C5, :C6, :C7, :C8, :C9, :Canviinicial, :Codi,
:CodiEmpresa, :CodiExercici, :Consolidarcanvi, :Credit, :Creditinicial,
:Credittancament, :Ctedifnegcanvi, :Ctedifposcanvi, :D1, :D10, :D11,
:D12, :D2, :D3, :D4, :D5, :D6, :D7, :D8, :D9, :Debit, :Debitinicial,
:Debittancament, :Esdemajor, :Moneda, :Titol)

I can't see any ? in the text.

The params all seem to be assigned OK, here are the values for the
specific error:

C1: 0
C10: 0
C11: 0
C12: 0
C2: 0
C3: 0
C4: 0
C5: 0
C6: 0
C7: 0
C8: 0
C9: 0
Canviinicial: <null>
Codi: 1
CodiEmpresa: 99
CodiExercici: 1
Consolidarcanvi:
Credit: 24432,93
Creditinicial: 0
Credittancament: 0
Ctedifnegcanvi: <null>
Ctedifposcanvi: <null>
D1: 0
D10: 0
D11: 0
D12: 0
D2: 0
D3: 0
D4: 0
D5: 0
D6: 0
D7: 0
D8: 0
D9: 0
Debit: 192691,43
Debitinicial: 0
Debittancament: 0
Esdemajor:
Moneda: <null>
Titol: Finançament bàsic

DBISAM4 version is 4.26 Build 2, with Delphi 7.

Any idea of what's wrong?

Best regards,

Gerard.
Mon, Apr 14 2008 7:43 AMPermanent Link

Gerard Visent
BTW, I just found that by using a switch of the ORM framework that
excludes null attributes from the SQL generation, everything works fine.
In this same case I posted, there are 4 null attributes for the object,
so the INSERT SQL is generated for all the colums except the 4 null columns.
Could it be that some kind of internal limit is reached with the version
that inserts all the columns?
Mon, Apr 14 2008 7:46 AMPermanent Link

"Robert"

"Gerard Visent" <gerard@zootec.ad> wrote in message
news:E04A0545-7517-4709-A9A6-8540A8FE1471@news.elevatesoft.com...
> Titol: Finançament bàsic
>

This probably needs to be in single quotes, because of the space.

Robert

Mon, Apr 14 2008 10:53 AMPermanent Link

Gerard Visent
En/na Robert ha escrit:
> "Gerard Visent" <gerard@zootec.ad> wrote in message
> news:E04A0545-7517-4709-A9A6-8540A8FE1471@news.elevatesoft.com...
>> Titol: Finançament bàsic
>>
>
> This probably needs to be in single quotes, because of the space.
>
Sorry for not making it clear, but this is the output of a debug message
I added to see what was going on.

    on e: Exception do
    begin
      s := 'DBISAM4 version: '+Q.EngineVersion;
      s := s + #13 + e.Message;
      s := s + #13#13 + Q.SQL.Text+#13#13;
      for i := 0 to Q.ParamCount-1 do
      begin
        s := s+ q.Params[i].Name+': ';
        if Q.Params[i].IsNull then
          s := s + '<null>'
        else
          s := s + q.Params[i].AsString;
        s := s + #13;
      end;
      TfmLog.Execute(s);
    end;
Mon, Apr 14 2008 2:29 PMPermanent Link

Gerard Visent
I'm sorry, it was my fault. The metadata definition for the db was wrong
and some param wasn't assigned right.
Mon, Apr 14 2008 2:29 PMPermanent Link

This message was cancelled from within Mozilla.
Mon, Apr 14 2008 2:29 PMPermanent Link

This message was cancelled from within Mozilla.
Mon, Apr 14 2008 2:29 PMPermanent Link

This message was cancelled from within Mozilla.
Image