I am getting an error in datawindow syntax in Powerbuilder. Database Oracle 12c.
Here is the error-
ORA-00904: "SEAT_AVLB": invalid identifier
Here is the code -
SELECT 0 as sr,
"TBL_CLASS_MST"."CLASS_NAME",
"TBL_CLASS_MST"."SECTION",
"TBL_CLASS_MST"."ROOM_NO",
"TBL_ROOMS_MST"."MAX_CAP" ,
TBL_ROOMS_MST.max_cap - (select count(*) from tbl_student_mst) as seat_avlb
FROM "TBL_CLASS_MST",
"TBL_ROOMS_MST"
WHERE ( "TBL_CLASS_MST"."ROOM_NO" = "TBL_ROOMS_MST"."ROOM_NO" ) and
((class_nr= :ra_class) and
(seat_avlb>0))
You can't use alias that way; put the whole expression (that makes seat_avlb
) into the where
clause:
SELECT 0 AS sr,
"TBL_CLASS_MST"."CLASS_NAME",
"TBL_CLASS_MST"."SECTION",
"TBL_CLASS_MST"."ROOM_NO",
"TBL_ROOMS_MST"."MAX_CAP",
tbl_rooms_mst.max_cap - (SELECT COUNT (*) FROM tbl_student_mst) AS seat_avlb
FROM "TBL_CLASS_MST", "TBL_ROOMS_MST"
WHERE ("TBL_CLASS_MST"."ROOM_NO" = "TBL_ROOMS_MST"."ROOM_NO")
AND ( (class_nr = :ra_class)
AND ( tbl_rooms_mst.max_cap
- (SELECT COUNT (*) FROM tbl_student_mst) >
0));