Hi, I'm fairly new to Perl and have an issue I'd like your feedback on... here goes
I need to create a view in a Sybase database to be able to extract data from via BCP
The view needs to be created dynamically every time the code is run and needs to finish up looking like this

create view aud_extr as select * from sybsecurity..sysaudits_01 where suid in (1,8,13,20) union select * from sybsecurity..sysaudits_02 where suid in (1,8,13,20) union . .
The number of unions in the above sql depends on how many audit tables are present, hence it could be 1 or upto 8 table joins . The sysaudits_nn number increasing for each union. I can find out how many sysaudits tables are present easily enough
The issue is should I be preparing this create view statement within the Perl code (I'm using DBD::Sybase and 12.5.3 Sybase) or within a stored proc in the Sybase server ?

If it's within the Perl code what's the best way to build the string before executing it ?

I'm sure that Perl is more than capable of doing this but is it more or less efficient as executing a stored proc to do this ?
Any suggestions/comments welcome


In reply to Perl or SQL ? by Anonymous Monk

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.