Note: The problem does not occur with all nested tables. I have only observed it when the nested table column is a table of VARCHAR2 fields.
Using this table...
Code: Select all
create or replace type varchar32_table as table of varchar2(32 char);
drop table odac_nestedtable2 purge;
create table ODAC_NESTEDTABLE2
( code integer generated always as identity,
CONTENT varchar32_table)
nested table content
store as CONTENT_nt;
insert into ODAC_NESTEDTABLE2(CONTENT)
values (varchar32_table('123456', 'abcdef'));
commit;
1) if OraCall.OCIUnicode is false, and Session.UnicodeEnvironment = false, and Session.UseUnicode=False, then I get access violations as soon as I try to set the TOraNestedTable.DataSetField property.
2) If the above-named properties are all TRUE, there is no access violation, but the first character of each row in the nested table is missing. So instead of seeing "123456", and "abcdef", I see "23456" and "bcdef"
I am using Delphi version 10.1, compiled in 32 bit, using Oracle 19c database and 12.1.0.2 client (but I believe it happens with other client/server versions)
Demo app below. Just create the table above, then run the app and click either of the buttons.
Unit2.pas
Code: Select all
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Vcl.Grids, Vcl.DBGrids, OraCall, DBAccess, Ora, OraSmart, MemDS,
Vcl.ExtCtrls, Vcl.StdCtrls;
type
TForm2 = class(TForm)
NestedTable: TOraNestedTable;
SmartQuery: TSmartQuery;
dsMaster: TDataSource;
Session: TOraSession;
DBGrid1: TDBGrid;
Splitter1: TSplitter;
DataSource1: TDataSource;
DBGrid2: TDBGrid;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
// restart the app to try the other button
Button1.Enabled := False;
Button2.Enabled := False;
OraCall.OCIUnicode := True;
Session.Options.UnicodeEnvironment := True;
Session.Options.UseUnicode := True;
session.username := 'JDORLON';
session.password := 'jdorlon';
session.server := 'AZURE_19c_PLUG';
session.Connected := True;
SmartQuery.sql.add('select * from ODAC_NESTEDTABLE2');
SmartQuery.Open;
NestedTable.DataSetField := TDataSetField(SmartQuery.FieldByName('CONTENT'));
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
// restart the app to try the other button
Button1.Enabled := False;
Button2.Enabled := False;
OraCall.OCIUnicode := False;
Session.Options.UnicodeEnvironment := False;
Session.Options.UseUnicode := False;
session.username := 'JDORLON';
session.password := 'jdorlon';
session.server := 'AZURE_19c_PLUG';
session.Connected := True;
SmartQuery.sql.add('select * from ODAC_NESTEDTABLE2');
SmartQuery.Open;
NestedTable.DataSetField := TDataSetField(SmartQuery.FieldByName('CONTENT'));
end;
end.
Code: Select all
object Form2: TForm2
Left = 0
Top = 0
Caption = 'Form2'
ClientHeight = 435
ClientWidth = 577
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Splitter1: TSplitter
Left = 0
Top = 205
Width = 577
Height = 6
Cursor = crVSplit
Align = alTop
ExplicitTop = 120
end
object DBGrid1: TDBGrid
Left = 0
Top = 41
Width = 577
Height = 164
Align = alTop
DataSource = dsMaster
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
end
object DBGrid2: TDBGrid
Left = 0
Top = 211
Width = 577
Height = 224
Align = alClient
DataSource = DataSource1
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
end
object Panel1: TPanel
Left = 0
Top = 0
Width = 577
Height = 41
Align = alTop
TabOrder = 2
object Button1: TButton
Left = 0
Top = 10
Width = 265
Height = 25
Caption = 'Unicode - wrong data'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 289
Top = 10
Width = 272
Height = 25
Caption = 'No Unicode - access violation'
TabOrder = 1
OnClick = Button2Click
end
end
object NestedTable: TOraNestedTable
Left = 163
Top = 53
end
object SmartQuery: TSmartQuery
Session = Session
ObjectView = True
Left = 118
Top = 55
end
object dsMaster: TDataSource
DataSet = SmartQuery
Left = 128
Top = 105
end
object Session: TOraSession
Options.UseUnicode = True
Options.UnicodeEnvironment = True
LoginPrompt = False
Left = 61
Top = 47
end
object DataSource1: TDataSource
DataSet = NestedTable
Left = 188
Top = 105
end
end
Code: Select all
program Project2;
uses
Vcl.Forms,
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
Thanks,
John Dorlon