I'm curious about your setup. You mention a GUI where a user "drags" column names from one side of the window to the other, placing them in a desired order, and then you say the result of this selection is sent to a CGI script, which would suggest that the GUI is actually a web browser.

In any case, if the user's job is simply to select from a finite set of column names and put the selected items in a chosen order, the "dynamic SQL" part seems pretty easy, because you have a constant statement frame that starts with SELECT ends with  FROM my_table [WHERE whatever...]", and has potentially two slots to be filled in by the user:

You already have the set of column names and their ordering provided as CGI parameters, so just put those together with the rest of the query statement. If that's giving you trouble, post some code to show us what kind of problem you are having.

As for the XML generation part, it looks like XML::Generator might not be the right tool for your job here, because it seems to assume that the caller wants to use function calls as nodes in the XML tree.

I think you want something that will generate XML from a hash structure (which can easily be built from the data you get after executing your dynamic select statement) -- look at XML::Simple instead. Again, if you have trouble with that, post some code and sample data, or else our help will be limited to generalities or poor examples.


In reply to Re: Building SQL Query on the fly by graff
in thread Building SQL Query on the fly by hallikpapa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.