Still struggling with DA and ElevateDB

I’m still having trouble getting basic functionality with DA and ElevateDB.

I have created a (more or less) identical project/database with MySQL and that seems to work as expected.

What I have done:

  1. Created a simple database in ElevateDB and MySQL
  2. Created a minimal DA server and DA client
  3. Created basically identical schema(s) for each database

The trouble revolves around indexing, I think. I can’t seem to add or edit any records to the ElevateDB without getting errors. Deleting existing records seems to work fine.

The error I get when trying to add a new record is:
A problem occurred while inserting a record in table ‘mytable’, record ‘mytable:-1’.

ElevateDB Error #700 An error was found in the statement at line 1 and column 8 (ElevateDB Error #401 The function GetAutoIncValue does not exist in the schema Default)

I have tried changing the field type in the schema to Integer (from AutoInc). I have tried every possible combination of the check-boxes in the schema modeler that I could think of. I have also tried changing the field type in the ElevateDB. I can’t find a combination that works while having an index on the c_id field.

I do get different errors, but always some sort of error.

Here are the database definitions:
ElevateDB:

CREATE TABLE "mytable" (
"c_id" INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
"c_name" VARCHAR(100) COLLATE "UNI");

CREATE INDEX "PRIMARY" ON "mytable" ("c_id");

MySQL:

CREATE TABLE IF NOT EXISTS `mydb`.`mytable` (
  `c_id` INT(11) NOT NULL AUTO_INCREMENT,
  `c_name` VARCHAR(100) NULL DEFAULT NULL,
  PRIMARY KEY (`c_id`))
Here is the schema: the only difference between the two is the 
<ConnectionType>MySql</ConnectionType> 
and 
<ConnectionType>ElevateDB</ConnectionType> 
line
<TDASchema>
  <UnionDataTables IsObject="true" Count="0" IsCollection="true" Type="TDAUnionDataTableCollection" ItemClass="TDAUnionDataTable" />
  <JoinDataTables IsObject="true" Count="0" IsCollection="true" Type="TDAJoinDataTableCollection" ItemClass="TDAJoinDataTable" />
  <Datasets IsObject="true" Count="1" IsCollection="true" Type="TDADatasetCollection" ItemClass="TDADataset">
    <Item0>
      <ReadOnly>False</ReadOnly>
      <Fields IsObject="true" Count="2" IsCollection="true" ItemClass="TDAField" Type="TDASchemaFieldCollection">
        <Item0>
          <Name>c_id</Name>
          <Alignment>taLeftJustify</Alignment>
          <Calculated>False</Calculated>
          <ServerCalculated>False</ServerCalculated>
          <DataType>datAutoInc</DataType>
          <DefaultValue />
          <CustomAttributes />
          <DictionaryEntry />
          <DisplayFormat />
          <DisplayLabel>c_id</DisplayLabel>
          <DisplayWidth>0</DisplayWidth>
          <EditFormat />
          <EditMask />
          <InPrimaryKey>True</InPrimaryKey>
          <LogChanges>True</LogChanges>
          <ReadOnly>False</ReadOnly>
          <RegExpression />
          <Required>True</Required>
          <ServerAutoRefresh>False</ServerAutoRefresh>
          <Visible>True</Visible>
          <Expression />
          <Size>0</Size>
          <DecimalScale>0</DecimalScale>
          <DecimalPrecision>0</DecimalPrecision>
          <BlobType>dabtUnknown</BlobType>
          <GeneratorName />
          <BusinessClassID />
          <Description />
        </Item0>
        <Item1>
          <Name>c_name</Name>
          <Alignment>taLeftJustify</Alignment>
          <Calculated>False</Calculated>
          <ServerCalculated>False</ServerCalculated>
          <DataType>datWideString</DataType>
          <DefaultValue />
          <CustomAttributes />
          <DictionaryEntry />
          <DisplayFormat />
          <DisplayLabel>c_name</DisplayLabel>
          <DisplayWidth>0</DisplayWidth>
          <EditFormat />
          <EditMask />
          <InPrimaryKey>False</InPrimaryKey>
          <LogChanges>True</LogChanges>
          <ReadOnly>False</ReadOnly>
          <RegExpression />
          <Required>False</Required>
          <ServerAutoRefresh>False</ServerAutoRefresh>
          <Visible>True</Visible>
          <Expression />
          <Size>100</Size>
          <DecimalScale>0</DecimalScale>
          <DecimalPrecision>0</DecimalPrecision>
          <BlobType>dabtUnknown</BlobType>
          <GeneratorName />
          <BusinessClassID />
          <Description />
        </Item1>
      </Fields>
      <BusinessRulesClient IsObject="true" Type="TDAClientBusinessRuleScript">
        <CompileOnServer>False</CompileOnServer>
        <RunOnClientAndServer>False</RunOnClientAndServer>
        <Script />
        <ScriptLanguageStr />
        <Description />
        <Name />
      </BusinessRulesClient>
      <BusinessRulesServer Type="TDABusinessRuleScript" IsObject="true">
        <Script />
        <ScriptLanguageStr />
        <Description />
        <Name />
      </BusinessRulesServer>
      <UpdateCommandName />
      <DeleteCommandName />
      <InsertCommandName />
      <Statements IsCollection="true" IsObject="true" Count="1" ItemClass="TDAStatement" Type="TDAStatementCollection">
        <Item0>
          <Connection />
          <SQL />
          <TargetTable>mytable</TargetTable>
          <ConnectionType>ElevateDB</ConnectionType>
          <Default>False</Default>
          <StatementName />
          <StatementType>stAutoSQL</StatementType>
          <GeneratorName />
          <ColumnMappings IsObject="true" Count="2" IsCollection="true" Type="TDAColumnMappingCollection" ItemClass="TDAColumnMapping">
            <Item0>
              <DatasetField>c_id</DatasetField>
              <SQLOrigin>c_id</SQLOrigin>
              <TableField>c_id</TableField>
            </Item0>
            <Item1>
              <DatasetField>c_name</DatasetField>
              <SQLOrigin>c_name</SQLOrigin>
              <TableField>c_name</TableField>
            </Item1>
          </ColumnMappings>
          <Description />
        </Item0>
      </Statements>
      <Params IsObject="true" Count="0" IsCollection="true" Type="TDAParamCollection" ItemClass="TDAParam" />
      <CustomAttributes />
      <IsPublic>True</IsPublic>
      <DynamicWhereXML />
      <BusinessClassID />
      <Description />
      <Name>mytable</Name>
    </Item0>
  </Datasets>
  <Commands IsObject="true" Count="0" IsCollection="true" ItemClass="TDASQLCommand" Type="TDASQLCommandCollection" />
  <RelationShips IsObject="true" Count="0" IsCollection="true" Type="TDADatasetRelationshipCollection" ItemClass="TDADatasetRelationship" />
  <UpdateRules IsObject="true" Count="0" IsCollection="true" Type="TDAUpdateRuleCollection" ItemClass="TDAUpdateRule" />
  <CustomAttributes />
  <Version>0</Version>
  <BusinessRulesServer Type="TDABusinessRuleScript" IsObject="true">
    <Script />
    <ScriptLanguageStr />
    <Description />
    <Name />
  </BusinessRulesServer>
