Page 1 of 1

TOraSQL raise 'Unknown data type' exception

Posted: Mon 25 Mar 2019 08:21
by erezharari55
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.

Re: TOraSQL raise 'Unknown data type' exception

Posted: Fri 29 Mar 2019 15:24
by MaximG
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();
   ...

Re: TOraSQL raise 'Unknown data type' exception

Posted: Mon 01 Apr 2019 11:18
by erezharari55
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();

Re: TOraSQL raise 'Unknown data type' exception

Posted: Tue 02 Apr 2019 05:12
by MaximG
We will investigate a possibility of its implementation in one of the next versions.