Sub ActualizarTJornada
Dim SO,SR,SP As SQL
Dim CO,CR,CP As Cursor
If SO.IsInitialized = False Then
SO.Initialize(File.DirDefaultExternal, "l4pro.sql", False)
End If
If SR.IsInitialized = False Then
SR.Initialize(File.DirDefaultExternal, "l4pro.sql", False)
End If
If SP.IsInitialized = False Then
SP.Initialize(File.DirDefaultExternal, "l4pro.sql", False)
End If
CP = SP.ExecQuery("SELECT * FROM PrediccionServicios")
If CP.RowCount > 0 Then
For i = 0 To CP.RowCount-1
CP.Position = i
CO = SO.ExecQuery("SELECT * FROM ServOrdinarios WHERE NumServicio = '"&CP.GetString("Servicio")&"'")
If CO.RowCount > 0 Then
'/////////////////
Else
CR = SR.ExecQuery("SELECT * FROM ServReducidos WHERE NumServicio = '"&CP.GetString("Servicio")&"'")
If CR.RowCount > 0 Then
'//////
End If
End If
Next
End If
CO.Close
CR.Close
CP.Close
End Sub
Sub ActualizarTJornada
Dim SO As SQL
Dim CO,CR,CP As Cursor
If SO.IsInitialized = False Then
SO.Initialize(File.DirDefaultExternal, "l4pro.sql", False)
EndIf
CP = SO.ExecQuery("SELECT * FROM PrediccionServicios")
If CP.RowCount > 0 Then
For i = 0To CP.RowCount-1
CP.Position = i
CO = SO.ExecQuery("SELECT * FROM ServOrdinarios WHERE NumServicio = '"&CP.GetString("Servicio")&"'")
If CO.RowCount > 0Then
'/////////////////
Else
CR = SO.ExecQuery("SELECT * FROM ServReducidos WHERE NumServicio = '"&CP.GetString("Servicio")&"'")
If CR.RowCount > 0Then
'//////
EndIf
EndIf
Next
EndIf
CO.Close
CR.Close
CP.CloseEnd Sub
Many thanks eps!
You know, I am a baby with nappies as programmer.
I thought I need to define or declare three sqls and three Cursors but now I know the correct procedure.
Thank youuuu!
Best regards
Espinosa
If I need to read only a column or two
No problemWe all have to start somewhere. Do the changes I suggested make a difference?
I think there are a few other improvements that could be made to the code, but I'm slightly unsure of what you are attempting to achieve.
Dim sSQL As SQL
Dim CO,CR,CP As Cursor
Dim P As Phone
Dim P2 As PhoneWakeState
If sSQL.IsInitialized = False Then
sSQL.Initialize(File.DirDefaultExternal, "l4pro.sql", False)
End If
CP = sSQL.ExecQuery("SELECT * FROM PrediccionServicios")
If Activity.Width > Activity.Height Then
P.SetScreenOrientation(0)
Else
P.SetScreenOrientation(1)
End If
P2.KeepAlive(True)
ProgressDialogShow("Un momento por fa")
If CP.RowCount > 0 Then
For i = 0 To CP.RowCount-1
DoEvents
CP.Position = i
CO = sSQL.ExecQuery("SELECT * FROM ServOrdinarios WHERE NumServicio = '"&CP.GetString("Servicio")&"'")
If CO.RowCount > 0 Then
'/////////////////
'sSQL.ExecNonQuery("UPDATE PrediccionServicios set TJornada = Null, otracolumna = '3'")
Else
CR = sSQL.ExecQuery("SELECT * FROM ServReducidos WHERE NumServicio = '"&CP.GetString("Servicio")&"'")
If CR.RowCount > 0 Then
'//////
End If
End If
Next
End If
CO.Close
CR.Close
CP.Close
sSQL.Close
P.SetScreenOrientation(-1)
P2.ReleaseKeepAlive
ProgressDialogHide
For i = 0 To CP.RowCount-1
DoEvents
CP.Position = i
CO = sSQL.ExecQuery("SELECT * FROM ServOrdinarios WHERE NumServicio = '"&CP.GetString("Servicio")&"'")
If CO.RowCount > 0 Then
'/////////////////
'sSQL.ExecNonQuery("UPDATE PrediccionServicios set TJornada = Null, otracolumna = '3'")
Else
CR = sSQL.ExecQuery("SELECT * FROM ServReducidos WHERE NumServicio = '"&CP.GetString("Servicio")&"'")
If CR.RowCount > 0 Then
'//////
End If
CR.Close
End If
CO.Close
Next
Dim NumberOfRecords As Int
NumberOfRecords = SQL1.ExecQuerySingleResult("SELECT count(_id) FROM <table>")
From the code you've posted though, you don't need a cursor at all. You do a select all, then check the Rowcount, you could just do something like this :
B4X:Dim NumberOfRecords As Int NumberOfRecords = SQL1.ExecQuerySingleResult("SELECT count(_id) FROM <table>")
?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?