Fraxi;
Yes you are right. I'm simplifying. I'm sorry.
I have a function based on ADSExecuteSQLDirect() that returns an array instead of a cursor with the values.
*-------------------------------------------------------------------------------------------------------------------------------
function ExecuteSQLScript( cScript, lShowProgress )
local cArea
local aStruc, i
local nCount := 1
local a := {}
local xTmp
local isGood := .f.
DEFAULT lShowProgress := .t.
  if !empty( cScript )
    AdsCacheOpenCursors( 0 )
    DBSELECTAREA(0)
    IF !ADSCreateSQLStatement("SQLarea", ADS_CDX ) //.or. !ADSVerifySQL( cScript )
TRY
      SQLArea -> ( DBCLOSEAREA() )
END
      MsgStop( "AdsCreateSqlStatement() failed with error "+ cValToChar( ADSGetLastError() ) )
      logfile( "SQLError.log", { cScript } )
    Else
      if lShowProgress
        MsgRun( "Running Script...", "Please Wait", { | oDlg | isGood := AdsExecuteSQLDirect( cScript, oDlg ) } )
      else
        isgood := ADSExecuteSQLDirect( cScript )
      endif
     Â
      if isgood
      CursorWait()
TRY
        cArea := "SQLarea"
        aStruc := (cArea)->( dbStruct() )
        a    := array( (cArea)->( lastrec() ) )
        while !(cArea)->( eof() )
          a[ nCount ] := array( len( aStruc ) ) //{}
          afill( a[nCount], " " )
         Â
          for i := 1 to len( aStruc )          Â
            a[ nCount, i ]:= iif( ( xTmp := (cArea)->( fieldGet( i ) ) ) == Nil, Blank( aStruc[ i, DBS_TYPE] ), xTmp )
          next i
         Â
          nCount++
          (cArea)->( dbSkip() )
        End
END
      Else
        logfile( "SQLError.log", { cScript } )
      ENDIF
      CursorArrow()
      aSize( a, nCount-1 )     Â
     Â
      AdsCacheOpenCursors( 0 )
      AdsClrCallBack()
      if Select( "sqlarea" ) > 0 ;SQLArea -> ( DBCLOSEAREA() ) ;endif
    Endif
  endif
Return a
So, in the previous sample, instead of using ADSExecuteSQLDirect(), I would use ExecuteSQLScript(). I was only trying to give a bird's eye view of what is possible.
Take care,
Reinaldo.