Start a new topic

Create loop to export data by group

[This topic is migrated from our old forums. The original author name has been removed]

I have an @export statement which I create a file for a specific group. Instead of copy and paste the instructions for each group I would like to be able to automate the process and runs it for each group. Example: @export on; @export set filename="F:\Monthly Reports\10245\Detail_10245.xls" ExcelTitle="Claims Data" format="xls"; SELECT * FROM Claims where group_ID='10245' ; I need to export each file to the folder that has the same name of the group.

[This reply is migrated from our old forums.]

Re: Create loop to export data by group
Hi Elaine, You can do this by combining the DbVisualizer command line interface with the scripting features of your OS. Please see the Users Guide for an example: http://confluence.dbvis.com/display/UG91/Command+Line+Interface#CommandLineInterface-CombiningOSscripts,thecommandlineinterfaceandDbVisualizervariables This forum post also discusses an example of doing this on Windows: http://www.dbvis.com/forum/thread.jspa?threadID=4782 Best Regards, Hans
[This reply is migrated from our old forums. The original author name has been removed]

Re: Create loop to export data by group
I am not familiar with that programming but in the example for Windows, ┬┐do I will need to enter the value every time for each group? what I would like to be able is for example that I have fixed the Group IDs . Let's say: Group ID 124 154 321 457 Then to have the instruction that the export runs for group 124, save in folder name "124" and then goes to the next group 154 and do the same. . @export on; @export set filename="F:\Monthly Reports\124\Detail_124.xls" ExcelTitle="Claims Data" format="xls"; SELECT * FROM Claims where group_ID='124''
[This reply is migrated from our old forums.]

Re: Create loop to export data by group
Hi Elaine, You should be able put the group IDs in a file and use a BAT file that calls the dbviscmd command with input from the file using the Windows FOR commands once for each group ID, and use DbVisualizer variables in the SQL for where the group ID should be inserted. I'm afraid we cannot help you with the exact syntax for the BAT file. You need to ask someone experienced with Windows BAT files for help. The Users Guide section and the forum post I pointed you to earlier should be enough to see how to integrate with the DbVisualizer command line interface. Best Regards, Hans
[This reply is migrated from our old forums. The original author name has been removed]

Re: Create loop to export data by group
Thank you for your advice and rapid response. Very appreciated!