PHP代码如下:
public function index()
{
$num = 3;
@$sql = "call TTTT('$num')";
$this->db04->query($sql);
}
public function indexxx()
{
header("Content-type: text/html; charset=utf-8");
$conn = oci_connect('user','password',"(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST=xxxxxxxxxx)(PORT = 1521))(CONNECT_DATA =(SID=xxxxx)))");
if($conn){
echo '连接上';
}else{
echo '未连接';
}
$sql = 'BEGIN TTTT(:num); END;';
$stmt = oci_parse($conn,$sql);
oci_bind_by_name($stmt,':num',$num,32); //绑定参数
$num = '2';
oci_execute($stmt);
}
Oracle procedure代码如下:
create or replace PROCEDURE TTTT(num number) AS BEGIN DELETE FROM TEST T WHERE T.THEDATE=TO_CHAR(SYSDATE-NUM,'YYYY-MM-DD'); INSERT INTO TEST(THEDATE,ACCOUNT_CNT,DEVICE_CNT,CHANNELID,GAMEID,LOADTIME) SELECT TO_CHAR(SYSDATE-NUM,'YYYY-MM-DD') AS REGDATE, COUNT(SN.ACCOUNTID), COUNT(DISTINCT SN.DEVICEID), SN.CHANNELID, SN.GAMEID, SYSDATE FROM SDK_NEWUSER SN WHERE SN.NEWDATE=TO_CHAR(SYSDATE-NUM,'YYYY-MM-DD') GROUP BY SN.CHANNELID, SN.GAMEID; COMMIT; END TTTT;