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.
TOraSQL raise 'Unknown data type' exception
Re: TOraSQL raise 'Unknown data type' exception
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();
...
-
- Posts: 2
- Joined: Sun 24 Mar 2019 13:56
Re: TOraSQL raise 'Unknown data type' exception
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();
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
We will investigate a possibility of its implementation in one of the next versions.