This discussion is archived
2 Replies Latest reply: Nov 19, 2012 9:30 PM by vansul RSS

Exporting query result set into CSV file using Forms

864019 Newbie
Currently Being Moderated
Hi ,
My requirement is

-> I need to create a form where I have a Multi line text box and two button.
-> When I enter a query in text box and click on Execute button, It should execute a select query.
-> After execution, Result set needs to be exported into an Excel file.

Please give a hint how to do this????


Thanks,
maddy
  • 1. Re: Exporting query result set into CSV file using Forms
    Christian Erlinger Guru
    Currently Being Moderated
    -> After execution, Result set needs to be exported into an Excel file.
    What is it now? A CSV or a XLS(X) file?

    You should take a look at exec_sql and text_io (CSV) or ole2 (XLS) (or their CLIENT_ counterparts when using a web-based version). Search your forms builder manual and/or the forums on how to use them.

    Note that the webutil client_xyz functions are significantly slower then the server implementations, so if you are on webforms you might think about generating the files on the server and transfer them to the client.

    cheers
  • 2. Re: Exporting query result set into CSV file using Forms
    vansul Pro
    Currently Being Moderated
    as you are using text item to write SQL query by the user
    so for that you need to use the exec_sql package to parse the text items query and get definitions and values of the columns being
    resulted in the result set of the query.
    once your query is execute to the desired connection then you need to use fetch the result to the CSV file by use of the TEXT_io package
    which will open the text file with .csv extension and you have to pass the each line to that text file with comma separated values as "ss","rr" etc.
    or you can use the ole2 package to call the excel application and then fetch the data of exe_sql query to that.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points