PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → WB19 - passing variable to report - SQl doesn't recognize it
WB19 - passing variable to report - SQl doesn't recognize it
Iniciado por guest, 03,ene. 2015 17:24 - 5 respuestas
Publicado el 03,enero 2015 - 17:24
Hi -

I pass a variable to a report like this:
PROCEDURE RPT_BirthdayNote(grpar_Month, grpar_Header, grpar_Message, grpar_Image)

Then I try to use it in a SQL statement like this:
grsSql is string = [
SELECT
*
FROM
gpsdContacts
WHERE
bActiveMembershipFlag = 1
AND
WL.DateToString(dDOB,'MMMM') = grpar_Month
]

HExecuteSQLQuery(grsdDataSource,grsSql)

And the Execute fails, says it doesn't recognize the grpar_Month variable. What is the correct syntax for this?
Publicado el 03,enero 2015 - 19:02
Hi,
you can use sql in reports i guess but I never do that.

I create the query. Make it availeble for reports and queries. Add the parameters to the query then in the report:

Procedure reportname ( passedvar1 , passedvar2 )

query.param1 = passedvar1
query.param2 = passedvar2
hexecutequery ( queryname, hdefault)

If you do it this way you can test your querie outside the report to see if it does what it is supposed to do .

Regards

Allard
Publicado el 03,enero 2015 - 19:34
Hi Joel
WL.DateToString(dDOB,'MMMM') = '%1' ] grsSQL = StringBuild(grsSQL,grpar_Month) HExecuteSQLQuery(grsdDataSource,grsSql)
David
Publicado el 03,enero 2015 - 21:26
Hi and thank you Allard -

I have to use SQl b/c I'm not using an Analysis - I've created a bunch of Data Sources so I don't need to have an analysis in every project. That way - I have one project with an analysis and just update that one if need be. Don't have to open everyone and update each. It was getting to be a pain.

I took a bit to figure out how to create a report with the SQL data source built in, but now that I've got it, it's all pretty straight forward.

Thanks and be welL!

Joel
Publicado el 03,enero 2015 - 21:45
Thanks David -

I knew that! Just haven't used it enough to keep it in memory.

Thanks!

J
Publicado el 03,enero 2015 - 22:16
Hi,

I use queries in reports quite extensively and implement them as per Allard's description.