T
T
teodolit2021-02-26 12:30:01
Oracle
teodolit, 2021-02-26 12:30:01

Is it possible to get data from a temporary table in multiple queries?

Good afternoon. I am writing a service that sends a request to the Table, and it must receive data in order to work with it further. Request example:

$sql = <<<SQL
CREATE GLOBAL TEMPORARY TABLE SADMIN.DUBLES (
RESULT varchar2(200),
GUID DATE
)
    ON COMMIT DELETE ROWS
SQL;
    $this->module->db_crm->createCommand($sql)->execute();

$sql = <<<SQL
DECLARE
  RESULT varchar2(200) ;
BEGIN
-- всякая логика
  INSERT INTO SADMIN.DUBLES (RESULT, GUID) VALUES (RESULT, CURRENT_DATE);
END;
SQL;
$this->module->db_crm->createCommand($sql)->execute();

Here I need to get the data that was written to the RESULT column.
I do
$sql = <<<SQL
SELECT * FROM SADMIN.DUBLES 
SQL;
$data2 = $this->module->db_crm->createCommand($sql)->queryAll();

But I am not getting data. I seem to understand that this is due to the fact that this request is already considered another transaction, so I don’t see the data.
When I try to add a select to the first query, after end, I get the error ORA-06550 Encountered the symbol "SELECT". An attempt to add "/" gives the same thing, it already swears at this character.

While I'm at a dead end, there are no ideas at all how to make the code work. Well, except for creating a "normal" table, but this option does not suit me yet.
I myself am familiar with oracle and sql, please do not kick much)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitsliputsli, 2021-02-26
@Vitsliputsli

But I am not getting data. I seem to understand that this is due to the fact that this request is already considered another transaction, so I don’t see the data.

Well, do it in one transaction. Explicitly declare the transaction or otherwise disable autocommit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question