doulangpeng3933 2018-06-05 19:13
浏览 72

PHP全局临时表的Oracle问题

I am using PHP 7.21 and Oracle 12c. I am having an issue with a global temporary table. Sometimes the data returns an empty table, and I am only having this issue with temporary tables. I have tried in both Laravel and CodeIgniter but the issue remains. Is there something in my below code that is an apparent problem?

PHP Code:

<?php

$c = oci_new_connect("system", "1234", "127.0.0.1:1521/ORCL:POOLED");
oci_execute(oci_parse($c,"CALL pr_test()"));
$s = oci_parse($c, 'select * from GTT_TABLEs');
oci_execute($s);
oci_fetch_all($s, $res);
var_dump($res);   

SQL Code:

--- Global Temporary Table ----    
CREATE GLOBAL TEMPORARY TABLE "SYSTEM"."GTT_TABLES" 
   (    "ID" NUMBER(10,0) NOT NULL ENABLE, 
    "FIRSTNAME" VARCHAR2(191 BYTE), 
    "LASTNAME" VARCHAR2(191 BYTE), 
    "EMAIL" VARCHAR2(191 BYTE), 
    "POINTS" VARCHAR2(191 BYTE), 
    "NOTES" VARCHAR2(191 BYTE), 
    "CREATED_AT" TIMESTAMP (6), 
    "UPDATED_AT" TIMESTAMP (6), 
    "AGE" NUMBER(10,0), 
    "JOB" VARCHAR2(191 BYTE), 
    "GENDER" VARCHAR2(191 BYTE), 
    "COUNTRY" VARCHAR2(191 BYTE), 
    "SALE_DATE" VARCHAR2(191 BYTE)
   ) ON COMMIT PRESERVE ROWS ;  

--- PROCEDURE -----            
create or replace PROCEDURE PR_TEST  AS
BEGIN
DELETE GTT_TABLED;  
INSERT INTO GTT_TABLES (SELECT * FROM DATATABLES);
COMMIT;
END;
  • 写回答

2条回答 默认 最新

  • dongzhunqiu4841 2018-06-05 19:19
    关注

    Data in temporary tables is visible to your session only, so - nobody but you can see nor use it. Is that your case? If so, switch to "normal" tables; you'll need some additional identifier which will help you distinguish data among different users.

    Also, I'd suggest you not to create your own objects in SYSTEM (nor SYS) schemas, which is what you currently are doing.

    评论

报告相同问题?

悬赏问题

  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致