odac to unidac - insert statement prepare fails

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
albourgz
Posts: 160
Joined: Wed 06 May 2009 12:17
Location: belgium

odac to unidac - insert statement prepare fails

Post by albourgz » Thu 25 Aug 2016 09:37

Hi,
using c++ builder xe 10 pro seattle and unidac 6.3.13, connected to oracle 12.1.0.2 SE in direct mode (exception also occurs using oracle client).
I have a query on a datamodule that worked with odac, and that cannot be prepared using unidac: exception during FDM->QInsStockMove->Prepare();, EAssertionFailed with message 'unknown data type ( d:\projects\Delphi\dac\oracle\source\oraclasses.pas, line 4753)'.

From ODAC dfm:

Code: Select all

  object QInsStockMove: TOraQuery
    Session = OurDB
    SQL.Strings = (
      
        'INSERT INTO VStockMoves(SITEORIG, SITEDEST, PRODUCT, QTMOVE, OND' +
        'T, BUYUP, CURUP, ID, BUYDAYCOURSE, QTORIG, QTDEST, USERID, REASO' +
        'N, SENDNR, ORDERDET, JOB, NO_REC, unmodifyable) VALUES '
      
        '                           (:1,       :2,       :3,      :4,    ' +
        ' :5,   :6,    :7,    :8, :9,           :10,    :11,    :12,    :' +
        '13,    :14,    :15,      :16, :17, :18)')
    Left = 320
    Top = 16
    ParamData = <
      item
        DataType = ftInteger
        Name = '1'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '2'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '3'
        Value = nil
      end
      item
        Name = '4'
        Value = Null
        ExtDataType = 107
      end
      item
        DataType = ftDateTime
        Name = '5'
        Value = nil
      end
      item
        Name = '6'
        Value = Null
        ExtDataType = 107
      end
      item
        DataType = ftString
        Name = '7'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '8'
        Value = nil
      end
      item
        DataType = ftFloat
        Name = '9'
        Value = nil
      end
      item
        Name = '10'
        Value = Null
        ExtDataType = 107
      end
      item
        Name = '11'
        Value = Null
        ExtDataType = 107
      end
      item
        DataType = ftInteger
        Name = '12'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '13'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '14'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '15'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '16'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '17'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = '18'
        Value = nil
      end>
  end
Unidac dfm:

Code: Select all

  object QInsStockMove: TUniQuery
    Connection = OurDB
    SQL.Strings = (
      
        'INSERT INTO VStockMoves(SITEORIG, SITEDEST, PRODUCT, QTMOVE, OND' +
        'T, BUYUP, CURUP, ID, BUYDAYCOURSE, QTORIG, QTDEST, USERID, REASO' +
        'N, SENDNR, ORDERDET, JOB, NO_REC, unmodifyable) VALUES '
      
        '                           (:1,       :2,       :3,      :4,    ' +
        ' :5,   :6,    :7,    :8, :9,           :10,    :11,    :12,    :' +
        '13,    :14,    :15,      :16, :17, :18)')
    Left = 320
    Top = 16
    ParamData = <
      item
        DataType = ftInteger
        Name = '1'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '2'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '3'
        Value = nil
      end
      item
        Name = '4'
        Value = nil
        ExtDataType = 107
      end
      item
        DataType = ftDateTime
        Name = '5'
        Value = nil
      end
      item
        Name = '6'
        Value = nil
        ExtDataType = 107
      end
      item
        DataType = ftString
        Name = '7'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '8'
        Value = nil
      end
      item
        DataType = ftFloat
        Name = '9'
        Value = nil
      end
      item
        Name = '10'
        Value = nil
        ExtDataType = 107
      end
      item
        Name = '11'
        Value = nil
        ExtDataType = 107
      end
      item
        DataType = ftInteger
        Name = '12'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '13'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '14'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '15'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '16'
        Value = nil
      end
      item
        DataType = ftInteger
        Name = '17'
        Value = nil
      end
      item
        DataType = ftUnknown
        Name = '18'
        Value = nil
      end>
  end
The only difference is that Value = nil has been replaced with Value=Null by the IDE when ExtDataType=107. (NUMBER(12,3).

Code: Select all

SQL> desc cec.vstockmoves
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                        NOT NULL NUMBER(10)
 SITEORIG                                  NOT NULL NUMBER(4)
 SITEDEST                                  NOT NULL NUMBER(4)
 QTORIG                                    NOT NULL NUMBER(12,3)
 QTDEST                                    NOT NULL NUMBER(12,3)
 QTMOVE                                    NOT NULL NUMBER(12,3)
 ONDT                                      NOT NULL DATE
 BUYUP                                              NUMBER(16,6)
 CURUP                                              CHAR(3)
 BUYDAYCOURSE                                       NUMBER(14,8)
 USERID                                    NOT NULL NUMBER(4)
 REASON                                    NOT NULL NUMBER(9)
 SENDNR                                             NUMBER(6)
 PRODUCT                                   NOT NULL NUMBER(10)
 ORDERDET                                           NUMBER(9)
 JOB                                                NUMBER(9)
 NO_REC                                             NUMBER(8)
 UNMODIFYABLE                                       NUMBER(1)
So the exception is easy to reproduce: just prepare the statement, no parameter to give!
The ExtDataType = 107 and Value=Null come from ODAC (or perhaps earlier from BDE). Should I remove this and set all fieltType to ftUnknown (I didn't find a way in unidac to refresh the query so that field types are updated)?

Thanks.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: odac to unidac - insert statement prepare fails

Post by MaximG » Fri 26 Aug 2016 10:56

You are absolutely right. The ftNumber type parameter is present in ODAC, and absent in UniDAC. Specify the new type values on setting query parameters in UniDAC using the types available in UniDAC.

Post Reply