Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Test if a dynamic query returns 0 results

Question
Tom Bruce · May 30, 2022

Test if a dynamic query returns 0 results

Hi, what’s the best way to check if your query return 0 records?

If $$$ISOK(sc) 	
    		{
   	   		 	Set tResult = sqlStatement.%Execute()
   	    
    			WHILE tResult.%Next()
    			{
					set tRecords = tResult.%ROWCOUNT
   		        }

				if (tRecords = "")
				{
					write "no records" 
				}
			}


 

 

 
 
#ObjectScript #SQL #InterSystems IRIS
Product version: IRIS 2021.2

Source URL:https://community.intersystems.com/post/test-if-dynamic-query-returns-0-results