in reply to DBI->MS SQL, optional parameters to stored procedures

Or, you can add the third argument saying if stored proc. have to treat NULL as NULL or change it to 0.
Complicated, but with constant count of args. I am afraid that there is no solution in DBI...
  • Comment on Re: DBI->MS SQL, optional parameters to stored procedures

Replies are listed 'Best First'.
Re^2: DBI->MS SQL, optional parameters to stored procedures
by Jenda (Abbot) on Nov 02, 2005 at 22:01 UTC

    Well ... this is for yet another DBIx module. Something that'd make calling MS SQL stored procedures (since that's all I want from my data access layer, thank you very much) very easy. I have finding the parameters of stored procedures and handling output parameters done, but I can't find a way to handle the optional parameters or even how to find which ones are optional :-(

    The code currently goes somewhat like this:

    package MyDB; use DBIx::LazyMethod::MSSQL; use vars qw(@ISA); @ISA = qw(DBIx::LazyMethod::MSSQL); sub new { my $class = shift; my $db = $class->SUPER::new( data_source => 'dbi:ODBC:jobodbc2', user => 'xxx', pass => 'xxx', attr => { PrintError => 0, RaiseError => 0, LongReadLen => 655 +36, 'AutoCommit' => 1 }, methods => { FetchUserInfo => { def => { adminid => 1 }, ret => '%', }, GetServerMailAddress => '$', GetFieldTitle => { def => {siteid => undef}, ret => '$' } }, ); return $db; } 1;
    and then
    use MyDB; my $db = MyDB->new(); print Dumper($db->FetchUserInfo(userid => '577')); my $email; $db->GetServerMailAddress(email => $email); print "\$email = $email\n"; my $title; $db->GetFieldTitle( fieldtype => 'I', fieldid => 11, fieldtitle => $ti +tle); print "\$title = $title\n";

    If I could at least find out what parameters are optional and what are the default values I could just call the procedures with all parameters and pass those defaults, but I can't find a way to do that apart from parsing the SQL :-(

    Jenda
    XML sucks. Badly. SOAP on the other hand is the most powerfull vacuum pump ever invented.