TOraSQL raise 'Unknown data type' exception

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
erezharari55
Posts: 2
Joined: Sun 24 Mar 2019 13:56

TOraSQL raise 'Unknown data type' exception

Post by erezharari55 » Mon 25 Mar 2019 08:21

Environment:
ODAC 10.1.3, Delphi 10.2, Oracle 11g.

Symptoms:
Inserting GUID into Oracle field using TOraSQL raise
Exception error message: 'Unknown data type (C:\....\OraClasses.pas, line 4851)'
Exception type: EAssertionFailed

Details:
I used TOraSQL to insert GUID into Oracle field that defined "Unique_Id RAW(16) NULL" .
The SQL is:
"Insert Into MyTable (Unique_Id) Values (:Unique_Id)'.

The Delphi code is:
var
Guid: TGuid;
OraSql: TOraSql;
begin
OraSql := TOraSql.Create(nil);
OraSql.Session := MySession;
OraSql.SQL.Text := 'Insert Into MyTable Unique_Id) Values (:Unique_Id)';
OraSql.ParamByName('Unique_Id').DataType := ftGuid; // or ftVarBytes
OraSql.ParamByName('Unique_Id').AsGuid := TGuid.NewGuid();
OraSql.Execute(); // ==> raise exception
end;

Exception call stack:
OraClasses.TOraParamDesc.AllocBuffer
OraClasses.TOraParamDesc.SetItemNull(0,True)
OraClasses.TOraParamDesc.SetItemValue(0,Unassigned)
OraClasses.InternalSetValue(0,Unassigned)
OraClasses.TOraParamDesc.SetValue(Unassigned)
DBAccess.TCustomDASQL.AssignParamValue($EF58998,$EF59080)
Ora.TOraSQL.AssignParamValue($EF58998,$EF59080)
DBAccess.TCustomDASQL.WriteParams(True)
DBAccess.TCustomDASQL.Execute(1,0)
DBAccess.TCustomDASQL.Execute

Comment:
OraQuery with Insert and Post works, for example
OraQuery.Insert;
OraQuery_Unique_Id.AsGuid := TGuid.NewGuid();
OraQuery.Post;
will works.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: TOraSQL raise 'Unknown data type' exception

Post by MaximG » Fri 29 Mar 2019 15:24

To solve the issue you described, you can apply the following code:

Code: Select all

   ...
   OraSQL.Session := MySession;
   OraSQL.SQL.Text := 'Insert Into MyTable (Unique_Id) Values (:Unique_Id)';
   OraSQL.ParamByName('Unique_Id').DataType := ftVarBytes;
   OraSQL.ParamByName('Unique_Id').Value := TGuid.NewGuid().ToByteArray;
   OraSql.Execute();
   ...

erezharari55
Posts: 2
Joined: Sun 24 Mar 2019 13:56

Re: TOraSQL raise 'Unknown data type' exception

Post by erezharari55 » Mon 01 Apr 2019 11:18

Thanks for your response.
Please consider adding GUID support to TOraSql, this make users code more intuitive.
For Example:
OraSql.ParamByName('Unique_Id').DataType := ftGuid;
OraSql.ParamByName('Unique_Id').AsGuid := TGuid.NewGuid();

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: TOraSQL raise 'Unknown data type' exception

Post by MaximG » Tue 02 Apr 2019 05:12

We will investigate a possibility of its implementation in one of the next versions.

Post Reply