Subject Error when trying to "SELECT" "ORDERED BY" not indexed column ?
Author Plamen Krastev
Hi,

When I try to do SELECT like this:

SELECT *
FROM ITEM
ORDER BY ITMFULLNAME;

it is successful, but when I try to do this:

SELECT *
FROM ITEM
ORDER BY ITMLEAFNAME;

I receive error message:

ISC ERROR CODE:335544344

ISC ERROR MESSAGE:
I/O error for file "C:\WINDOWS\system32\WINDOWS\TEMP\fb_sort_x2l31t"
Error while trying to open file
The system cannot find the file specified.

STATEMENT:
TIBOInternalDataset: "<TApplication>.frmMain.d

Here is the table definition:

/* Table: ITEM, Owner: SYSDBA */

CREATE TABLE "ITEM"
(
"IDITEM" INTEGER NOT NULL,
"ITMPARENT" INTEGER,
"ITMLEAFNAME" VARCHAR(60),
"ITMFULLNAME" VARCHAR(120),
"ITMTYPE" VARCHAR(10),
"ITMISGROUP" CHAR(1),
"ITMMEASURE" VARCHAR(15),
"IDACCITEM" INTEGER,
CONSTRAINT "ITEM_PRIMARY" PRIMARY KEY ("IDITEM")
);

/* Index definitions for ITEM */

CREATE INDEX "IDACCITEM" ON "ITEM"("IDACCITEM");
CREATE INDEX "IDX_ITEM_1" ON "ITEM"("ITMFULLNAME");
CREATE UNIQUE INDEX "ITMLEAFLEVELIDX"
ON "ITEM"("ITMPARENT", "ITMLEAFNAME");
CREATE INDEX "ITMPARENT" ON "ITEM"("ITMPARENT");
ALTER TABLE "ITEM" ADD CONSTRAINT "RIHIERARCHY" FOREIGN KEY
("ITMPARENT")
REFERENCES "ITEM" ("IDITEM");

The obvious thing is that in first case SELECT is ORDERED BY indexed
column,
while in second case there is no such index.

Is that the reason for the error, and is there any workaround
different than
indexing on columns I want to use in ORDER BY clause ?

Additional information:

I made the test with IBOConsole, operating system Windows XP Home
Edition
SP2, Firebird 2.0 RC3, table contains 934 records.

Thanx in advance for any ideas.