Hi, I'm just trying out Perl with the DBD::Sybase module nad cannot figure out whether it's possible or how to do this. I am a perl newcomer so forgive me if this is a trivial question.

I want to be able to put this statement into the prepare but don't know how to get DBD::Sybase to handle the delare bits ?
declare @name char(30)
declare @uid int
select @name=name, @uid=uid from $database..sysusers where suid = $suid
if (@name != null) exec $database..sp_dropuser @name else if exists (select 1 from $database..sysalternates where suid = $suid)
exec $database..sp_dropalias $loginname

Just sticking the whole select in a prepare doesn't work e.g.

$database="testdb"; $suid=1234; $loginname="joe"; $sth=$dbh->prepare("declare \@name char(30) declare \@uid int selec +t \@name=name, \@uid=uid from $database..sysusers where suid = $suid if (\@name != null) exec $database..sp_dropuser \@name else +if exists (select 1 from $database..sysal ternates where suid = $suid) exec $database..sp_dropalias $loginname") +; $sth->execute;
Any help appreciated

In reply to DBD Sybase and declare 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.