pass parameter to an extraction

4 posts / 0 new
Last post
ortizmario6025@...
Offline
Joined: 09/03/2021 - 11:54
pass parameter to an extraction

How can I pass parameters or arguments to an extraction of this type.
the part in bold are the months of a date entered in the form
Sub Main
Call DirectExtraction()'FISA.TPLA_HISDAT.IMD
End Sub
 
 
' Datos: Extracción directa
Function DirectExtraction
Set db = Client.OpenDatabase("FISA.TPLA_HISDAT.IMD")
Set task = db.Extraction
task.IncludeAllFields
dbName = "xxxxxxxx.IMD"
task.AddExtraction dbName, "", " HIS_MES_FECHA_FECHA_  >= ""02 ""  .AND.  HIS_MES_FECHA_FECHA_ <=""03 ""  "
task.PerformTask 1, db.Count
Set task = Nothing
Set db = Nothing
Client.OpenDatabase (dbName)
End Function

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

You can do this in two ways.


Sub Main
	Dim input1 As String
	Dim input2 As String
	
	input1 = "02"
	input2 = "03"

	task.AddExtraction dbName, "", " HIS_MES_FECHA_FECHA_  >= """ & input1 & """  .AND.  HIS_MES_FECHA_FECHA_ <=""" & input2 & """"

End Sub

or the second way doesn't screw up the colouring in the editor.


Sub Main
	Dim input1 As String
	Dim input2 As String
	
	input1 = "02"
	input2 = "03"

	task.AddExtraction dbName, "", " HIS_MES_FECHA_FECHA_  >= " & Chr(34) &  input1 & Chr(34) & "  .AND.  HIS_MES_FECHA_FECHA_ <=" & Chr(34) & input2 & Chr(34)

End Sub
ortizmario6025@...
Offline
Joined: 09/03/2021 - 11:54

Thank you,
but I have a problem when passing the parameters, because I am passing 4, two dates, and the two months of both dates and they are fine, but when arriving at the extraction there is a compile error that does not detail well. I'll send an example to see if you can illustrate me. maybe the argument is wrong? or something is missing, because in the import odbc if it works with the date.
 
Sub Main
MsgBox " date.....  1..."   & arg1
MsgBox " date ...... 2..."  & arg2
MsgBox "month 1...."  & arg3
MsgBox " month 2...... " & arg4
Call DirectExtraction()'FISA.TPLA_ACCRUAL.IMD
End Sub
' Datos: Extracción directa
Function DirectExtraction
                Set db = Client.OpenDatabase("FISA.TPLA_ACCRUAL.IMD")
                Set task = db.Extraction
                task.IncludeAllFields
                dbName = "prueba.IMD"
                task.AddExtraction dbName, "", " ACC_MES_FECHA_FECHA  >= ""& arg3 &""  .AND.  ACC_MES_FECHA_FECHA  <= ""& arg4 &"""
                task.PerformTask 1, db.Count
                Set task = Nothing
                Set db = Nothing
                Client.OpenDatabase (dbName)
 
End Function
 
 

ortizmario6025@...
Offline
Joined: 09/03/2021 - 11:54

!!!ohhhh!! 
I already found the problem