Guid format

I switched my connection from native ODBC connection to Unidac connection and ran into problems with Guid.
if guid is with { } like '{DA29DB20-EF52-42C7-9ABC-8DE5337B0482}' i get param error engine Data conversion error: Parameter #1.
After testing I notice that I must enter guid with out {} like 'DA29DB20-EF52-42C7-9ABC-8DE5337B0482' which works. (this is our DB guid presentation format)
I got into aurelius.drivers.unidac and on setparams i changed
if parameter.datatype=ftguid then
parameter.asguid:= Tguid.Create(vartostr(p.ParamValue))
else
...
Didn't help.
Testcode with unidac works fine.

  q.ParamByName('guid').AsGuid := tguid.NewGuid;
  q.ParamByName('s').asstring := timetostr(now);
  q.ParamByName('a').AsInteger := 33;
  q.ExecSQL;

I compared both params with codesite and their properties are same (except name)

has anyone else faced similar problems?

What are the exact steps to reproduce the problem?> Because usually with Aurelius you don't need to handle GUID format as string. So you are probably doing something "low level"?
Usually you just have a property of type TGUID and Aurelius will save it to the database for you. That's all.

Steps to reproduce was to switch from Aurelius Native ODBC to Unidac. :slight_smile:
But to be honest, this might be more zen/unidac issue, i have asked from Devart forum about this ( Guid issue with Actian ZEN - Devart Forums)

One isolated case. Tdepartment_translations has singe table inheritance, in case you are wondering what's the extra parameter.
my code is simple.

var
  fmanager: TObjectManager;
  llist:tlist<Tdepartment_translations>;
  c:tuniconnection;
  icon: IDBConnection;
  uq: TUniQuery;
begin
  c := TUniConnection.Create(nil);
  c.ProviderName := 'ODBC';
  c.server := 'Driver=Pervasive ODBC Unicode Interface;dbq=kirkar;ServerName=mylaptop';
  c.LoginPrompt := FALSE;
  c.Connected := true;
  icon := TUniDacConnectionAdapter.Create( c,'ZEN',TRUE);
  icon.Connect;
  uq := tuniquery.Create(nil);
  uq.connection := c;
  Randomize;
  fmanager := TObjectManager.Create( icon );
  fmanager.Explorer.Events.OnSQLExecuting.Subscribe(
    procedure( args: TSQLExecutingArgs )
    var
      p: TDBParam;
    begin
      codesite.send( 'sql: ', args.sql );
      for p in args.Params.ToArray do
          codesite.send( '%s = %s', [ p.ParamName, VarToStr( p.ParamValue ) ] );
    end );
  llist := fmanager.find<Tdepartment_translations>.list;
  codesite.send('Origial Item[0] = %s  %s', [llist.Items[0].Id.ToString, llist.Items[0].Translation.ValueOrDefault]);
  llist.Items[0].Translation := 'test'+random(999999).tostring;
  fmanager.Flush;
  fmanager.Free;
  fmanager := TObjectManager.Create( icon );
  llist := fmanager.find<Tdepartment_translations>.list;
  codesite.send('After update Item[0] = %s  %s', [llist.Items[0].Id.ToString, llist.Items[0].Translation.ValueOrDefault]);

ANd codesite output

sql:  = SELECT A.id AS A_id, A.recordid AS A_recordid, A.languageid AS A_languageid, A.kaannos AS A_kaannos, A.tablename AS A_tablename
FROM kaannos_intavain A
WHERE A.tablename = :p_0
p_0 = PRYHMA
Origial Item[0] = {3CC90711-AC76-4209-BCF9-2677489C6644}  Foobar
sql:  = UPDATE kaannos_intavain SET 
  kaannos = :p1
WHERE id = :p_1
p1 = test842170
p_1 = {3CC90711-AC76-4209-BCF9-2677489C6644}
sql:  = SELECT A.id AS A_id, A.recordid AS A_recordid, A.languageid AS A_languageid, A.kaannos AS A_kaannos, A.tablename AS A_tablename
FROM kaannos_intavain A
WHERE A.tablename = :p_0
p_0 = PRYHMA
After update Item[0] = {3CC90711-AC76-4209-BCF9-2677489C6644}  Foobar

And It's not actually aurelius fault, if i put following code end of previous example (kaannos_intavain is table behind Tdepartment_translations)

uq := tuniquery.Create(nil);
  uq.connection := c;
  uq.SQL.Text := 'update kaannos_intavain set kaannos=:p1 where id=:p2';
  uq.ParamByName('p1').AsString := 'will this work';
  uq.ParamByName('p2').AsGuid:= tguid.Create( '{3CC90711-AC76-4209-BCF9-2677489C6644}');
  uq.ExecSQL;
  codesite.send('uq.rowsaffected', uq.rowsaffected);
  uq.ParamByName('p1').AsString := 'how about this, will this work';
  uq.ParamByName('p2').asstring:= '3CC90711-AC76-4209-BCF9-2677489C6644';
  uq.ExecSQL;
  codesite.send('uq.rowsaffected', uq.rowsaffected);

ouput is

uq.rowsaffected = 0
uq.rowsaffected = 1

and just to make sure my table structure is

CREATE TABLE "kaannos_intavain" ( 
	"id" UNIQUEIDENTIFIER NOT NULL, 
	"tablename" VARCHAR(40) NOT NULL CASE, 
	"recordid" INTEGER, 
	"languageid" INTEGER DEFAULT '1', 
	"kaannos" NVARCHAR(256));
CREATE UNIQUE INDEX "index_0" IN DICTIONARY ON "kaannos_intavain" ( 
	"id" );

Ok, I see. So, should we wait for Devart response about this issue?

Yes, meanwhile I'll just week using patched version, where I set parameter as string.

1 Like