Innov-AI
    Documentation | MentDB Weak Server
Get a single row in JSON format from a SQL table

  • try {
    
    	sql connect "session1" {cm get "demo_cm_mysql";};
    
    	json load "keyId" (sql row "session1" (concat "select * from products where id=" (sql encode 1)));
    	json parse_obj "keyId" "/" "[key]" "[val]" {
    	
    		#Here your MQL source code ...;
    		log trace (concat [key] "=" [val]);
    	
    	};
    	
    	# Here your MQL source code to work with [name];
    	
    	sql disconnect "session1";
    
    } {
    
    	try {sql disconnect "session1";} {} "[err_sql]";
    	log trace [err]; 
    
    } "[err]";
  • #JSON return by sql row;
    "{
      \"dtcreate\": \"2018-02-15 10:00:00.0\",
      \"sale\": \"1\",
      \"quantity\": \"5\",
      \"subtype\": \"T\",
      \"price\": \"7.50\",
      \"cat\": null,
      \"name\": \"car\",
      \"weight\": \"23.4567\",
      \"id\": \"1\",
      \"type\": \"A\",
      \"desc\": \"a car ....\"
    }";
Services     Supporters     Contact     About     Legal notice © 2024