| 
    
     | 
       
        | Author |  |  
        | jeffw_00 Super User
 
  
 
 Joined: June 30 2007
 Online Status: Offline
 Posts: 935
 | 
          Hi - I would like to find a way (preferably something I can write as a macro), that writes out the SQL for the macros, timed events, triggers, and (ideally) devices.
           | Posted: December 13 2007 at 21:42 | IP Logged |   |  
           | 
 |  
 Here's why  - I'd really like a way to textually "diff" two databases.  It's a great way to
 
 1) review your changes after you make some, the diff will show only your edits.
 
 2) see what changes I made on a certain day, by comparing backup files.
 
 Just wondering if there's an SQL statement to do the whole caboodle at once.
 
 thanks!
 /j
 |  
        | Back to Top |     |  
        |  |  
        | jeffw_00 Super User
 
  
 
 Joined: June 30 2007
 Online Status: Offline
 Posts: 935
 | 
          bump?  (I think Dave is away this week...)
           | Posted: December 25 2007 at 14:23 | IP Logged |   |  
           | 
 |  /j
 |  
        | Back to Top |     |  
        |  |  
        | dhoward Admin Group
 
  
  
 Joined: June 29 2001
 Location: United States
 Online Status: Offline
 Posts: 4447
 | 
          Jeff,
           | Posted: December 30 2007 at 21:11 | IP Logged |   |  
           | 
 |  
 Ive looked at this and can think of no good way to do this as a macro.  You could of course use the multi-editor in SQL mode and select each of the tables one by one to create the reports and then use the File "Export" to save as type SQL.  No way to do this automatically though unless you wanted to try and send keystrokes to the PowerHome application itself to duplicate the steps you'd do manually.  Probably doable, but no easy feat.
 
 However, after looking at your requirements, I think it can be done.  The saved database wouldnt be in SQL format however and would instead be an HTML table.  Still text data that could be compared and diffed.  If you're interested, this is the way you'd do it.
 
 
 
| Code: 
 
    
    | 
      
       | insert into macroheader values ('DBEXPORT','DB Export',0,0,1);
 insert into macrodetail values ('DBEXPORT',1,15,'[LOCAL2]',NULL,'string(today(),"yyyy-mm-dd")',0,'');
 insert into macrodetail values ('DBEXPORT',2,15,'[LOCAL3]',NULL,'1',0,'');
 insert into macrodetail values ('DBEXPORT',3,26,'',NULL,'LOOP',0,'');
 insert into macrodetail values ('DBEXPORT',4,15,'[LOCAL1] ',NULL,'ph_regexdiff1(",",",",",macroheader,macrodetail,inst eondevices,exit,",1,[LOCAL3],0,0,0)',0,'');
 insert into macrodetail values ('DBEXPORT',5,16,'',NULL,'if("[LOCAL1]" = "exit",999,1)',0,'');
 insert into macrodetail values ('DBEXPORT',6,38,'',0,'ph_sqlselect(1,"select * from [LOCAL1] order by 1,2") + ph_writefile("[LOCAL2].htm",0,ph_gethtmldata(1)) + ph_sqldestroy(1) + ph_addtovar(1,3,1)',0,'');
 insert into macrodetail values ('DBEXPORT',7,27,'',NULL,'"LOOP"',0,'');
 
 |  |  |  
 Since the forum has a tendency to dork up SQL, Ive also attached the above macro as an attachment 2007-12-30_211007_dbexport.txt
 
 As you can see, Ive only included 3 tables in the sample but you can add others as you see fit.  The important thing is to make sure that the string that contains the table names begins and ends with a comma with each table separated by a comma.
 
 Hope this helps,
 
 Dave.
 
 |  
        | Back to Top |       |  
        |  |  
        | jeffw_00 Super User
 
  
 
 Joined: June 30 2007
 Online Status: Offline
 Posts: 935
 | 
          thanks Dave - I'll give it a try
           | Posted: December 30 2007 at 21:13 | IP Logged |   |  
           | 
 |  /j
 |  
        | Back to Top |     |  
        |  |  
        | jeffw_00 Super User
 
  
 
 Joined: June 30 2007
 Online Status: Offline
 Posts: 935
 | 
          Hi Dave - this works great. Although... (8-}) is it just as easy to write plain text as HTML?    Not to complain, but the HTML source is rather heavy (for example, I added one comment to one macro and it added about 7 lines of HTML....).
           | Posted: December 30 2007 at 22:15 | IP Logged |   |  
           | 
 |  
 If it's not trivial to write plain text, I can convert it externally.
 
 THANKS!
 /j
 |  
        | Back to Top |     |  
        |  |  |  |