*FUNCTION nav_vytvor_cursor
PARAMETERS menotriedy, menocursora, menotabulky, sqlprikaz, menopoli, menoupdatov, menokluca, menoschemy
IF m.issql
    DO open_database
ELSE
    IF DBUSED("food600")
        SET DATABASE TO food600
        m.boladb=.T.
    ELSE
        m.boladb=.F.
        OPEN DATABASE (m.gcpri_path+"views\food600") SHARED
    ENDIF
ENDIF
IF VARTYPE(m.navconnection)<>"N"  
    PUBLIC navconnection
    m.navconnection=SQLCONNECT("Navision")
ELSE 
    IF m.navconnection>0
        TRY 
            USE navision_test_spojenia IN 0 ALIAS navtest
            USE IN navtest
        CATCH
            m.navconnection=-1
        ENDTRY 
        IF m.navconnection<0
            m.navconnection=SQLCONNECT("Navision")
        ENDIF 
    ENDIF 
ENDIF 
IF m.navconnection > 0
    lobj=IIF(TYPE('THISFORM')='O',THISFORM,_SCREEN)
    lalmeno=m.menocursora
    IF TYPE('lobj.'+lalmeno)<>'O'
        lobj.ADDPROPERTY(lalmeno)
    ELSE
        lobj.&lalmeno=.NULL.
    ENDIF
    lobj.&lalmeno= CREATEOBJECT(menotriedy)
    lobj= lobj.&lalmeno
    lobj.SELECTCMD=m.sqlprikaz
    lobj.ALIAS=m.menocursora
    lobj.DATASOURCE=m.navconnection
    lobj.DATASOURCETYPE='ODBC'
    lobj.FETCHMEMO=.T.
    lobj.FETCHASNEEDED=.F.
    lobj.FETCHSIZE=-1
    lobj.MAXRECORDS=-1
    lobj.allowinsert=.t.
    lobj.allowupdate=.t.
    lobj.allowdelete=.t.
    lobj.USECURSORSCHEMA=.T.
    lobj.sendupdates=.t.
    lobj.BatchUpdateCount=1
    lobj.CompareMemo=.T.
    lobj.Prepared=.F.
    lobj.AllowSimultaneousFetch=.F.
    lobj.UpdateType=1
    lobj.UseMemoSize=255
    lobj.Tables=m.menotabulky
    lobj.keyfieldlist=m.menokluca
    lobj.WhereType=3
    lobj.CURSORSCHEMA=m.menoschemy
    lobj.UpdateNameList=m.menoupdatov
    lobj.UpdatableFieldList=m.menopoli
    m.vysledok=lobj.CURSORFILL(.t.,.f.)
*!*        IF NOT ip_bez_hada
*!*            lsnake.RELEASE()
*!*        ENDIF
    IF m.vysledok
        SELECT (m.menocursora)
    ELSE
        =AERROR(chybapole)
        =MESSAGEBOX("SQL Chyba"+CHR(10)+chybapole(2),64)
        IF ".FXP"$UPPER(SYS(16,0))
            DO FORM ca_error WITH m.sqlprikaz,m.menoalias,m.menoschemy
        ENDIF
    ENDIF
ELSE
    m.vysledok=.F.    
ENDIF
RETURN m.vysledok    
