Page 1 of 1

Sql insert error if roAfterInsert selected

Posted: Wed 13 Jul 2016 10:24
by mika
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.

Re: Sql insert error if roAfterInsert selected

Posted: Fri 15 Jul 2016 11:17
by AlexP
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';

Re: Sql insert error if roAfterInsert selected

Posted: Fri 15 Jul 2016 11:41
by mika
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

Re: Sql insert error if roAfterInsert selected

Posted: Mon 18 Jul 2016 10:04
by AlexP
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.

Re: Sql insert error if roAfterInsert selected

Posted: Wed 20 Jul 2016 08:25
by mika
Okay - I'll be waiting that :) Meanwhile i have to work with legacy Titan tbTable components

Re: Sql insert error if roAfterInsert selected

Posted: Thu 21 Jul 2016 10:54
by AlexP
We have already added this functionality, it will be available in the next UniDAC version