Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: No File is Being Created when Using TIBOutputRawFile in Delphi XE6


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 7 - Last Post: Jun 30, 2014 7:51 AM Last Post By: Mike Norayr Mon...
Mike Norayr Mon...

Posts: 49
Registered: 11/18/99
No File is Being Created when Using TIBOutputRawFile in Delphi XE6  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 25, 2014 7:52 AM
I have the following procedure:

procedure TForm1.Button1Click(Sender: TObject);
var
RawOutput: TIBOutputRawFile;
FileName: string;
begin
RawOutput:= TIBOutputRawFile.Create;
try
with IBSQL1 do begin
close;
sql.text:= 'select * from employee';
RawOutput.FileName := 'TRANS.ibx';
BatchOutput(RawOutput);
end;
finally
RawOutput.Free
end;
end;

In Delphi XE6, even though this procedure is run without any exceptions, no file is being created. It created the file just fine with Delphi XE5 and before.

Has anything changed? Am I missing something?
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: No File is Being Created when Using TIBOutputRawFile in Delphi XE6  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 25, 2014 9:35 AM   in response to: Mike Norayr Mon... in response to: Mike Norayr Mon...
Mike Norayr Monjian wrote:
I have the following procedure:

procedure TForm1.Button1Click(Sender: TObject);
var
RawOutput: TIBOutputRawFile;
FileName: string;
begin
RawOutput:= TIBOutputRawFile.Create;
try
with IBSQL1 do begin
close;
sql.text:= 'select * from employee';
RawOutput.FileName := 'TRANS.ibx';
BatchOutput(RawOutput);
end;
finally
RawOutput.Free
end;
end;

In Delphi XE6, even though this procedure is run without any exceptions, no file is being created. It created the file just fine with Delphi XE5 and before.

Has anything changed? Am I missing something?

There was a lot of rework on the delimited file side of things, I do not recall
working on the raw side, but they have a common ancestor and I might have broken
something there. I will look at it later today time permitting.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: No File is Being Created when Using TIBOutputRawFile in Delphi XE6  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 25, 2014 12:34 PM   in response to: Mike Norayr Mon... in response to: Mike Norayr Mon...
Mike Norayr Monjian wrote:
I have the following procedure:

procedure TForm1.Button1Click(Sender: TObject);
var
RawOutput: TIBOutputRawFile;
FileName: string;
begin
RawOutput:= TIBOutputRawFile.Create;
try
with IBSQL1 do begin
close;
sql.text:= 'select * from employee';
RawOutput.FileName := 'TRANS.ibx';
BatchOutput(RawOutput);
end;
finally
RawOutput.Free
end;
end;

In Delphi XE6, even though this procedure is run without any exceptions, no file is being created. It created the file just fine with Delphi XE5 and before.

Has anything changed? Am I missing something?

Yes in finally fixing outputting Unicode character in the delimited file version
I messed up RAW file slightly.

In both TIBOutputRawFile and TIBInputRawFile add a public procedure

     procedure ReadyFile; override;


Then the two new procedures look like

procedure TIBOutputRawFile.ReadyFile;
begin
   inherited;
   FFile := TFileStream.Create(FFilename, fmCreate or fmShareDenyWrite);
end;
 
...
 
procedure TIBInputRawFile.ReadyFile;
begin
   inherited;
   FFile := TFileStream.Create(FFilename, fmOpenRead or fmShareDenyWrite);
end;
 


This will have to be delayed till XE7 to actually get into an official update
since it requires breaking the interface.

Sorry about that, the Unicode part needed a pretty big rewrite on the Delimited
side of the inheritance tree.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
quinn wildman

Posts: 856
Registered: 12/2/99
Re: No File is Being Created when Using TIBOutputRawFile in Delphi XE6  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 25, 2014 2:22 PM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff Overcash (TeamB) wrote:
Yes in finally fixing outputting Unicode character in the delimited file version
I messed up RAW file slightly. …

Can you write this up for Quality Central?
Mike Norayr Mon...

Posts: 49
Registered: 11/18/99
Re: No File is Being Created when Using TIBOutputRawFile in Delphi XE6  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 27, 2014 1:12 AM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff Overcash (TeamB) wrote:
Mike Norayr Monjian wrote:
I have the following procedure:

