Innov-AI
    Documentation | MentDB Weak Server
Generate MQL to ETL_DB_TO_DB on table

  • To generate MQL to ETL_DB_TO_DB on table:
  • Right click on the table 'apps' and select 'GEN HANDLE > DB_TO_DB'
  • script create exe "MENTDB.apps.db_to_db" false 1
      (param
      )
      "Move data from a table to another table."
    {
    	
    	#To create parameters;
    	parameter add "MENTDB.APPS.DB_TO_DB.lock" null;
    	parameter add "MENTDB.APPS.DB_TO_DB.err" "";
    	parameter add "MENTDB.APPS.DB_TO_DB.ts" "";
    	parameter add "MENTDB.APPS.DB_TO_DB.pk" "0";
    
    	
    	#Execute only if not use;
    	if (parameter lock_if_null "MENTDB.APPS.DB_TO_DB.lock" (concat "Locked by: " (who) "/" (sid))) {
    	
    		try {
    			
    			#Connection ...;
    			sql connect "session1" {cm get "MENTDB"};
    			sql connect "session2" {cm get "MENTDB"};
    			sql auto_commit "session2" false;
    			-> "[nbToCommit]" 0;
    			
    			-> "[json_result]" (sql parse "session1" "T" (concat 
    				"SELECT  
    				app_id,
    				title
    			 FROM public.apps
    			 LIMIT 0, 100;") {
    				
    				#Here your MQL code ...;
    
    				#INSERT REQUEST;
    				-> "[result]" (sql dml "session2" (concat 
    					"INSERT INTO public.apps (
    				app_id,
    				title
    			) VALUES (
    				" (sql encode [T_app_id]) " ,
    				" (sql encode [T_title]) "
    			);"
    				));
    
    				#UPDATE REQUEST;
    				-> "[result]" (sql dml "session2" (concat 
    					"UPDATE public.apps SET
    				app_id=" (sql encode [T_app_id]) " ,
    				title=" (sql encode [T_title]) " 
    			WHERE "
    				));
    
    				#DELETE REQUEST;
    				-> "[result]" (sql dml "session2" (concat 
    					"DELETE FROM public.apps WHERE "
    				));
    				
    				++ "[nbToCommit]";
    				
    				if (== [nbToCommit] 100) {
    					
    					sql commit "session2";
    					
    					-> "[nbToCommit]" 0;
    					
    				};
    			
    			});
    			
    			#End by commit;
    			sql commit "session2";
    			
    			#Disconnection ...;
    			sql disconnect "session1";
    			sql disconnect "session2";
    			
    			parameter update "MENTDB.APPS.DB_TO_DB.lock" null;
    			parameter update "MENTDB.APPS.DB_TO_DB.err" "";
    			parameter update "MENTDB.APPS.DB_TO_DB.ts" "";
    			
    			"OK"
    			
    		} {
    			
    			parameter update "MENTDB.APPS.DB_TO_DB.lock" null;
    			parameter update "MENTDB.APPS.DB_TO_DB.err" [err];
    			parameter update "MENTDB.APPS.DB_TO_DB.ts" (date systimestamp);
    		
    			#Close the connection;
    			try {sql disconnect "session1"} {} "[sub_err]";
    			try {sql disconnect "session2"} {} "[sub_err]";
    			
    			#Generate an error;
    			exception (1) ([err]);
    			
    		} "[err]";
    	
    	} {
    		
    		parameter get value "MENTDB.APPS.DB_TO_DB.lock";
    		
    	}
    	
    } "Return nothing.";
  • Update the script and save:
  • Execute buttons
Services     Supporters     Contact     About     Legal notice © 2024