Innov-AI
    Documentation | MentDB Weak Server
Read a SQL Database and write a no-regular text file

  • Method 1:
  • try {
    
    	sql connect "session1" {cm get "demo_cm_mysql";};
    
    	-> "TEXT" "";
    	sql parse "session1" "T" (concat "select id, name, quantity from products") {
    
    		if (< [T_quantity] 10) {
    			concat_var "[TEXT]" [_n_] ",X," [T_id] "," [T_quantity];
    		} {
    			concat_var "[TEXT]" [_n_] ",Y," [T_id] "," [T_quantity];
    		};
    	
    	};
    
    	sql disconnect "session1";
    
    	file create "data/file.txt" [TEXT];
    
    } {
    
    	try {sql disconnect "session1";} {} "[err]";
    
    } "[err]";
  • Method 2:
  • try {
    
    	sql connect "session1" {cm get "demo_cm_mysql";};
    
    	file writer_open "w1" "data/file.txt" false TEXT "utf-8";
    	
    	sql parse "session1" "T" (concat "select id, name, quantity from products") {
    
    		case
    			(< [T_quantity] 10) {file writer_add_line "w1" (concat [_n_] ",X," [T_id] "," [T_quantity] "," [T_name]);}
    			(< [T_quantity] 100) {file writer_add_line "w1" (concat [_n_] ",Y," [T_id] "," [T_quantity] "," [T_name]);}
    			{file writer_add_line "w1" (concat [_n_] ",Z," [T_id] "," [T_quantity] "," [T_name]);}
    		;
    	
    	};
    
    	file writer_close "w1";
    	sql disconnect "session1";
    
    } {
    
    	try {file writer_close "w1";} {} "[err]";
    	try {sql disconnect "session1";} {} "[err]";
    
    } "[err]";
Services     Supporters     Contact     About     Legal notice © 2024