procedure TForm1.Button1Click(Sender: TObject);
var
RawOutput: TIBOutputRawFile;
FileName: string;
begin
RawOutput:= TIBOutputRawFile.Create;
try
with IBSQL1 do begin
close;
sql.text:= 'select * from employee';
RawOutput.FileName := 'TRANS.ibx';
BatchOutput(RawOutput);
end;
finally
RawOutput.Free
end;
end;

In Delphi XE6, even though this procedure is run without any exceptions, no file is being created. It created the file just fine with Delphi XE5 and before.

Has anything changed? Am I missing something?

Yes in finally fixing outputting Unicode character in the delimited file version
I messed up RAW file slightly.

In both TIBOutputRawFile and TIBInputRawFile add a public procedure

     procedure ReadyFile; override;


Then the two new procedures look like

procedure TIBOutputRawFile.ReadyFile;
begin
   inherited;
   FFile := TFileStream.Create(FFilename, fmCreate or fmShareDenyWrite);
end;
 
...
 
procedure TIBInputRawFile.ReadyFile;
begin
   inherited;
   FFile := TFileStream.Create(FFilename, fmOpenRead or fmShareDenyWrite);
end;
 


This will have to be delayed till XE7 to actually get into an official update
since it requires breaking the interface.

Sorry about that, the Unicode part needed a pretty big rewrite on the Delimited
side of the inheritance tree.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)

Thanx, Jeff.

I did the changes. The raw file export & import works fine. As for the delimited file, the export works fine (at least looks fine) but the import results in an "EConvertError with message 'X' is not a valid date and time" exception. FYI, my date format in the regional settings is 'dd/mm/yyyy' and the date fields in the export file look fine. I don't know if the import is trying to read them in Interbase format, i.e. 'mm/dd/yyyy'.

BTW, do I add "$(BDS)\Source\IBX" to the library path or just copy the new IBX.IBSQL.dcu file created to the "$(BDSLIB)\$(Platform)\release" folder?
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: No File is Being Created when Using TIBOutputRawFile in Delphi XE6  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 27, 2014 9:52 AM   in response to: Mike Norayr Mon... in response to: Mike Norayr Mon...
Mike Norayr Monjian wrote:
Jeff Overcash (TeamB) wrote:
Mike Norayr Monjian wrote:
I have the following procedure:

procedure TForm1.Button1Click(Sender: TObject);
var
RawOutput: TIBOutputRawFile;
FileName: string;
begin
RawOutput:= TIBOutputRawFile.Create;
try
with IBSQL1 do begin
close;
sql.text:= 'select * from employee';
RawOutput.FileName := 'TRANS.ibx';
BatchOutput(RawOutput);
end;
finally
RawOutput.Free
end;
end;

In Delphi XE6, even though this procedure is run without any exceptions, no file is being created. It created the file just fine with Delphi XE5 and before.

Has anything changed? Am I missing something?
Yes in finally fixing outputting Unicode character in the delimited file version
I messed up RAW file slightly.

In both TIBOutputRawFile and TIBInputRawFile add a public procedure

     procedure ReadyFile; override;


Then the two new procedures look like

procedure TIBOutputRawFile.ReadyFile;
begin
   inherited;
   FFile := TFileStream.Create(FFilename, fmCreate or fmShareDenyWrite);
end;
 
...
 
procedure TIBInputRawFile.ReadyFile;
begin
   inherited;
   FFile := TFileStream.Create(FFilename, fmOpenRead or fmShareDenyWrite);
end;
 


This will have to be delayed till XE7 to actually get into an official update
since it requires breaking the interface.

Sorry about that, the Unicode part needed a pretty big rewrite on the Delimited
side of the inheritance tree.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)

Thanx, Jeff.

I did the changes. The raw file export & import works fine. As for the delimited file, the export works fine (at least looks fine) but the import results in an "EConvertError with message 'X' is not a valid date and time" exception. FYI, my date format in the regional settings is 'dd/mm/yyyy' and the date fields in the export file look fine. I don't know if the import is trying to read them in Interbase format, i.e. 'mm/dd/yyyy'.