</TDASchema>

I’ve attached the server and client projects. In the server project there is a folder for the ElevateDB and MySQL schemas and connections. I have been copying them into the parent folder to switch between them.
app.zip (71.6 KB)
appServer.zip (857.0 KB)

There are db-level incompatibility between the way AutoInc is supported in ElevateDB and in Data Abstract.

To allow Data Abstract for .NET to process AutoInc values define following SQL function:

Define function GetAutoIncValue that accepts parameter TableName of type VarChar(250) and returns an Integer

Function body should be

BEGIN
  DECLARE FieldName VARCHAR(250);
  DECLARE Value INTEGER;
  EXECUTE IMMEDIATE
    'SELECT  name  INTO ?  FROM Information.TableColumns  WHERE  Generated  AND  TableName=?'
     USING FieldName, TableName;
  EXECUTE IMMEDIATE
    'SELECT  LASTIDENTITY("' + TableName + '", "' + FieldName + '") INTO ?'
    USING  Value;

  RETURN  Value;
END

After that the AutoInc fields should work in ElevateDB

Thanks antonk,

Looks like it’s getting closer to working.

When I add a new row, the record does insert, but I get this error:

A problem occurred while inserting a record in table ‘mytable’, record ‘mytable:-1’.

Object cannot be cast from DBNull to other types.

When I edit a record, the update does not happen, and I get this error:

A problem occurred while editing a record in table ‘mytable’, record ‘mytable:15’.

ElevateDB Error #1011 An error occurred with the parameter :c_name (A conversion error occurred with the value cchris)

Hmm. There can be a lot of different reasons for this - from Data Abstract bug up to misconfigured application Schema. Perhaps the fastest way to resolve this would be if you’ll create a testcase and will send it to support@ along with instructions/screenshots displaying how to reproduce the issue.

Thanks in advance

Ok, thanks. I just emailed that stuff in.

Hmm, unfortunately I do not see it

I assumed that “support@” in your post meant: support (at) remobjects.com

Is that correct?

If so, could my attached .zip files be causing a spam filter problem?

Thanks

Yes, they could trigger either AV or spam checks. If there is nothing business-specific then could you attach the testcase here in the thread?

another workaround: you can drop PM to support user here and attach your .zip

Ok, nothing sensitive in the additional info so here is my email and attachments:

Hi Support,

Antonk in the Talk forum suggested I email an example project, to help
figure out what’s going on.

Here is the thread in the forum:
https://talk.remobjects.com/t/still-struggling-with-da-and-elevatedb/

Just to reiterate, everything works as expected with a MySQL database.

I’ve attached the server and client projects that I am using. The
server’s zip file also includes the ElevateDB database files in the db
folder.

Also the first attached screenshot is what I get when adding a new
record. The second screenshot is what I get when editing an existing
record.

EDIT: It looks like the screenshots uploaded in the opposite order, so the first is the error from editing, and the second is from creating.

SimpleDataOperations.zip (138.7 KB)
appServer.zip (3.5 MB)

Hello

I’ve reproduced the issue and I am currently working on it

Thanks, logged as bugs://81045

bugs://81045 got closed with status fixed.

Hello

Please drop a main to support@ with your login name on the remobjects.com site so we’ll provide you an updated build

Ok, thanks.

Just sent my login name.

Please let me know if you didn’t get the email. My last email didn’t make it through to that address, but it was probably because of an attachment.