UniScript error INSERTing rows in table with array fields

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
stevel
Posts: 125
Joined: Tue 02 Nov 2010 19:01

UniScript error INSERTing rows in table with array fields

Post by stevel » Sun 17 Aug 2014 19:28

Using: UniDAC 5.3.10 Professional (without source), Delphi XE2, Firebird 2.5.2 SuperServer

TUniScript component fails with runtime error when script tries to insert data into table with array fields:

Table structure:

Code: Select all

CREATE TABLE JUMBO 
(  
  J_ID                 INTEGER,
  J_PROP               INTEGER[4],
  PRIMARY KEY (J_ID)
);
SQL INSERT command in script:

Code: Select all

INSERT INTO JUMBO (J_ID, J_PROP[1], J_PROP[2], J_PROP[3], J_PROP[4])
 VALUES(1, 1, 2, 3, 4);

PavloP
Devart Team
Posts: 149
Joined: Fri 24 Jan 2014 12:33

Re: UniScript error INSERTing rows in table with array fields

Post by PavloP » Wed 20 Aug 2014 08:54

Insert and update of the field, defined in Firebird as an array field is not available through SQL queries. For more information, refer to http://tracker.firebirdsql.org/browse/CORE-710
In UniDAC, you can extract, insert and update data of the array type using the TUniTable and TUniQuery components. These components output a field of the array type as an array of fields, if the value of the ComplexArrayFields parameter of the SpecificOptions property is set in True. You may use the following code for the record insertion:

Code: Select all

  UniTable1.Insert;

  UniTable1.FieldByName('J_ID').AsInteger := 1;
  UniTable1.FieldByName('J_PROP[0]').AsInteger := 1;
  UniTable1.FieldByName('J_PROP[1]').AsInteger := 2;
  UniTable1.FieldByName('J_PROP[2]').AsInteger := 3;
  UniTable1.FieldByName('J_PROP[3]').AsInteger := 4;

  UniTable1.Post;

Post Reply