I will look at that, but I made no changes around dates so it might be IB date
format. The changes were to support Unicode data in the delimited exports.
Doesn't mean I didn't break something else I didn't have a test for though.

BTW, do I add "$(BDS)\Source\IBX" to the library path or just copy the new IBX.IBSQL.dcu file created to the "$(BDSLIB)\$(Platform)\release" folder?

Normally I do not recommend adding the srouce to your library path, but in this
case doing that might be best. Breaking hte interface is going to require
recompiling anything using that unit, which pretty much everything uses IBSQL.pas.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: No File is Being Created when Using TIBOutputRawFile in Delphi XE6  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 27, 2014 11:57 AM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff Overcash (TeamB) wrote:
Mike Norayr Monjian wrote:
Jeff Overcash (TeamB) wrote:
Mike Norayr Monjian wrote:
I have the following procedure:

procedure TForm1.Button1Click(Sender: TObject);
var
RawOutput: TIBOutputRawFile;
FileName: string;
begin
RawOutput:= TIBOutputRawFile.Create;
try
with IBSQL1 do begin
close;
sql.text:= 'select * from employee';
RawOutput.FileName := 'TRANS.ibx';
BatchOutput(RawOutput);
end;
finally
RawOutput.Free
end;
end;

In Delphi XE6, even though this procedure is run without any exceptions, no file is being created. It created the file just fine with Delphi XE5 and before.

Has anything changed? Am I missing something?
Yes in finally fixing outputting Unicode character in the delimited file version
I messed up RAW file slightly.

In both TIBOutputRawFile and TIBInputRawFile add a public procedure

     procedure ReadyFile; override;


Then the two new procedures look like

procedure TIBOutputRawFile.ReadyFile;
begin
   inherited;
   FFile := TFileStream.Create(FFilename, fmCreate or fmShareDenyWrite);
end;
 
...
 
procedure TIBInputRawFile.ReadyFile;
begin
   inherited;
   FFile := TFileStream.Create(FFilename, fmOpenRead or fmShareDenyWrite);
end;
 


This will have to be delayed till XE7 to actually get into an official update
since it requires breaking the interface.

Sorry about that, the Unicode part needed a pretty big rewrite on the Delimited
side of the inheritance tree.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Thanx, Jeff.

I did the changes. The raw file export & import works fine. As for the delimited file, the export works fine (at least looks fine) but the import results in an "EConvertError with message 'X' is not a valid date and time" exception. FYI, my date format in the regional settings is 'dd/mm/yyyy' and the date fields in the export file look fine. I don't know if the import is trying to read them in Interbase format, i.e. 'mm/dd/yyyy'.

I will look at that, but I made no changes around dates so it might be IB date
format. The changes were to support Unicode data in the delimited exports.
Doesn't mean I didn't break something else I didn't have a test for though.

BTW, do I add "$(BDS)\Source\IBX" to the library path or just copy the new IBX.IBSQL.dcu file created to the "$(BDSLIB)\$(Platform)\release" folder?

Normally I do not recommend adding the srouce to your library path, but in this
case doing that might be best. Breaking hte interface is going to require
recompiling anything using that unit, which pretty much everything uses IBSQL.pas.

I'm not able to reproduce this. Are you sure that somehow your FormatSettings
are not being changed between writing and inputing hte file? That would do it.

Here is the test

procedure TdmIBSQL.InputDelimitedFileWithDates;
var
   FilePath : String;
   S : Array[0..1] of TDateTime;
   I: Integer;
begin
   FormatSettings.ShortDateFormat := 'dd/mm/yyyy';
   CreateTestDatabase('sysdba', 'masterkey', 'NONE', 3, 4096);
   FilePath := PATH_TO_GDB + 'data.txt';
   try
     ConnectToDatabase(3);
     ActivateTransaction;
     CreateTestTable( TestTableName, 'timestamp' );
     //Setup
     S[0] := StrToDateTime('15/1/2014 12:30');
     S[1] := StrToDateTime('26/8/1965 9:45');
     CreateOutputFile(S);
 
     // Test inputing the file
     ProcessInputFile;
 
     IBDataset1.Transaction := IBTransaction1;
     IBDataset1.Database := IBDatabase1;
     IBDataset1.SelectSQL.Text := 'Select ID, DATUM from ' + TestTableName + ' 
