Subject Re: [firebird-support] Cannot order By
Author Yosi
> I notice that your view includes double quotes, which makes things case
> sensitive. If your table was created using double quotes, you have to use
> double quotes and the same case when referencing it. If that is not the
> reason, then show us the entire select you are using along with the table
> definition and tell us which tool you are using.

Actually I don not use any double quotes when i create the view,
I am using IB console 6.0 and server FB 1.0.
After the table / view created, the console automatically added the quotes
sign
like i have copied the metadata yesterday.

Below are metadatas of my table & view,
It is written in non english language. I am sorry, Maybe it is a little
difficult to understand.

And if there is really no way out, I have considered to redesign my table,
event if it will take more time.
I know my table is not perfect, so be gentle :)

As a little reference from me:

RIN = Raw Item Number
QTY = Quantity
Pakai = Used
TglTerima / TglRawDatang = Received Date
UOM = Unit Of Measurement
Price = Price :)
Ket = Remark
KodeGdg = Warehouse Code
NamaGdg = Warehouse Name
NamaBrg = Material Name
NoRR = Receiving Report Number
NoPO = Purchasing Order Number
OrgName = Organisation name / Suopplier Name
RawStatus = Raw Status, wheter it is Good, Bad or Distress
KodeSupl = Suplier Code
MIDOut = is a unique ID for references as foreign key by another table


------------------
CREATE VIEW QSALDORAW AS
select A.Rin, A.Qty as Masuk, B.Pakai as Pakai, (A.Qty - B.Pakai) as Saldo,
A.TglTerima, A.UOM, A.Price, A.Ket, A.KodeGdg, A.namaGdg, A.NamaBrg
from qRawIn A left outer join qAkumPakaiRaw B
on A.Ket = B.Ket and A.Rin = B.RIn and A.KEt = B.ket and A.tglTerima =
B.tglMasuk and A.KodeGdg = B.KodeGdg
------------------

this view reference into another 2 view like below

--------------------
CREATE VIEW QRAWIN AS
select E.NoRR, E.tglTerima, E.NoPo, E.NoDo, A.RIN, B.NamaBrg, A.Qty, A.UOM,
C.Ket, D.KodeGdg, D.NamaGdg, F.OrgName, A.Price
from dtRawIn A, MasterRaw B, StatusRaw C, gudang D, bktRawIn E, organization
F
where A.rin = B.RIN and E.NoRR = A.NoRR and A.RawStatus = C.RawStatus and
A.KodeGdg = D.Kodegdg and E.KodeSupl = F.OrgCode
------------------------

And this view

---------------------------------
CREATE VIEW QAKUMPAKAIRAW AS
select A.Rin, Sum(A.Qty), A.UOM, A.CurrentPrice, A.TglRawDatang, A.Bulan,
A.Tahun, C.RawStatus, C.Ket, A.KodeGdg
from PakaiRaw A, MasterRaw B, StatusRaw C
where A.Rin = B.Rin and A.RawStatus = C.RawStatus
group By A.CurrentPrice, A.TglRawdatang, A.Bulan, A.Tahun, A.Rin, A.Uom,
C.RawStatus, C.Ket, A.KodeGdg
----------------------------------

Those 2 view reference into these tables :

Table dtrawin = Save Detail Of Raw incoming Material
------------------------
CREATE TABLE "DTRAWIN"
(
"RIN" VARCHAR(20) NOT NULL,
"QTY" DOUBLE PRECISION NOT NULL,
"UOM" VARCHAR(15) NOT NULL,
"BULAN" SMALLINT NOT NULL,
"TAHUN" SMALLINT NOT NULL,
"KODEGDG" VARCHAR(15) NOT NULL,
"NORR" VARCHAR(15) NOT NULL,
"RAWSTATUS" SMALLINT NOT NULL,
"MIDOUT" NUMERIC(15, 0) NOT NULL,
"PRICE" NUMERIC(15, 2) NOT NULL,
"TGLTERIMA" DATE,
PRIMARY KEY ("NORR", "RIN", "RAWSTATUS"),
UNIQUE ("MIDOUT")
);
ALTER TABLE "DTRAWIN" ADD CONSTRAINT "FK_DTRAWIN_MASTERRAW" FOREIGN KEY
("RIN") REFERENCES MASTERRAW ("RIN") ON UPDATE CASCADE;
ALTER TABLE "DTRAWIN" ADD CONSTRAINT "FK_DTRAWIN_STATUSRAW" FOREIGN KEY
("RAWSTATUS") REFERENCES STATUSRAW ("RAWSTATUS") ON UPDATE CASCADE;
ALTER TABLE "DTRAWIN" ADD CONSTRAINT "FK_RAWIN_GUDANG" FOREIGN KEY
("KODEGDG") REFERENCES GUDANG ("KODEGDG") ON UPDATE CASCADE;

