Correct SQL and Wrong Results in iReport

Dear Community, I'm trying to make a report that I call in a JSF page to generate a PDF with infos.

My query is: 

     orcamento.`id` AS orcamento_id,
     orcamento.`data_finalizacao` AS orcamento_data_finalizacao,
     orcamento.`obs` AS orcamento_obs,
     orcamento.`statusorcamento` AS orcamento_statusorcamento,
     orcamento.`valor_total` AS orcamento_valor_total,
     orcamento.`formapagamento` AS orcamento_formapagamento,
     orcamento.`prazoentrega` AS orcamento_prazoentrega,
     item_orcamento.`quantidade` AS item_orcamento_quantidade,
     item_orcamento.`valor_unitario` AS item_orcamento_valor_unitario,
     produto.`nome` AS produto_nome,
     produto.`valor_precofinal` AS produto_valor_precofinal,
     tipoproduto.`nometipo` AS tipoproduto_nometipo,
     cliente.`nome` AS cliente_nome,
     usuario.`nome` AS usuario_nome
     `orcamento` orcamento INNER JOIN `item_orcamento` item_orcamento ON orcamento.`id` = item_orcamento.`orcamento_id`
     INNER JOIN `produto` produto ON item_orcamento.`produto_id` = produto.`id`
     INNER JOIN `tipoproduto` tipoproduto ON produto.`tipo_id` = tipoproduto.`id`
     INNER JOIN `cliente` cliente ON orcamento.`cliente_id` = cliente.`id`
     INNER JOIN `usuario` usuario ON orcamento.`usuario_id` = usuario.`id`
WHERE = 9;

and when I execute this query in like Dbeaver the results is correct, but in my report doesnt.

In my report I have one parameter that is the id, I enter this parameter in report and bring infos that is not in my db.

What i am doing wrong?

danilodecanini's picture
Joined: Oct 8 2017 - 6:27am
Last seen: 5 years 11 months ago

2 Answers:

Fisrt of all did you do a test run with a hard code value ,before chaning the id to a parameter. 
You need to identify where the change in data request is occuring. 

By doing a hard coded query run in jasper you can identify if the query is returning resutls correctly. If the hard coded query is not returning data as expected, then therer is issues with your query or you are getitng data from the wrongly selected database. 

If query returned is correct, then that means you implemetnation of the parameter into the query is incorrect. Or your logic in your query is incorrect. etc. 


joseng62's picture
Joined: Dec 5 2014 - 2:43am
Last seen: 8 months 1 day ago

You haven't specified what error you're getting and which value you've replaced with a parameter.

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 4 years 3 months ago