|
|
|
รบกวนช่วยดูโค้ดหน่อยได้ไหมคะ พอดีไม่สามารถ insert update ได้ ติดมาหลายวันแล้วค่ะ |
|
|
|
|
|
|
|
สั่งให้ $data['query']=$query;
alert ค่า query ออกมาแล้วขึ้นว่า undefined
Code (PHP)
if ($_GET[aMode]=='Update')
{
$conn=oci_connect($oracle_user, $oracle_pwd, $db)or die('Connect Error');
$data['success']=false;
$data['name']="Err";
$query=" SELECT SFC80_ORDNO AS ORDNO FROM SFCWGPAL
INNER JOIN SFCMCPAL ON
SFCA0_PALLETID=SFC90_PALLETID
INNER JOIN SFCMCUPC ON
SFC90_PACKAGEID=SFC80_PACKAGEID
WHERE TO_CHAR(SFCA0_RECTIME,'YYYYMMDD')>='$START_DATE' AND
TO_CHAR(SFCA0_RECTIME,'YYYYMMDD')<='$END_DATE'
GROUP BY SFC80_ORDNO
ORDER BY SFC80_ORDNO ";
oci_free_statement($stmt);
$stmt = oci_parse ($conn, $query);
oci_execute ($stmt,OCI_DEFAULT);
while ($rs = oci_fetch_array($stmt, OCI_ASSOC))
{
$data['success']=true;
$data['ORDNO']="".$rs[ORDNO];
$ORDNO1=$rs[ORDNO];
//=============================FECTH2-FOR-GET-QTY============
if ($ORDNO1) {
$q1 = "SELECT COUNT(SFC80_EDASN) AS QTY ,SFC80_ORDNO FROM SFCMCUPC
WHERE SFC80_ORDNO='$ORDNO1' and TO_CHAR(SFC80_RECTIME,'YYYYMMDD')>='$START_DATE' AND
TO_CHAR(SFC80_RECTIME,'YYYYMMDD')<='$END_DATE'
GROUP BY SFC80_ORDNO ";
//-$Btmt = oci_parse ($conn, $q1);
//-oci_execute ($Btmt,OCI_DEFAULT);
oci_free_statement($Btmt);
$Btmt = oci_parse ($conn, $q1);
oci_execute ($Btmt,OCI_DEFAULT);
while($Brs = oci_fetch_array($Btmt,OCI_ASSOC)){
$QTY=$Brs[QTY];
$data['QTY']="".$Brs[QTY];
//===================UPDATE OR INSERT===========
$sqlSUM61 = "SELECT * FROM SFC1MINV
WHERE SFCV0_YYYYMM='$SFCV0_YYYYMM' AND SFCV0_PO='$ORDNO1'
";
$data['sqlSUM61']=$sqlSUM61;
$stmtSE1 = oci_parse ($conn, $sqlSUM61);
oci_execute ($stmtSE1,OCI_DEFAULT);
$resultSE1 = oci_fetch_array($stmtSE1);
if($resultSE1) {
$query ="UPDATE SFC1MINV
SET SFCV0_QTY='$QTY' ,SFCV0_AMOUNT=$QTY*$UPRICE,SFCV0_RECTIME=SYSDATE
WHERE SFCV0_YYYYMM='$SFCV0_YYYYMM' AND SFCV0_PO='$SFC80_ORDNO' ";
$data['query']=$query;
}else {
$query ="INSERT INTO SFC1MINV (
SFCV0_YYYYMM ,
SFCV0_PO,
SFCV0_QTY,
SFCV0_RECTIME ,
SFCV0_UPRICE
)
VALUES(
'$SFCV0_YYYYMM',
'$SFC80_ORDNO',
'$QTY',
SYSDATE,
0
)";
}
//====================END UPDATE OR INSERT=======
}//while($Brs
//=============================FETCH2-FOR-GET-QTY=============
}//if ($ORDNO1) {
}//while ($rs
echo __json_encode($data);
oci_free_statement($stmt);
oci_close($conn);
exit;
}
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2015-11-18 13:26:04
|
|
|
|
|
Date :
2015-11-18 13:23:34 |
By :
ipchully |
View :
851 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เดานะครับ
Code
if($resultSE1) {
$query ="UPDATE SFC1MINV
SET SFCV0_QTY='$QTY' ,SFCV0_AMOUNT='".$QTY*$UPRICE."',SFCV0_RECTIME='".SYSDATE."'
WHERE SFCV0_YYYYMM='$SFCV0_YYYYMM' AND SFCV0_PO='$SFC80_ORDNO' ";
$data['query']=$query;
}else {
$query ="INSERT INTO SFC1MINV (
SFCV0_YYYYMM ,
SFCV0_PO,
SFCV0_QTY,
SFCV0_RECTIME ,
SFCV0_UPRICE
)
VALUES(
'$SFCV0_YYYYMM',
'$SFC80_ORDNO',
'$QTY',
'".SYSDATE."',
0
)";
}
|
|
|
|
|
Date :
2015-11-18 14:11:46 |
By :
arm8957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'".($QTY*$UPRICE)."'
ทำงานในรูปแบบ function อย่าลืมวงเล็บด้วยครับ
SFCV0_RECTIME=SYSDATE()
SYSDATE เป็น function ใน mysql ต้องใส่ วงเล็บอีกเหมือนกัน
|
ประวัติการแก้ไข 2015-11-18 15:38:43
|
|
|
|
Date :
2015-11-18 15:37:59 |
By :
NewbiePHP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณพี่ๆมากๆค่ะ
|
|
|
|
|
Date :
2015-11-18 17:51:52 |
By :
ipchully |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|