Sql insert error if roAfterInsert selected

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mika
Posts: 20
Joined: Thu 08 May 2014 06:15

Sql insert error if roAfterInsert selected

Post by mika » Wed 13 Jul 2016 10:24

I'm using unidac 6.2.9 for delphi2007, ODBC provider and Actian PSQL 12.
UniQuery.sql is something simple like "select * from table".

if RefreshOptions has roAfterInsert during INSERT query like

Code: Select all

select "Field1" as _0, "Field2" as _1 FROM table WHERE "Field1" IS NULL 
is generated automatically. Problem is that PSQL doesn't like at all from field name like _0 and _1 unless they are quoted but unfortunatelly QuoteFields doesn't affect to that.

Edit:
I'm trying to refresh data because I need that FIELD1 value after insert. Field1 is Identity field.
Can't just get it with odbc-provider. if using separete sql statements, i would first execute insert and after
that execute query "select @@identity " but that's now difficult, because queries are connected to datagrid.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sql insert error if roAfterInsert selected

Post by AlexP » Fri 15 Jul 2016 11:17

Hello,

To solve the issue, you can set the "correct" query in the UniQuery1.SQLRefresh property, for example:

Code: Select all

UniQuery1.SQLRefresh.Text := 'select "Field1", "Field2" FROM table WHERE "Field1" IS NULL';

mika
Posts: 20
Joined: Thu 08 May 2014 06:15

Re: Sql insert error if roAfterInsert selected

Post by mika » Fri 15 Jul 2016 11:41

Hello,
Actually I realized that myself - forgot to post sorry about that- but my problem is now that
Field1 is autoincrement (identity) and I'm just not able to refresh it smootly.
As far as I know, I (or Uniquery etc) should execute select @@idenity after insert

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sql insert error if roAfterInsert selected

Post by AlexP » Mon 18 Jul 2016 10:04

Currently, ODBCUniProvider has no support for automatic retrieving of identity field values. We will consider the possibility to add support for identity in one of the next versions.

mika
Posts: 20
Joined: Thu 08 May 2014 06:15

Re: Sql insert error if roAfterInsert selected

Post by mika » Wed 20 Jul 2016 08:25

Okay - I'll be waiting that :) Meanwhile i have to work with legacy Titan tbTable components

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sql insert error if roAfterInsert selected

Post by AlexP » Thu 21 Jul 2016 10:54

We have already added this functionality, it will be available in the next UniDAC version

Post Reply