We had a homegrown DBI here and the boss mandated that we swap it out in place of DBI. However, all existing code had to work without changes. So far, so good. However, we also had to make a feature extension. Before, when calling stored procedures, there was no way to pass in a set of scalars to be modified as OUT parameters. So stored procs could only be called with IN parms.
So, the whole idea was before people would do:
And the only way to extend this with functionality for dealing with new OUT parms without breaking any existing code was to "earmark" one of the scalars. And the best way to do that is for that scalar to be an array ref. Thus to make a call to a stored proc and expect OUT parms to be bound is now:my $retval = $sth->exec_sp($val1, $val2);
So, then all I do is run through @_ and splice out any scalar which is an array ref and consider those values as the ones to do a DBI bind_param_inout() on.my $retval = $sth->exec_sp($val1, $val2, [ \($outval1, $outval2) ]);
Ok, so now my earlier unexplained software engineering rationale is now explained.
2001-04-15 Edit by Corion : Moved to Meditations
In reply to Non-invasive API extension by use of array refs by princepawn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |