Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use a data type parameter in the query function on the floor? #393

Closed
claudneysessa opened this issue Aug 24, 2020 · 5 comments
Closed

Comments

@claudneysessa
Copy link

How can I use a data type parameter in the query function on the floor?

@claudneysessa
Copy link
Author

claudneysessa commented Aug 24, 2020

Example:

Does not work

@query("""
SELECT Coleta.*,
( select sum(ItemColeta.PD_QTD)
from ItemColeta
where ItemColeta.MCO_COD = Coleta.MCO_COD
) as MCO_TOTAL
FROM Coleta
WHERE MCO_DTAGENDA <= :data ================> Does not work
and MCO_STATUS = :status
ORDER BY MCO_DTCOLETA
""")
Future<List> findStatusDataMenor(int status, String data);

This code above does not work, but if I put it directly the value works

@query("""
SELECT Coleta.*,
( select sum(ItemColeta.PD_QTD)
from ItemColeta
where ItemColeta.MCO_COD = Coleta.MCO_COD
) as MCO_TOTAL
FROM Coleta
WHERE MCO_DTAGENDA <= "2020-08-01" =====> OK
and MCO_STATUS = :status
ORDER BY MCO_DTCOLETA
""")
Future findStatusDataMenor(int status);

@mqus
Copy link
Collaborator

mqus commented Aug 24, 2020

Please elaborate. What do you mean with "does not work"? Do you get an error message?
I noticed one thing in your example though: we currently only support parameters being referenced in the same order as they're specified in the function(#224). This is being worked on in #361. So the first example might work if you use

@query("""
SELECT Coleta.*,
( select sum(ItemColeta.PD_QTD)
from ItemColeta
where ItemColeta.MCO_COD = Coleta.MCO_COD
) as MCO_TOTAL
FROM Coleta
WHERE MCO_DTAGENDA <= :data
and MCO_STATUS = :status
ORDER BY MCO_DTCOLETA
""")
Future<List> findStatusDataMenor(String data, int status);

(Btw, the Future<List> bit is also not correct but I assume that you are just omitting the details here)

@claudneysessa
Copy link
Author

Thanks for the guidance I didn't pay attention to the order of the parameters and this was the problem, thank you very much!

@claudneysessa
Copy link
Author

Please elaborate. What do you mean with "does not work"? Do you get an error message?
I noticed one thing in your example though: we currently only support parameters being referenced in the same order as they're specified in the function(#224). This is being worked on in #361. So the first example might work if you use

@query("""
SELECT Coleta.*,
( select sum(ItemColeta.PD_QTD)
from ItemColeta
where ItemColeta.MCO_COD = Coleta.MCO_COD
) as MCO_TOTAL
FROM Coleta
WHERE MCO_DTAGENDA <= :data
and MCO_STATUS = :status
ORDER BY MCO_DTCOLETA
""")
Future<List> findStatusDataMenor(String data, int status);

(Btw, the Future<List> bit is also not correct but I assume that you are just omitting the details here)

Thanks for the guidance I didn't pay attention to the order of the parameters and this was the problem, thank you very much!

@claudneysessa
Copy link
Author

Solved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants