by 날아라갑을 [PL/SQL] PostgreSQL [2024.07.12 14:25:43]
insert into netn_dsstrfr_rsknt_list_type_message(list_id, dsstrwry_region_cd, issue_date, risk_se, creat_dt, effect_dt, pt_dt)
SELECT nextval('netn_dsstrfr_rsknt_list_type_message_list_id_seq'::regclass)
, ndr.dsstrwry_region_cd
, substring(a.start_time, 1, 12) as start_time
, case
when (a.warn_var = '2' and a.warn_stress = '0') then '10'
when (a.warn_var = '2' and a.warn_stress = '1') then '11'
when (a.warn_var = '7' and a.warn_stress = '0') then '13'
when (a.warn_var = '7' and a.warn_stress = '1') then '14'
end as RISK_SE
, now()
, to_timestamp(a.start_time, 'YYYYMMDDHH24MI')
, to_timestamp(a.dt_tm_fc,'YYYYMMDDHH24MI')
FROM (SELECT nds.sigungu_cd
, ndkf.cd_stn
, ndkf.start_time
, ndkf.dt_tm_fc
, ndkf.warn_var
, ndkf.warn_stress
FROM netn_dsstrwry_kma_flash ndkf
INNER JOIN netn_disasterarea_sigungu nds ON nds.disasterarea_nm = ndkf.cd_stn
-- 5분전 데이터 조회
WHERE substring(ndkf.start_time, 1, 12) = to_char(to_timestamp(v_dt_obz, 'YYYYMMDDHH24MI') - interval '5 minutes', 'YYYYMMDDHH24MI')
and (ndkf.warn_var = '2' or ndkf.warn_var = '7')
and ndkf.command in ('1', '6', '7')
GROUP BY nds.sigungu_cd, ndkf.cd_stn, ndkf.start_time, ndkf.dt_tm_fc, ndkf.warn_var, ndkf.warn_stress
) a
INNER JOIN netn_dsstrwry_region ndr ON a.sigungu_cd = ndr.sigungu_cd
and ndr.use_at = 'Y';
*select 조회만 해봤을때 30건 데이터가 조회가 되는데 insert부분을 타면
ERROR: missing FROM-clause entry for table "a" 라는 에러문구가 떨어집니다
혹시 제가 from절 뒤에 a로 묶은 부분이 문제가 되는걸까요 ...?