| Author | 
         | 
          
      
        
         
         gg102 Senior Member 
          
 
  Joined: January 29 2013 Location: United States
 Online Status: Offline Posts: 246
          | 
        
         
          
           | Posted: February 28 2013 at 21:29 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
I have PH running on two systems, my primary and my backup computer.  I want to make the macros/code as transparent as possible.  I have code to determine which system it’s running on, and it makes various adjustments accordingly.  The last remaining one is to change the port for the CM11A controller.  Currently I have to manually go to PH explorer/Setup/Controllers and click “settings” and change the port number then  click “DONE”.
 
 So, I got this brain storm to do a direct SQL to automatically change the port.
 
 Let’s say I want to change the X10 controller port from 3 to 5.
 
 If I execute the following direct SQL
 Ph_sql(1," select * from ctlrparms where parm = 'port' ")
 Formula evaluates to: data(CM11A_1”,”port”,”3”,)
 Ok, all good. Port = 3 
 
 Then when I do the update:
 Ph_sql( 1, “update ctlrparms set value  = 5 where parm = 'port' " )
 Formula evaluates to: data()
 
 Seemingly all good, BUT if I go to PH explorer/Setup/Controllers and click “settings” I can see the new port of 5, but when I press “DONE” it locks PH. I have to go to the task manager to end the program.
 
 No matter what change I make, 1 to 1, 3 to 5, it locks PH tight.
 
 When I restart PH, it has the old value, not the new one. Seemingly it didn’t update/flush/write the new value.
 
 Am I doing something wrong?
 
         | 
        
       
        | Back to Top | 
         
          
         | 
        
       
       
        |   | 
       
        
         
         dhoward Admin Group 
          
  
  Joined: June 29 2001 Location: United States
 Online Status: Offline Posts: 4447
          | 
        
         
          
           | Posted: February 28 2013 at 21:49 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
gg102,
 
 Assuming the ID of your CM11A is "CM11A_1", try this formula instead:
 
 
Code: 
   
    
    
      
       
 ph_directsql("update ctlrparms set value = '5' where id = 'CM11A_1' and parm = 'port'")
  | 
       
       | 
    
    | 
 
 
 
 Hope this helps,
 
 Dave.
 
         | 
        
       
        | Back to Top | 
         
          
          
         | 
        
       
       
        |   | 
       
        
         
         gg102 Senior Member 
          
 
  Joined: January 29 2013 Location: United States
 Online Status: Offline Posts: 246
          | 
        
         
          
           | Posted: February 28 2013 at 21:52 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Dave, you d'man !
 
 That worked perfectly!
 
 Thank you
         | 
        
       
        | Back to Top | 
         
          
         | 
        
       
       
        |   |       
      | 
    
   
  |