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 CAST( cm.category_code AS varchar ) IN ('84') AND 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 > 0SQL顼