B4J Library SQL: Simplyfying Calling Stored Procedures

Discussion in 'B4J Libraries & Classes' started by keirS, Nov 17, 2016.

  1. victormedranop

    victormedranop Well-Known Member Licensed User

    try this
    Code:
    Sub CursorToLog2(oCursorToLog As ResultSet)
        
    Dim iRowCount As Int
        
    Dim iColumnCount As Int
        
    Log(" ")
        
    Do While oCursorToLog.NextRow
            
    For iColumnCount = 0 To oCursorToLog.ColumnCount -1
                
    'Log(oCursorToLog.GetColumnName(iColumnCount) & ": " & oCursorToLog.GetString2(iColumnCount))
       Log(oCursorToLog.GetString("CodIdis"))
            
    Next
            
    Log("  ")
        
    Loop
    End Sub
    but the result wan

    10203364
    10203364
    10203364
    10203364
    10203364
    10203364
    10203364
    10203364
    10203364
    10203364

    all colums with the real data. that 10203364 have to be the return but not an all result just CodIdis.

    victor
     
  2. victormedranop

    victormedranop Well-Known Member Licensed User

    For me its working I just have to take the first value and use it.
    but this is an amazing library.

    Victor
     
  3. keirS

    keirS Well-Known Member Licensed User

    You have the code in the wrong place. You should have:

    Code:
    Sub CursorToLog2(oCursorToLog As ResultSet)
        
    Dim iRowCount As Int
        
    Dim iColumnCount As Int
        
    Log(" ")
        
    Do While oCursorToLog.NextRow
            
    'For iColumnCount = 0 To oCursorToLog.ColumnCount -1
                'Log(oCursorToLog.GetColumnName(iColumnCount) & ": " & oCursorToLog.GetString2(iColumnCount))
            'Next
              Log(oCursorToLog.GetString("CodIdis"))
              
    Log(oCursorToLog.GetString("Nombre"))
              
    'lots more logs
            Log("  ")
        
    Loop
    End Sub
    [/code
     
    joulongleu and victormedranop like this.
  4. victormedranop

    victormedranop Well-Known Member Licensed User

    You were absolutely right.
    always was working, was a log that confuse me. I remove all log() and
    as expected.

    thanks.

    great job, great lib!!!!!

    Victor
     
  5. XbNnX_507

    XbNnX_507 Active Member Licensed User

    Hi, i know this thread is quiet old but i think this question should be of help for those using OracleDatbase...
    is it possible to return a resulset Type ?
    Code:
    MYSQLProcedure.AddOutputParameter(2,MYSQLProcedure.SQLINTEGER) ' <- MYSQLProcedure.SQLRESULSET ? REF CURSORS
     
    Last edited: Apr 13, 2019
  6. keirS

    keirS Well-Known Member Licensed User

    Yes. Both the samples return result sets.
     
  7. XbNnX_507

    XbNnX_507 Active Member Licensed User

    They indeed return a resulset set. but i don't find the MYSQLProcedure.SQLRESULSET type in your library.
    Code:
    MYSQLProcedure.AddOutputParameter(2,MYSQLProcedure.SQL_CURSOR) <- here
    See i'm not returning a integer, nor float, nor string... i'm returning a cursor...
     
  8. keirS

    keirS Well-Known Member Licensed User

    A result set is retrieved by calling FetchResultSet. It is not defined as an output parameter. Parameters are used for returning primitive types.
     
  9. XbNnX_507

    XbNnX_507 Active Member Licensed User

    That's the case with Mariadb, Mysql...
    With Oracle ( which i'm using ) i can return a cursor... Actually i need to return a cursor if need to call FetchResulset.
     
  10. keirS

    keirS Well-Known Member Licensed User

    That's not possible with this library. It's not generic JDBC. It appears it is an extension to JDBC that is specific to the Oracle driver..
     
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