Using DBeaver 4.0.8 against a DB2 for i database to export various resultsets
SQL Select contains variables with values set within the session
When exporting a resultset, the export uses values for the SQL variables from the database rather than the values set in the session. What's being exported is not the resultset in the Result pane.
-- Create SQL variables
CREATE OR REPLACE VARIABLE HHRlib.BegDate Date DEFAULT '2016-12-01';
CREATE OR REPLACE VARIABLE HHRlib.EndDate Date DEFAULT '2016-12-31';
-- Simple Range Query
SELECT Min(CountDate), Max(CountDate), Count(*)
FROM TcsLib.TcsRadarP
WHERE CountDate BETWEEN HHRLib.BegDate AND HHRLib.EndDate;
Select Results:
Min Date Max Date Count
2016-12-01 2016-12-31 157422
-- Change dates for SQL variables
-- SET only updates values for SQL variable within current session
SET HHRLib.BegDate = '2017-05-01';
SET HHRLib.EndDate = '2017-05-31';
Rerun Simple Range Query Results:
Min Date Max Date Count
2017-05-01 2017-05-31 160134
But when Exporting the Resultset (whether right click on SQL statement or in Result pane), the Export picks up the values for the SQL variables from the database rather than from the session, resulting in the wrong resultset being exported:
Min Date Max Date Count
2016-12-01 2016-12-31 157422
Hi,
Can you confirm that you have unchecked "open new connection(s)" in the export settings?
if it's checked, what you see is expected.
Regards
The box was checked. Unchecking "open new connection(s)" fixed my issue.
Thank you!!
Hi, Serge.
The box was checked. Unchecking the box fixed my issue.
Thank you for your help. I've closed the issue.
Regards,
Herb.
From: masebu notifications@github.com
Sent: Wednesday, June 14, 2017 5:25 AM
To: serge-rider/dbeaver
Cc: Herb Rea; Author
Subject: Re: [serge-rider/dbeaver] Wrong Resultset Exported, Export Using Wrong Values For SQL Variables (#1765)
Hi,
Can you confirm that you have unchecked "open new connection(s)" in the export settings?
if it's checked, what you see is expected.
[image]https://user-images.githubusercontent.com/19706602/27125184-bf7b787e-50f3-11e7-9895-a7c8c03883d6.png
[https://user-images.githubusercontent.com/19706602/27125184-bf7b787e-50f3-11e7-9895-a7c8c03883d6.png]
Regards
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/serge-rider/dbeaver/issues/1765#issuecomment-308375938, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AcCwBgWDGwkThEycu0HyBQ1I7kW1XeaYks5sD6cigaJpZM4N4lCx.
Most helpful comment
Hi,
Can you confirm that you have unchecked "open new connection(s)" in the export settings?
if it's checked, what you see is expected.
Regards