order by ID';
     IBDataset1.Active := True;
 
     for I := Low(S) to High(S) do
     begin
       Comparer.IntegerCompare(I, IBDataset1.Fields[0].AsInteger, 'Wrong Column 
Expected : ' +
           i.ToString + ' Received : ' + IBDataset1.Fields[0].AsString);
       Comparer.StringCompare(DateTimeToStr(S[i]), 
IBDataset1.Fields[1].AsString, 'Expected : ' +
             DateTimeToStr(S[i]) + ' Received : ' + IBDataset1.Fields[1].AsString);
       IBDataset1.Next;
     end;
   finally
     if FileExists(FilePath) then
       DeleteFile(FilePath);
     DropTestDatabase;
     FormatSettings.ShortDateFormat := 'mm/dd/yyyy';
   end;
end;


Basically I
1. Change the global FormatSettgins to dd/mm/yyyy (mine is normally mm/dd/yyyy)
2. Do basic setup of a DB and a table with 2 columns, an ID of integer, a datum
of timestamp
3. Output the file after inserting the data, once the file is generated I
rollback to the table is empty again. The file looks like

0 15/01/2014 12:30:00 PM
1 26/08/1965 9:45:00 AM

4. Process that input file back into the database.
5. Read the table and compare the values with what is expected.
6. cleanup afterwards

It passes just fine.

Try putting a break point on line 19760 in System.sysUtils and check the value
of the FormatSettings.ShrotDateformat. The only thing I can think of is somehow
that is now not 'dd/mm'yyyy'. IBX never changes this so I'd look at your code
for where it might change it temporarily to something else then not back to what
you need for the file.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Mike Norayr Mon...

Posts: 49
Registered: 11/18/99
Re: No File is Being Created when Using TIBOutputRawFile in Delphi XE6  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2014 7:51 AM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff Overcash (TeamB) wrote:
Jeff Overcash (TeamB) wrote:
Mike Norayr Monjian wrote:
Jeff Overcash (TeamB) wrote:
Mike Norayr Monjian wrote:
I have the following procedure:

procedure TForm1.Button1Click(Sender: TObject);
var
RawOutput: TIBOutputRawFile;
FileName: string;
begin
RawOutput:= TIBOutputRawFile.Create;
try
with IBSQL1 do begin
close;
sql.text:= 'select * from employee';
RawOutput.FileName := 'TRANS.ibx';
BatchOutput(RawOutput);
end;
finally
RawOutput.Free
end;
end;

In Delphi XE6, even though this procedure is run without any exceptions, no file is being created. It created the file just fine with Delphi XE5 and before.

Has anything changed? Am I missing something?
Yes in finally fixing outputting Unicode character in the delimited file version
I messed up RAW file slightly.

In both TIBOutputRawFile and TIBInputRawFile add a public procedure

     procedure ReadyFile; override;


Then the two new procedures look like

procedure TIBOutputRawFile.ReadyFile;
begin
   inherited;
   FFile := TFileStream.Create(FFilename, fmCreate or fmShareDenyWrite);
end;
 
...
 
procedure TIBInputRawFile.ReadyFile;
begin
   inherited;
   FFile := TFileStream.Create(FFilename, fmOpenRead or fmShareDenyWrite);
end;
 


This will have to be delayed till XE7 to actually get into an official update
since it requires breaking the interface.

Sorry about that, the Unicode part needed a pretty big rewrite on the Delimited
side of the inheritance tree.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Thanx, Jeff.

I did the changes. The raw file export & import works fine. As for the delimited file, the export works fine (at least looks fine) but the import results in an "EConvertError with message 'X' is not a valid date and time" exception. FYI, my date format in the regional settings is 'dd/mm/yyyy' and the date fields in the export file look fine. I don't know if the import is trying to read them in Interbase format, i.e. 'mm/dd/yyyy'.

I will look at that, but I made no changes around dates so it might be IB date
format. The changes were to support Unicode data in the delimited exports.
Doesn't mean I didn't break something else I didn't have a test for though.

BTW, do I add "$(BDS)\Source\IBX" to the library path or just copy the new IBX.IBSQL.dcu file created to the "$(BDSLIB)\$(Platform)\release" folder?

