On 06/02/2010 04:17 PM, newbie01 perl wrote:
> Hi Peter,
> 
> Yes, that is correct ... am referring to these commands ...
> 
> If I already have the .sql file that has all the formatting in them, is it
> okay to just run @x.sql from the Perl DBI script ...
> 
> BTW, you mentioned some "template toolkit", never heard of those ... can you
> elaborate on them or give a link reference that I can check
> 
> On Tue, Jun 1, 2010 at 10:28 PM, Peter J. Holzer <h...@wsr.ac.at> wrote:
> 
>> On 2010-05-30 17:33:39 +1200, newbie01 perl wrote:
>>> Am trying out DBI for Oracle and just want to know if for example, I need
>> to
>>> include column formatting stuff etc., is it best to just put them into a
>>> .sql file and then execute the .sql file instead of placing them in the
>> Perl
>>> DBI script?
>>
>> By "column formatting stuff" you mean commands like
>> column foo format a20
>> ?
>>
>> These are sqlplus commands, not sql commands, i.e., they are features of
>> the query tool, not the database. Consequently, they are not available
>> in perl. To format data in Perl, use Perl features, like printf,
>> formats, various templating toolkits, etc.
>>
>>        hp
>>
>> --
>>   _  | Peter J. Holzer    | Auf jedem Computer sollte der Satz Ludwigs II
>> |_|_) | Sysadmin WSR       | eingeprägt stehen: "Ein ewig Rätsel will ich
>> | |   | h...@wsr.ac.at      | bleiben, mir und andern."
>> __/   | http://www.hjp.at/ |    -- Wolfram Heinrich in desd
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.9 (GNU/Linux)
>>
>> iD8DBQFMBODFMdFfQa64PCwRAjWnAJ9OWXWMfa786KB1XIEQeFQZKZe9AwCfSMOU
>> RPGR6X8KB4QAKqUBZdx+FeI=
>> =UW1N
>> -----END PGP SIGNATURE-----
>>

Hi, newbie01 perl,

First, may I suggest you should be "bottom posting", that is, put your
words after the rest, as I'm doing.  It makes it easier for others to
scan through a post and figure out what it's all about ;-)

As Peter said, those formatting commands are a feature of the "query
tool".  That means they work in sqlplus but not necessarily anywhere
else.  And the "@filename" function is also, I believe, specific to the
"query tool".  Though it may be common as the symbol of choice in
several different tools, it is a "command" for the tool, not the DBI or DBD.

In fact, if you tried to use "@x.sql" from a DBI script, you'd get some
sort of error, since you've defined an array, @x with a concatenation
operator, dot, and a bareword: sql.

You will have to remove the formatting commands from your file, use the
"real" SQL to get data, and then format for output using one of the
tools Peter mentioned.

As for "templating toolkits", you may want to go to CPAN, search for
that name (or just "template") and study the results.

-- 
Bob McGowan

Reply via email to