環境
PHP MVCモデル
フレームワーク CodeIgniter
DB Oracle
やっていること
あるテーブルの二つの値を用いて新しくレコードを作成している。
OSqlEditで実行すると正常に値が取得される。
PHPで元々実装されているSQLに組み込むとエラーが出る。
既にSELECTで指定されている最後の項目の後に[,]は入れています。
元々実装されているSQLはPHPでは実行できますが、OSqlEditで実行すると
「\」が「¥」に置き換えられ「式がありません」のエラーが出ます。
元々実装されているSQL
SQL
1SELECT MF_SISAKU_MAIN.SISKKNR_NO, MF_SISAKU_MAIN.TNT_CD, MF_SISAKU_MAIN.PAYMENT_CD, MF_SISAKU_MAIN.PAYMENT_TYPE,MF_SISAKU_MAIN.HSYCAL_KBN, MF_SISAKU_MAIN.HYKSIHYO_KBN,MF_SISAKU_MAIN.TNTBSY_CD, MF_SISAKU_MAIN.KOSIN_TIM, MF_SISAKU_MAIN.SISKDAT_SBT, MF_SISAKU_MAIN.PRIVATE_FLG, MF_SISAKU_MAIN.PAYAPLY_STAT,MF_SISAKU_MAIN.SISKAPLY_STAT,MF_SISAKU_MAIN.SIMU_STAT, HYKFROM_YM, HYKTO_YM, TKUISK_KNM, SISK_ID, SISK_KNM, HINGRP_KNM, HSY_KIN, PLN_KIN, JGN_KIN, SSKRYK_KNM, KNZSMEI_SEI_KNM, KNZSMEI_MEI_KNM,SISKJTI_KBN, SISKPTN_KBN, SISKOPE_STAT, TRKSAPLY_STAT, CATE_JTI.KNM AS CATE_JTI_KNM, CATE_SBT.KNM AS CATE_SBT_KNM, PAY.PAYMENT_KNM,SIMU_SBT.KNM AS SIMU_SBT_KNM,MKH_SBT.KNM AS MKH_SBT_KNM,CASE WHEN HYKTO_YM IS NOT NULL THEN TO_CHAR(ADD_MONTHS(SUBSTR(HYKTO_YM, 1, 4) || \'/\' || SUBSTR(HYKTO_YM, 5, 2) || \'/01\', 1), \'YYYYMM\') END AS HYKTO_NXT_YM, 2FROM (SELECT MF_SISAKU.*, EGT0000P.EGT0102S(SISKKNR_NO, \'O\') || 01 AS SISKKIJUN_YMD FROM MF_SISAKU) MF_SISAKU_MAIN LEFT OUTER JOIN VW_TKUISK ON MF_SISAKU_MAIN.HYKHOJIN_CD = VW_TKUISK.TKUISK_CD AND SISKKIJUN_YMD BETWEEN VW_TKUISK.YUKOFROM_YMD AND VW_TKUISK.YUKOTO_YMD 3LEFT OUTER JOIN MF_SISKHINGRP ON MF_SISAKU_MAIN.SISKKNR_NO = MF_SISKHINGRP.SISKKNR_NO AND SISK_SEQ = 1 AND HYKHSY_KBN = 1 AND HYOJI_SEQ = 1 4LEFT OUTER JOIN MF_HINGRP ON MF_HINGRP.HINGRP_CD = MF_SISKHINGRP.HINGRP_CD AND SISKKIJUN_YMD BETWEEN MF_HINGRP.YUKOFROM_YMD AND MF_HINGRP.YUKOTO_YMD 5LEFT OUTER JOIN VW_NEWSSK ON MF_SISAKU_MAIN.TNTBSY_CD = VW_NEWSSK.SSK_CD AND SISKKIJUN_YMD BETWEEN VW_NEWSSK.YUKOFROM_YMD AND VW_NEWSSK.YUKOTO_YMD 6LEFT OUTER JOIN VW_KZNKHN ON MF_SISAKU_MAIN.TNT_CD = VW_KZNKHN.KZN_CD AND SISKKIJUN_YMD BETWEEN VW_KZNKHN.YUKOFROM_YMD AND VW_KZNKHN.YUKOTO_YMD 7LEFT OUTER JOIN MF_CATEGORY CATE_JTI ON MF_SISAKU_MAIN.SISKJTI_KBN = CATE_JTI.KBN AND CATE_JTI.CTGRSBT_KBN = \'SISKJTI\' 8LEFT OUTER JOIN MF_CATEGORY CATE_SBT ON MF_SISAKU_MAIN.SISKSBT_CD = CATE_SBT.KBN AND CATE_SBT.CTGRSBT_KBN = \'SISKSBT\' 9LEFT OUTER JOIN MF_CATEGORY SIMU_SBT ON MF_SISAKU_MAIN.SIMU_STAT = SIMU_SBT.KBN AND SIMU_SBT.CTGRSBT_KBN = \'SIMUST\' 10LEFT OUTER JOIN MF_CATEGORY MKH_SBT ON MF_SISAKU_MAIN.MKH_STAT = MKH_SBT.KBN AND MKH_SBT.CTGRSBT_KBN = \'MKHOST\' 11LEFT OUTER JOIN VW_PAYMENT PAY ON MF_SISAKU_MAIN.PAYMENT_CD = PAY.PAYMENT_CD ;
追加するSQL
SQL
1select HYSCAL_KBN,HYKSIHYO_KBN 2CASE HSYCAL_KBN 3 WHEN '1' THEN 4 CASE HYKSIHYO_KBN 5 WHEN '01' THEN 'A' 6 WHEN '02' THEN 'A' 7 WHEN '03' THEN 'B' 8 WHEN '04' THEN 'B' 9 WHEN '05' THEN 'B' 10 WHEN '06' THEN 'B' 11 END 12 WHEN '2' THEN 13 CASE HYKSIHYO_KBN 14 WHEN '01' THEN 'A' 15 WHEN '02' THEN 'A' 16 WHEN '03' THEN 'B' 17 WHEN '04' THEN 'B' 18 WHEN '05' THEN 'B' 19 WHEN '06' THEN 'B' 20 END 21 WHEN '3' THEN 'C' 22 23 ELSE NULL 24 END AS KUBUN 25 26from HOGE;
追加後のSQL
SQL
1SELECT MF_SISAKU_MAIN.SISKKNR_NO, MF_SISAKU_MAIN.TNT_CD, MF_SISAKU_MAIN.PAYMENT_CD, MF_SISAKU_MAIN.PAYMENT_TYPE,MF_SISAKU_MAIN.HSYCAL_KBN, MF_SISAKU_MAIN.HYKSIHYO_KBN,MF_SISAKU_MAIN.TNTBSY_CD, MF_SISAKU_MAIN.KOSIN_TIM, MF_SISAKU_MAIN.SISKDAT_SBT, MF_SISAKU_MAIN.PRIVATE_FLG, MF_SISAKU_MAIN.PAYAPLY_STAT,MF_SISAKU_MAIN.SISKAPLY_STAT,MF_SISAKU_MAIN.SIMU_STAT, HYKFROM_YM, HYKTO_YM, TKUISK_KNM, SISK_ID, SISK_KNM, HINGRP_KNM, HSY_KIN, PLN_KIN, JGN_KIN, SSKRYK_KNM, KNZSMEI_SEI_KNM, KNZSMEI_MEI_KNM,SISKJTI_KBN, SISKPTN_KBN, SISKOPE_STAT, TRKSAPLY_STAT, CATE_JTI.KNM AS CATE_JTI_KNM, CATE_SBT.KNM AS CATE_SBT_KNM, PAY.PAYMENT_KNM,SIMU_SBT.KNM AS SIMU_SBT_KNM,MKH_SBT.KNM AS MKH_SBT_KNM,CASE WHEN HYKTO_YM IS NOT NULL THEN TO_CHAR(ADD_MONTHS(SUBSTR(HYKTO_YM, 1, 4) || \'/\' || SUBSTR(HYKTO_YM, 5, 2) || \'/01\', 1), \'YYYYMM\') END AS HYKTO_NXT_YM, CASE HSYCAL_KBN WHEN 1 THEN CASE HYKSIHYO_KBN WHEN 01 THEN A WHEN 02 THEN A WHEN 03 THEN B WHEN 04 THEN B WHEN 05 THEN B WHEN 06 THEN B END WHEN 2 THEN CASE HYKSIHYO_KBN WHEN 01 THEN A WHEN 02 THEN A WHEN 03 THEN B WHEN 04 THEN B WHEN 05 THEN B WHEN 06 THEN B END WHEN 3 THEN C ELSE NULL END AS HOGE 2FROM (SELECT MF_SISAKU.*, EGT0000P.EGT0102S(SISKKNR_NO, \'O\') || 01 AS SISKKIJUN_YMD FROM MF_SISAKU) MF_SISAKU_MAIN LEFT OUTER JOIN VW_TKUISK ON MF_SISAKU_MAIN.HYKHOJIN_CD = VW_TKUISK.TKUISK_CD AND SISKKIJUN_YMD BETWEEN VW_TKUISK.YUKOFROM_YMD AND VW_TKUISK.YUKOTO_YMD 3LEFT OUTER JOIN MF_SISKHINGRP ON MF_SISAKU_MAIN.SISKKNR_NO = MF_SISKHINGRP.SISKKNR_NO AND SISK_SEQ = 1 AND HYKHSY_KBN = 1 AND HYOJI_SEQ = 1 4LEFT OUTER JOIN MF_HINGRP ON MF_HINGRP.HINGRP_CD = MF_SISKHINGRP.HINGRP_CD AND SISKKIJUN_YMD BETWEEN MF_HINGRP.YUKOFROM_YMD AND MF_HINGRP.YUKOTO_YMD 5LEFT OUTER JOIN VW_NEWSSK ON MF_SISAKU_MAIN.TNTBSY_CD = VW_NEWSSK.SSK_CD AND SISKKIJUN_YMD BETWEEN VW_NEWSSK.YUKOFROM_YMD AND VW_NEWSSK.YUKOTO_YMD 6LEFT OUTER JOIN VW_KZNKHN ON MF_SISAKU_MAIN.TNT_CD = VW_KZNKHN.KZN_CD AND SISKKIJUN_YMD BETWEEN VW_KZNKHN.YUKOFROM_YMD AND VW_KZNKHN.YUKOTO_YMD 7LEFT OUTER JOIN MF_CATEGORY CATE_JTI ON MF_SISAKU_MAIN.SISKJTI_KBN = CATE_JTI.KBN AND CATE_JTI.CTGRSBT_KBN = \'SISKJTI\' 8LEFT OUTER JOIN MF_CATEGORY CATE_SBT ON MF_SISAKU_MAIN.SISKSBT_CD = CATE_SBT.KBN AND CATE_SBT.CTGRSBT_KBN = \'SISKSBT\' 9LEFT OUTER JOIN MF_CATEGORY SIMU_SBT ON MF_SISAKU_MAIN.SIMU_STAT = SIMU_SBT.KBN AND SIMU_SBT.CTGRSBT_KBN = \'SIMUST\' 10LEFT OUTER JOIN MF_CATEGORY MKH_SBT ON MF_SISAKU_MAIN.MKH_STAT = MKH_SBT.KBN AND MKH_SBT.CTGRSBT_KBN = \'MKHOST\' 11LEFT OUTER JOIN VW_PAYMENT PAY ON MF_SISAKU_MAIN.PAYMENT_CD = PAY.PAYMENT_CD ;
回答2件
あなたの回答
tips
プレビュー