B4J Question Using dbutils

Discussion in 'B4J Questions' started by kelvo01, Jun 19, 2019.

Similar threads

B4J Library [B4X] DBUtils 2
B4J Tutorial DBUtils Example
B4J Tutorial TableView Tutorial
B4J Question DBUtils ExecuteMemoryTable
B4J Question SQLlite - dbutils problem
  1. kelvo01

    kelvo01 Member Licensed User

    How to execute a query. obtain some rows of results and parse field results?

    ...
    ExecuteMemoryTable( selet *fom

    Do While NOT EOF ...
    Loop

    the exact code ? an example ?
     
  2. DonManfred

    DonManfred Expert Licensed User

  3. kelvo01

    kelvo01 Member Licensed User

    A mean a short way to make this with dbutils 2


    Code:
    cerca="SELECT MVNUMDOC, MVALFDOC, MVDATDOC, MVTIPDOC, MVCODMAG, CLCODCLI, CLRAGSOC, MVTOTDOC "
        cerca=cerca&
    " FROM MOVIME LEFT JOIN CLIFOR ON MVCOD_CF = CLCODCLI "
        cerca=cerca&
    " WHERE MVTIPDOC='DT' AND MVTPCLFO='1' AND MV__ANNO='2019' "
        cerca=cerca&
    " ORDER BY MVALFDOC, MVNUMDOC "'limit 100 "
        
        
    Dim rs As ResultSet

        rs = gSQL.ExecQuery(cerca)
        
    Do While rs.NextRow
            
    Log(rs.GetString("MVALFDOC"))
        
    Loop
        rs.Close
     
  4. DonManfred

    DonManfred Expert Licensed User

    Use ExecQuery2 and SmartStringLiteral. This will make it much easier to build the query.
     
    OliverA and jimmyF like this.
  5. universengo

    universengo Member

    You can replace the "cerca=cerca&" by using "& _" as below
    Code:
    cerca="SELECT MVNUMDOC, MVALFDOC, MVDATDOC, MVTIPDOC, MVCODMAG, CLCODCLI, CLRAGSOC, MVTOTDOC " & _
       
    " FROM MOVIME LEFT JOIN CLIFOR ON MVCOD_CF = CLCODCLI " & _
       
    " WHERE MVTIPDOC='DT' AND MVTPCLFO='1' AND MV__ANNO='2019' " & _
       
    " ORDER BY MVALFDOC, MVNUMDOC "'limit 100 "
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Better like this:
    Code:
    cerca=$"SELECT MVNUMDOC, MVALFDOC, MVDATDOC, MVTIPDOC, MVCODMAG, CLCODCLI, CLRAGSOC, MVTOTDOC 
       FROM MOVIME LEFT JOIN CLIFOR ON MVCOD_CF = CLCODCLI 
       WHERE MVTIPDOC='DT' AND MVTPCLFO='1' AND MV__ANNO='2019'
       ORDER BY MVALFDOC, MVNUMDOC"$
     
    OliverA and klaus like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice