2
I need to copy the data from a BD-1 PGSQL to another BD-2 PGSQL whenever I have a new record. I was trying to give a SELECT inside the INSERT but is failing with the connection, I already checked smallpox posts but I could not find a solution, someone could give some idea of how to do or would be just like I was doing ?
NOTE: I can’t modify anything from the BD-1.
$sql1 = "INSERT INTO call_lost.teste (cod, data, hora, telefone)
SELECT q_num, time_start, from_userpart, ts_servicing FROM database_single.callcent_queuecalls WHERE ts_servicing = '00:00:00'";
$resultset = pg_query($conn1, $sql1) or die("database error:" . pg_errormessage($conn1));
What connection error?
– Diego Schmidt
@Diegoschmidt he is not making the connection with the two banks, only makes the connection individually.
– Diogo Moura
You can use the dblink only will not sync alone need to call it in your code or via cron.
– rray
@rray I just saw this post was researching a little more about, you know let me know if I need to have them in both comics ?
– Diogo Moura
You need to 'install' it only in the DB that will record the information of the other.
– rray
@rray Great,ai I throwing the code in cron it would run for a certain time, correct? Or would I have a condition to make
INSERT
only when you have a new entry in BD-1.– Diogo Moura
Not ready. Would have to assemble a logic prorpria, in DB-1 if possible could put a datetime column with the inclusion date of the record, then at the time of calling the cron does already filters for the last time it ran.
– rray
@rray can’t create this column, DB-1 is from another third party system, I only have permission to perform queries.
– Diogo Moura