从特定的日期时间从Oracle数据库中检索数据,然后将其张贴到PHP中的Firebase



描述项目思想:

我正在处理Oracle数据库8i版本的系统。我想执行一个每月自动运行的查询(使用PHP或Java)以检索下个月某些用户的适当付款数据,然后将这些数据发布到Google Firebase。

描述我的问题:

我想知道如何在每个月的特定日期自动执行查询,而不是通过单击按钮或手动运行脚本来手动运行代码。对于从Oracle检索数据和将数据发布到Firebase的既是)。但是不会永远循环循环。

我不知道它是否可以在PHP代码中完成,或者我应该使用外部程序或服务在特定时间自动运行我的功能

一个示例伪代码:

一个非常简单的示例来解释我的过程,实际代码将更有条理。您的想法非常感谢

// some Proramming language API to call myFunction() automatically 
/* this is what I need  */
// check date
if (today() = 20-currentMonth-currentYear)
(
   myFunction()
)
function myFunction()
{ 
  //conneting to database
  connect to oracle(connectionURL, username, password)
  // running connection
  run connection
  // executing updated query
  execute query(Select * from tableName where date 01-nextMonth-currentYear)
  // fetching query results
  Loop throw query result
  // prepare JSON format
  add result to json(object or array)
  // close database connection
  close oracle connection

  // sending json to firebase
  send json result to Firebase RestAPI
}

编程语言:

php

gosh,8i?那是一个古老的软件。

无论如何:您不需要PHP或外部程序 - 您需要的只是在数据库中安排的作业。DBMS_JOB应该这样做。这是该软件包的8i文档:https://docs.oracle.com/cd/a87860_01/doc/server.817/a76956/jobq.htm#5727

这是一个如何做的示例:

SQL> set serveroutput on
SQL> -- creating a dummy procedure; yours would collect data
SQL> create or replace procedure p_test
  2  is
  3  begin
  4     null;
  5  end p_test;
  6  /
Procedure created.
SQL> -- schedule a job. NEXT_DATE says when it is executed for the first time,
SQL> -- while INTERVAL says when to re-execute it -> monthly, on 5th of every month,
SQL> -- at 14:30 
SQL> declare
  2     x   number;
  3  begin
  4     sys.dbms_job.submit (
  5        job         => x,
  6        what        => 'p_test;',
  7        next_date   => to_date ('05.12.2017 14:30:00', 'dd.mm.yyyy hh24:mi:ss'),
  8        interval    => 'add_months(to_date(''05.12.2017'', ''dd.mm.yyyy''), 1) + 14 / 24 + 30 / (24*60)',
  9        no_parse    => false);
 10     sys.dbms_output.put_line ('Job Number is: ' || to_char (x));
 11     commit;
 12  end;
 13  /
Job Number is: 2895612
PL/SQL procedure successfully completed.
SQL> -- check job info
SQL> select * from user_jobs where job = 2895612;

现在,这就是收集数据的方法。不幸的是,我不知道如何将其转移到firebase中(如果需要的话,我会提到以下关键字:数据库链接,异质服务。或者,当然是Google为此)。希望其他人能够提供帮助。

相关内容

最新更新