Page 1 of 1

UniScript error INSERTing rows in table with array fields

Posted: Sun 17 Aug 2014 19:28
by stevel
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);

Re: UniScript error INSERTing rows in table with array fields

Posted: Wed 20 Aug 2014 08:54
by PavloP
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;