2 xuzhiyang12345 xuzhiyang12345 于 2013.12.17 10:01 提问

在PLSQL中执行没问题,在JDBC中查询报列名无效

大家帮忙看看,这段SQL有什么问题,我在PLSQL中执行没问题,但是用JDBC查的时候就报列名无效的错误。
select *
from (select T_c_p_i.HOUSEHOLD_ID,
T_c_p_i.HOUSEHOLD_HEAD_RELATIONSHIP,
T_P_H_A.attribute_meaning as attribute_meaning,
T_c_p_i.PERSON_NAME,
T_c_p_i.GENDER,
to_char(T_c_p_i.BIRTHDAY, 'yyyy/mm/dd'),
T_c_p_i.ID_NUMBER,
T_c_i.COOPERATE_NUMBER,
T_c_i.PERSON_PAYMENT,
T_c_p_i.MARRIAGE_STATE,
T_c_p_i.NATION,
T_c_i.LIVE_TOWN,
T_c_i.LIVE_VILLAGE,
T_c_i.CONTACT_WAY,
T_c_i.CONTACT_ADDRESS,
T_c_p_i.CHRONIC_DISEASE1,
T_c_p_i.CHRONIC_DISEASE2,
T_c_p_i.CHRONIC_DISEASE3,
T_P_H_A.attributeMean as attributeMean,
T_c_i.Area_Id,
T_c_i.Cooperate_Year,
f.hospital_id
from t_cooperate_info T_c_i
left join t_cooperate_person_info T_c_p_i
on T_c_i.person_info_id = T_c_p_i.id
left join (select personInfo.personId,
personInfo.attributeMean,
houseInfo.attribute_meaning
from (select personId,
sys_connect_by_path(attributeMean, ',') attributeMean
from (select temp.person_info_id as personId,
temp.attribute_meaning as attributeMean,
row_number() over(partition by temp.person_info_id order by temp.person_info_id) rn,
count(*) over(partition by temp.person_info_id) cnt
from (select a.person_info_id,
b.attribute_meaning
from t_person_attribute_link a,
t_person_household_attribute b
where a.attribute_id = b.id
and b.id in
(select id
from t_person_household_attribute
where t_person_household_attribute.attribute_type = '01')) temp)
where level = cnt
start with rn = 1
connect by prior personId = personId
and prior rn = rn - 1) personInfo
left join (select a.person_info_id, b.attribute_meaning
from t_person_attribute_link a,
t_person_household_attribute b
where a.attribute_id = b.id
and b.id in
(select id
from t_person_household_attribute
where t_person_household_attribute.attribute_type = '02')
order by a.person_info_id asc) houseInfo
on personInfo.personId = houseInfo.person_info_id) T_P_H_A
on t_p_h_a.personId = T_c_i.Person_Info_Id
left join t_cooperate_info_hospital_link f
on f.cooperate_info_id = T_c_i.Person_Info_Id)
where 1 = 1
and cooperate_year like '%2013%'
and area_id = '1099100700371197000'

1个回答

a_liujian
a_liujian   2013.12.17 10:27
已采纳

问题可以说清楚点:错误日志? 有无用到Hibernet等框架?什么环境?

用排除法来解决错误吧
1.select ```````` 这些字段可以一部份一部份来查,直到找到不能识别的列

PS:to_char(T_c_p_i.BIRTHDAY, 'yyyy/mm/dd') 要给别名

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!