Table MasterRaw = Material Spec and it's property
---------------------------------
CREATE TABLE "MASTERRAW"
(
"RIN" VARCHAR(20) NOT NULL,
"UOM1" VARCHAR(20) NOT NULL,
"UOM2" VARCHAR(20),
"KONVERSIUOM" FLOAT,
"LEBAR" FLOAT,
"PANJANG" FLOAT,
"TINGGI" FLOAT,
"LOWERPRICE" NUMERIC(10, 2),
"AVERAGEPRICE" NUMERIC(10, 2),
"STANDARDCOST" NUMERIC(15, 2),
"ACTUALCOST" NUMERIC(15, 2),
"LEADTIME" INTEGER,
"KET" VARCHAR(40),
"NAMABRG" VARCHAR(200),
PRIMARY KEY ("RIN")
);

Table StatusRaw = Material Status (Good, Distress, Bed, etc)
-----------------------------
CREATE TABLE "STATUSRAW"
(
"KET" VARCHAR(20),
"RAWSTATUS" SMALLINT NOT NULL,
PRIMARY KEY ("RAWSTATUS")
);

Table BktRawIn = Incoming Material Dokument / Letter
----------------------------
CREATE TABLE "BKTRAWIN"
(
"NORR" VARCHAR(20) NOT NULL,
"KODESUPL" VARCHAR(20),
"TGLTERIMA" DATE NOT NULL,
"PICSUPL" VARCHAR(20),
"PICTS" VARCHAR(20),
"NOPO" VARCHAR(15),
"NODO" VARCHAR(20),
PRIMARY KEY ("NORR")
);

Table organization = Supplier / Konsumen Name
------------------------------
CREATE TABLE "ORGANIZATION"
(
"ORGANIZATION_ID" INTEGER NOT NULL,
"ORGCODE" VARCHAR(5),
"ORGNAME" VARCHAR(30),
"ADDRESS" VARCHAR(100),
"PHONE" VARCHAR(20),
"FAX" VARCHAR(20),
"CITY" VARCHAR(30),
"CONTACT" VARCHAR(30),
"DESCRIPTION" VARCHAR(100),
"ZIPCODE" VARCHAR(10),
"COUNTRY" VARCHAR(30),
"PKP" VARCHAR(20),
"PKPDATE" TIMESTAMP,
"NPWP" VARCHAR(20),
"CHANGE_DATE" TIMESTAMP,
"TAXKIND" INTEGER,
"TAX" DOUBLE PRECISION,
"CREDITDAYS" INTEGER,
"ORGANIZATION_KIND" VARCHAR(1),
PRIMARY KEY ("ORGANIZATION_ID")
);

Table gudang = Warehouse
-----------------------------
CREATE TABLE "GUDANG"
(
"KODEGDG" VARCHAR(15) NOT NULL,
"NAMAGDG" VARCHAR(30) NOT NULL,
"KET" VARCHAR(50),
"JMLSLOT" INTEGER,
"JMLZONE" INTEGER,
"JENISGDG" SMALLINT NOT NULL,
"LOKASI" VARCHAR(45),
"SIFAT" SMALLINT NOT NULL,
PRIMARY KEY ("KODEGDG")
);
ALTER TABLE "GUDANG" ADD CONSTRAINT "FK_GUDANG_JENISGDG" FOREIGN KEY
("JENISGDG") REFERENCES JENISGUDANG ("NOGDG") ON UPDATE CASCADE;
ALTER TABLE "GUDANG" ADD CONSTRAINT "FK_GUDANG_SIFATGUDANG" FOREIGN KEY
("SIFAT") REFERENCES SIFATGUDANG ("NOGDG") ON UPDATE CASCADE;

Table PAKAIRAW = Material Used
------------------------------
CREATE TABLE "PAKAIRAW"
(
"TGLPAKAI" DATE NOT NULL,
"KODEGDG" VARCHAR(15) NOT NULL,
"RIN" VARCHAR(20) NOT NULL,
"QTY" FLOAT NOT NULL,
"UOM" VARCHAR(15) NOT NULL,
"NOJO" VARCHAR(15),
"CURRENTPRICE" NUMERIC(15, 2),
"PEMAKAI" VARCHAR(15) NOT NULL,
"RAWSTATUS" SMALLINT NOT NULL,
"BULAN" SMALLINT,
"TAHUN" SMALLINT,
"IDPAKAI" NUMERIC(15, 0) NOT NULL,
"TGLRAWDATANG" DATE,
UNIQUE ("IDPAKAI")
);
ALTER TABLE "PAKAIRAW" ADD CONSTRAINT "FK_PAKAIRAW_MASTERRAW" FOREIGN KEY
("RIN") REFERENCES MASTERRAW ("RIN") ON UPDATE CASCADE;
ALTER TABLE "PAKAIRAW" ADD CONSTRAINT "FK_PAKAIRAW_STATUSRAW" FOREIGN KEY
("RAWSTATUS") REFERENCES STATUSRAW ("RAWSTATUS") ON UPDATE CASCADE;