Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Run sequential queries on one button click

New Here ,
Mar 11, 2010 Mar 11, 2010

Hello, I hope you can help me.

I have to export to excel, 20 or so queries.

What I would like to do is set the date range on a form, and then click Submit.  The submit would perform about 20 queries, one of the other and writing EACH to its own excel file.  Is this possible?

The queries are exactly the same, except for one WHERE clause.  I can pre-write the queries, all 20 of them, but how I do make them begin after the previous ends?  And what would be the best way to have these write to a file upon completion?

Thanks guys

1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 13, 2010 Mar 13, 2010

ColdFusion executes all statements in .cfm template, including queries, in sequential order (with some exceptions like cfexecute with certain attributes).

Thus, your question does not make sense to me. Can you specify a bit further?

-Fernis

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2010 Mar 13, 2010

But can you have it save the query data to file after each query is

run, all on the same page? Would you just have a separate for

each?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 13, 2010 Mar 13, 2010

I don't see how - for example - using cfspreadsheet tag to save a query to a file is any different from, say, setting a variable with a value. If you do <cfset a = 1>, you certainly don't need a new .cfm page to set <cfset b = 2>. Similarly, writing many files from many queries on the same page is something you could logically do with any language or any middleware.

I must be missing something here, since I can't see how this is a problem...

It should be pretty easy to have a loop, and parameterize both filenames and cfquery data.

Maybe if you post some code example or detailed expalanation about how and what you want to do, people can help you further.

-Fernis

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2010 Mar 13, 2010

My original post just wanted to know if this was possible. I never said it

was a problem.

I am new to CF, have a basic understanding, but when it comes to writing

files I've only had experience writing a single file from a .cfm page. I

wrap the output table in a , etc.

With that, I wanted to add more queries and more outputs. Would the logic

just be the same?

Thanks,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 13, 2010 Mar 13, 2010

Are you wanting to •save• the files (ie: to the server HDD), or do

you want to serve them to the client browser (ie: so the user can save

them to their HDD). Those are two different things. From your wording

it sounds like the former, but I suspect you want to do the latter..?

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2010 Mar 13, 2010

Yes, to my HDD. I will supply the path (%SYSTEMROOT%/reports).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 13, 2010 Mar 13, 2010

Yes, that's completely possible in one page.  You'd simply have 20 queries, and 20 CFSpreadsheet calls.  Or stick them in a

CFLoop, if possible, but either way, completely doable.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2010 Mar 13, 2010

Well, I'm using CF8 so what is the proper equivalent?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 13, 2010 Mar 13, 2010
LATEST

If .csv files are enough for you, then you can construct a variable and use cffile to save it as a .csv file.

See http://www.cflib.org/udf/CSVFormat for more.

If you really need .xls file and you don't have CF9, search Internet for "cfx_excel", "cf_excel" or "coldfusion query to excel", or use the Adobe Exchange to search for any excel related stuff for ColdFusion.

One starting point I found is http://querytoexcel.riaforge.org/ - never tried it. Hope you get lucky.

-Fernis

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources