SQL – insert

通常insert

$StrSQL =   
      "insert into GVIS_log "
    . " ( logPeriod,"
    . "   logShubetsu, "
    . "   clientIP, "
    . "   userID, "
    . "   Sousa, "
    . "   Message, "
    . "   browser, "
    . "   ins_date, "
    . "   ins_user "
    . " ) "
    . " values ( '" . $gv_ymd . " " . $gv_hhmmss ."' " 
    . "        , 'info' "
    . "        , '" . $gv_IP ."' " 
    . "        , '" . $gv_User  ."' " 
    . "        , '" . $arg1  ."' " 
    . "        , '" . $arg2  ."' " 
    . "        , '" . $gv_browser  ."' " 
    . "        , '" . $gv_ymd . " " . $gv_hhmmss ."' "
    . "        , '" . $gv_User    . "' " 
    . "        ) " 

抽出内容をinsert

$StrSQL2 = 
      " insert into GVIS_keihi". "  \n"
    . " select ". "  \n"
    . "     '" .$InputParm2_yyyy. "-" . $InputParm2_mm . "-01' as workPeriod,". "  \n"
    . "     workShubetsu,". "  \n"
    . "     workPriority,". "  \n"
    . "     '" .$InputParm2_yyyy. "-" . $InputParm2_mm . "-01' as workPeriod,". "  \n"
    . "     Kamoku,". "  \n"
    . "     Tehai,". "  \n"
    . "     Kng,". "  \n"
    . "     Biko,". "  \n"
    . "     '" . $gv_DATE . "' as ins_date,". "  \n"
    . "     '" . $gv_user . "' as ins_user,". "  \n"
    . "     '" . $gv_DATE . "' as upd_date,". "  \n"
    . "     '" . $gv_user . "' as upd_user". "  \n"
    . " from GVIS_keihi as t1". "  \n"
    . " where  year(workPeriod) = " . $InputParm1_yyyy. "  \n"
    . "   and month(workPeriod) = " . $InputParm1_mm. "  \n"
    . "   and workPriority      < 2001                   \n"
    . " ; ". "  \n"
タイトルとURLをコピーしました