Warning: pg_query(): Query failed: ERROR: could not establish connection DETAIL: FATAL: sorry, too many clients already in /usr/local/apache2/htdocs/classes2/jp/co/itup/database/pg_process.php on line 53
SELECT class_id FROM ( SELECT class_id, count(class_id) AS counting FROM ( SELECT nm.class_id, cm.category_code, attendancekbn, mstLectCustomer.customerno, mstLectCustomer.associateno FROM ( near_class_mst AS nm INNER JOIN near_class_pref AS p ON nm.class_id =p.class_id AND nm.class_case =p.class_case ) INNER JOIN ( SELECT tb.class_id, tb.class_kbn, tb.class_case, tb.category_code, mst.formal_name As category_name, mst.coins_cd, mst.category_pic, mstHobby.hobby_name FROM near_class_category AS tb LEFT OUTER JOIN category_mst AS mst ON tb.category_code=mst.category_code LEFT JOIN mst_hobby_category AS mstHobbyCategory ON tb.category_code = mstHobbyCategory.category_code LEFT JOIN mst_hobby AS mstHobby ON mstHobbyCategory.hobby_code = mstHobby.hobby_code WHERE mst.delete_flg = '0' AND mst.tushin_flg <> '1' AND mst.view_flg = '1' GROUP BY tb.class_id, tb.class_kbn, tb.class_case, tb.category_code, mst.formal_name, mst.category_pic, mst.coins_cd, mstHobby.hobby_name ) AS cm ON nm.class_id = cm.class_id AND nm.class_case = cm.class_case INNER JOIN ( SELECT t2.memberno, t2.customername, t2.customerno, t2.lectureno, t2.associateno, t2.attendancekbn from dblink( 'dbname=coinsdb user=postgres password=password', 'SELECT y.memberno, y.customername, x.customerno, x.lectureno, x.associateno, x.attendancekbn FROM mst_lectcustomer x, mst_customer y WHERE x.customerno = y.customerno AND x.attendancekbn = 6 GROUP BY y.memberno, y.customername, x.customerno, x.lectureno, x.associateno' ) as t2( memberno numeric(7, 0), customername character varying(64), customerno numeric(8, 0), lectureno numeric(5, 0), associateno numeric(5, 0), attendancekbn numeric(2, 0) ) ) mstLectcustomer ON CAST(nm.member_number AS numeric) = mstLectcustomer.memberno WHERE nm.delete_flg = '0' AND nm.class_apply_status = 3 AND attendancekbn IS NOT NULL GROUP BY nm.class_id, cm.category_code, attendancekbn, mstLectcustomer.customerno, mstLectcustomer.associateno ) AS class_table GROUP BY class_id ) AS count_table WHERE counting > 0 AND class_id IN ( SELECT class_id FROM near_class_mst AS ncm LEFT JOIN ( SELECT t2.customerno, t2.lectureno, t2.memberno FROM dblink( 'dbname=coinsdb user=postgres password=password', 'select x.customerno, x.lectureno, y.memberno from mst_lectcustomer x, mst_customer y where x.customerno = y.customerno AND x.attendancekbn = 6' ) as t2( customerno numeric(8, 0), lectureno numeric(5, 0), memberno numeric(7, 0) ) ) AS mstLectcustomer2 ON ncm.member_number = CAST(mstLectcustomer2.memberno AS character varying) WHERE ( CAST( mstLectcustomer2.lectureno AS varchar ) = '2802' AND EXISTS ( SELECT null FROM category_mst AS categoryMst LEFT JOIN near_class_category AS nearClassCategory ON nearClassCategory.category_code = categoryMst.category_code WHERE CAST(categoryMst.coins_cd AS varchar) IN ( 2201 ) AND nearClassCategory.class_id = ncm.class_id AND nearClassCategory.class_case = ncm.class_case AND ( ( categoryMst.delete_flg = 0 AND categoryMst.tushin_flg <> '1' AND categoryMst.view_flg = '1' ) OR (ncm.class_id IS NULL) ) ) AND NOT EXISTS ( SELECT * FROM mst_new_lecture_excluded AS b WHERE ncm.class_id = b.class_id AND ncm.class_case = b.class_case AND ( CAST( b.new_lecture_id AS varchar ) = '46' ) ) ) AND class_apply_status = 3 AND delete_flg != 1 GROUP BY class_id ) SQL顼