Normally I do not recommend adding the srouce to your library path, but in this
case doing that might be best. Breaking hte interface is going to require
recompiling anything using that unit, which pretty much everything uses IBSQL.pas.

I'm not able to reproduce this. Are you sure that somehow your FormatSettings
are not being changed between writing and inputing hte file? That would do it.

Here is the test

procedure TdmIBSQL.InputDelimitedFileWithDates;
var
   FilePath : String;
   S : Array[0..1] of TDateTime;
   I: Integer;
begin
   FormatSettings.ShortDateFormat := 'dd/mm/yyyy';
   CreateTestDatabase('sysdba', 'masterkey', 'NONE', 3, 4096);
   FilePath := PATH_TO_GDB + 'data.txt';
   try
     ConnectToDatabase(3);
     ActivateTransaction;
     CreateTestTable( TestTableName, 'timestamp' );
     //Setup
     S[0] := StrToDateTime('15/1/2014 12:30');
     S[1] := StrToDateTime('26/8/1965 9:45');
     CreateOutputFile(S);
 
     // Test inputing the file
     ProcessInputFile;
 
     IBDataset1.Transaction := IBTransaction1;
     IBDataset1.Database := IBDatabase1;
     IBDataset1.SelectSQL.Text := 'Select ID, DATUM from ' + TestTableName + ' 
order by ID';
     IBDataset1.Active := True;
 
     for I := Low(S) to High(S) do
     begin
       Comparer.IntegerCompare(I, IBDataset1.Fields[0].AsInteger, 'Wrong Column 
Expected : ' +
           i.ToString + ' Received : ' + IBDataset1.Fields[0].AsString);
       Comparer.StringCompare(DateTimeToStr(S[i]), 
IBDataset1.Fields[1].AsString, 'Expected : ' +
             DateTimeToStr(S[i]) + ' Received : ' + IBDataset1.Fields[1].AsString);
       IBDataset1.Next;
     end;
   finally
     if FileExists(FilePath) then
       DeleteFile(FilePath);
     DropTestDatabase;
     FormatSettings.ShortDateFormat := 'mm/dd/yyyy';
   end;
end;


Basically I
1. Change the global FormatSettgins to dd/mm/yyyy (mine is normally mm/dd/yyyy)
2. Do basic setup of a DB and a table with 2 columns, an ID of integer, a datum
of timestamp
3. Output the file after inserting the data, once the file is generated I
rollback to the table is empty again. The file looks like

0 15/01/2014 12:30:00 PM
1 26/08/1965 9:45:00 AM

4. Process that input file back into the database.
5. Read the table and compare the values with what is expected.
6. cleanup afterwards

It passes just fine.

Try putting a break point on line 19760 in System.sysUtils and check the value
of the FormatSettings.ShrotDateformat. The only thing I can think of is somehow
that is now not 'dd/mm'yyyy'. IBX never changes this so I'd look at your code
for where it might change it temporarily to something else then not back to what
you need for the file.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)

Hi Jeff. I checked. The value of ShortDateFormat is 'dd/mm/yyyy' and is never changed in the code. If the case was the ShortDateFormat changing, the TIBInputRawFile wouldn't work either, right? BTW, the exception is in the ReadParameters function in the IBX.IBSQL on the "Inc(curcol)" line:

function TIBInputDelimitedFile.ReadParameters: Boolean;
var
i, curcol: Integer;
Col: String;
begin
result := False;
if FCurrentData = '' then
FCurrentData := ReadLine;
if not FEOF then
begin
curcol := 0;
repeat
i := GetColumn(Col);
if (i = 0) then
FEOF := True;
if (curcol < Params.Count) then
begin
try
if (Length(Col) = 0) and
(ReadBlanksAsNull) then
Params[curcol].IsNull := True
else
Params[curcol].AsString := col;
Inc(curcol); //<<<<<<<<<<<<<<<<<<<<<<<<<< Here is the exception
except
on E: Exception do
begin
if not (FEOF and (curcol = Params.Count)) then
raise;
end;
end;
end;
until (FEOF) or (i = 2);
result := ((FEOF) and (curcol = Params.Count)) or
(not FEOF);
end;
end;
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02