Page 1 of 1

TClientDataset issue when DefaultValues is set (PostGreSQL)

Posted: Thu 09 Feb 2012 16:59
by swierzbicki
Hello,

I'm not able to open a ClientDataset linked to an uniquery having the DefaultValues set True. In my case I'm getting an error (when activing the clientdataset) telling me that the default expressions are invalid !
It happens on ALL fields having a default expression !

Here is the table DDL :

Code: Select all

CREATE TABLE public.agenda_positions (
  "Id_Agenda" INTEGER NOT NULL, 
  "Id_Affaire" INTEGER NOT NULL, 
  "Id_Position" VARCHAR(3) DEFAULT ''::character varying NOT NULL, 
  "Date_Creation" TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT now(), 
  "Utilisateur" VARCHAR(50) DEFAULT "current_user"(), 
  "Quantite" DOUBLE PRECISION DEFAULT 0 NOT NULL
) WITHOUT OIDS;
Here is the Delphi DFM objects

Code: Select all

object mainconnection: TUniConnection
  ProviderName = 'PostgreSQL'
  Database = 'myCRM'
  SpecificOptions.Strings = (
    'PostgreSQL.ApplicationName=myCRM'
    'PostgreSQL.Schema=public'
    'DB2.UseUnicode=True'
    'PostgreSQL.Charset=ISO-8859-1')
  Options.KeepDesignConnected = False
  ConnectDialog = UniConnectDialog1
  Left = 64
  Top = 56
end

object qrAgenda_Positions: TUniQuery
  UpdatingTable = 'agenda_positions'
  Connection = mainconnection
  SQL.Strings = (
    'SELECT '
    '  agenda_positions."Id_Agenda",'
    '  agenda_positions."Id_Affaire",'
    '  agenda_positions."Id_Position",'
    '  agenda_positions."Date_Creation",'
    '  agenda_positions."Utilisateur",'
    '  agenda_positions."Quantite"'
    'FROM'
    '  agenda_positions'
    'Where '
    'agenda_positions."Id_Agenda" = :Id_Agenda')
  Options.QuoteNames = True
  Options.DefaultValues = True
  BeforeOpen = DatasetBeforeOpen
  AfterOpen = DatasetAfterOpen
  Left = 32
  Top = 8
  ParamData = 
end
object cdsAgenda_Positions: TClientDataSet
  Aggregates = 
  Params = 
  ProviderName = 'dspAgenda_Positions'
  Left = 32
  Top = 112
end
object dspAgenda_Positions: TDataSetProvider
  DataSet = qrAgenda_Positions
  Left = 32
  Top = 56
end
object dsAgenda_Positions: TUniDataSource
  DataSet = cdsAgenda_Positions
  Left = 32
  Top = 168
end
I'm working with Delphi XE / XE2. Can you provide me a fix ?

Posted: Fri 10 Feb 2012 09:35
by bork
Hello

TClientDataSet doesn't support the default values like ''::character varying or "current_user"(). If you want to use the default values, you should use TUniQuery without TClientDataSet. If you want to use the TClientDataSet, you should set TUniQuery.Options.DefaultValues=False.

Also you can write a suggestion to Embarcadero and propose to support the default values initialization in the TClientDataSet from TDataSet's.

Posted: Fri 10 Feb 2012 12:53
by swierzbicki
Hello,

Thank you for the clarification but I'm pretty confident that *YOU* will get more attention from Embarcadero when asking such a suggestion.

For the record here is the report I've just filled :

Report No: 103324 Status: Reported
Support default values initialization in TClientDataSet from TDataSet's.
http://qc.embarcadero.com/wc/qcmain.aspx?d=103324
QCWIN:Defect_No=103324

BR

Posted: Thu 16 Feb 2012 11:16
by AlexP
Hello,

Implementation of any suggestion by Embarcadero developers doesn't depand on who has made the suggestion. Therefore, even if we offer a corresponding proposal, there are no guarantees in its implementation.