Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » Batch Script connecting two databases in an Extract Tranform Load (ETL) Design Pattern (Do you have any advice about how to structure a program that will be moving data between pgsql and sqlsrv databases?)
Re: Batch Script connecting two databases in an Extract Tranform Load (ETL) Design Pattern [message #4762 is a reply to message #4761] Tue, 02 June 2015 23:28 Go to previous messageGo to previous message
rafs is currently offline  rafs
Messages: 69
Registered: May 2015
Member
Here is another, more simple test. Here it appears that I am trying to insert, rather than update...basically I am missing the key idea.

You can see the errors:
38 Debug Errors:
39 array(2) {
40 ["sid_type_id"]=>
41 string(38) "A record already exists with this key."
42 ["sid"]=>
43 string(38) "A record already exists with this key."

test-batch-simple.php
  1 <?php
  2 // Batch Test
  3
  4 ini_set('include_path', '.');
  5 require 'std.batch.inc';
  6
  7 batchInit(__FILE__);
  8
  9 $dbobj = RDCsingleton::getInstance('sids');
 10 $dbobj->sql_select  = '';
 11 $dbobj->sql_from    = '';
 12 $dbobj->sql_where   = 'sid_type_id=2';
 13 $dbobj->sql_groupby = '';
 14 $dbobj->sql_orderby = 'sid ASC';
 15
 16 $fieldarray = $dbobj->getData("sid=15");
 17 print "Debug\tgetData:\n";
 18 var_dump($fieldarray);
 19
 20 // simple modification
 21 $fieldaray['deployment_status_flags'] = $fieldarray['deployment_status_flags'] | 2;
 22
 23 $dbobj->startTransaction();
 24 $rowdata = $dbobj->updateRecord($fieldarray);
 25
 26 if ( !empty($dbobj->errors) ) {
 27     print "Debug\tErrors:\n";
 28     var_dump($dbobj->errors);
 29     $dbobj->rollback();
 30 } else {
 31     $dbobj->commit();
 32 }
 33
 34 if ( isset($dbobj->messages) ) {
 35     print "Debug\tmessages: \n";
 36     var_dump($dbobj->messages);
 37 }
 38
 39 print "Debug\tAfter update rows:\n";
 40 var_dump($rowdata);
 41
 42 batchEnd();
 43
 44 ?>


out
     7  <p>server API   : cli</p>
     8  <p>language     : en-us</p>
     9  <p>server_admin : </p>
    10  <p>include_path : .;C:\xampp\radicore\includes;C:\xampp\htdocs\radicore\newsigdb;C:\xampp\htdocs\radicore\idp1;C:\xampp\htdocs\radicore\audit;C:\xampp\htdocs\radicore\audit\text;C:\xampp\htdocs\radicore\dict;C:\xampp\htdocs\radicore\menu;C:\xampp\htdocs\radicore\workflow;C:\xampp\htdocs\radicore\menu;C:\xampp\htdocs\radicore\audit;C:\xampp\htdocs\radicore\workflow</p>
    11  <p>project_code : </p>
    12  <p>user_id : batch</p>
    13  <p>role_id : batch</p>
    14  Debug   getData:
    15  array(1) {
    16    [0]=>
    17    array(9) {
    18      ["id"]=>
    19      string(1) "2"
    20      ["sid_type_id"]=>
    21      string(1) "2"
    22      ["sid"]=>
    23      string(2) "15"
    24      ["current_signature_id"]=>
    25      NULL
    26      ["deployment_status_flags"]=>
    27      string(1) "2"
    28      ["updated_at"]=>
    29      NULL
    30      ["updated_by"]=>
    31      NULL
    32      ["first_deployed_timestamp"]=>
    33      NULL
    34      ["last_deployed_timestamp"]=>
    35      NULL
    36    }
    37  }
    38  Debug   Errors:
    39  array(2) {
    40    ["sid_type_id"]=>
    41    string(38) "A record already exists with this key."
    42    ["sid"]=>
    43    string(38) "A record already exists with this key."
    44  }
    45  Debug   messages:
    46  array(0) {
    47  }
    48  Debug   After update rows:
    49  array(9) {
    50    ["id"]=>
    51    string(1) "2"
    52    ["sid_type_id"]=>
    53    string(1) "2"
    54    ["sid"]=>
    55    string(2) "15"
    56    ["current_signature_id"]=>
    57    NULL
    58    ["deployment_status_flags"]=>
    59    string(1) "2"
    60    ["updated_at"]=>
    61    NULL
    62    ["updated_by"]=>
    63    NULL
    64    ["first_deployed_timestamp"]=>
    65    NULL
    66    ["last_deployed_timestamp"]=>
    67    NULL
    68  }
    69  <p>** finished at June 3, 2015, 5:16 am</p>
    70  </html>
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to use actions(submit,submitstay,copy,quit)
Next Topic: tutorial4 Viewing the Tree structure
Goto Forum:
  


Current Time: Sun Apr 28 16:58:35 EDT 2024

Total time taken to generate the page: 0.07987 seconds