On Wed 13 Feb 2002 20:07, Jonathan Leffler <[EMAIL PROTECTED]> wrote:
> On Wed, 13 Feb 2002, H.Merijn Brand wrote:
> >On Wed 13 Feb 2002 02:02, Jonathan Leffler <[EMAIL PROTECTED]> wrote:
> >> -The next thing is you really execute the statement. Note that you must
> >> -prepare the attributes NUM_OF_FIELDS, NAME, ... when the statement is
> >> -successfully executed if you have not already done so: They may be used even
>before a potential
> >> -I<fetchrow>. In particular you have to tell DBI the number of fields,
> >> -that the statement has, because it will be used by DBI internally.
> >> +The next thing is you really execute the statement.
> >> +Note that you must prepare the attributes NUM_OF_PARAMS, NUM_OF_FIELDS,
> >> +NAME, etc when the statement is successfully executed if the driver has
> >> +not already done so.
> >> +They may be used even before a potential I<fetchrow>.
> >> +In particular you have to tell DBI the number of fields, that the
> >> +statement has, because it will be used by DBI internally.
> >
> >Maybe mention that these attributes might act different on positional
> >parameters and returned values. For example in the DEC port of DBD-Unify,
> >accessing the NAME field of positional parameters dumps core, where it works
> >fine in the returned values. This is due to the database, not the DBD program.
> >I've tested that with stand-alone code which also fails. (I have no DEC
> >machines anymore, so I cannot test newer releases)
> >
> >Unify might be the odd one out here, but as this is aguideline to new DBD
> >authors (and a reference to existing DBD authors that want to update their
> >drivers to the latest DBI), it might be worth mentioning.
>
> I need some clarification here...
>
> Positional parameters = 'input parameters'?
> That is, positional parameters are the values supplied to
> the execute statement for placeholders?
Yes
> Return values = 'output parameters'?
> That is, the return values are the values in the select-list
> of a SELECT statement?
Yes.
> Under Informix, the input parameters do not have names at all. I
> thought the $sth->{NAME} stuff only applied to the output parameters.
DBD::Unify supports for this is based on E/SQL, which makes no difference in
the documentation among input (positional) or output parameters, but as the
code shows:
/* for output fields */
int dbd_fld_describe (SV *dbh, imp_sth_t *imp_sth, int num_fields)
{
register imp_fld_t *f;
register int i;
dbg (3, "DBD::Unify::fld_describe %s (%d fields)\n", o_sql_nm, num_fields);
unless (num_fields > 0 &&
(imp_sth->fld = (imp_fld_t *)calloc (num_fields, sizeof (imp_fld_t))))
return (0);
for (fix = 1; fix <= num_fields; fix++) {
f = &imp_sth->fld[fix - 1];
EXEC SQL
GET DESCRIPTOR :o_sql_nm
VALUE :fix
:ftp = TYPE,
:fln = LENGTH,
:fpr = PRECISION,
:fic = INDICATOR,
:fsc = SCALE,
:fnl = NULLABLE,
:fnm = NAME;
dbg (3, " After get, sqlcode = %d\n", SQLCODE);
unless (sqlError (dbh))
return (0);
/* for input fields */
int dbd_prm_describe (SV *dbh, imp_sth_t *imp_sth, int num_params)
{
register imp_fld_t *f;
register int i;
dbg (3, "DBD::Unify::prm_describe %s (%d params)\n", i_sql_nm, num_params);
unless (num_params > 0 &&
(imp_sth->prm = (imp_fld_t *)calloc (num_params, sizeof (imp_fld_t))))
return (0);
for (fix = 1; fix <= num_params; fix++) {
f = &imp_sth->prm[fix - 1];
EXEC SQL
GET DESCRIPTOR :i_sql_nm
VALUE :fix
:ftp = TYPE,
:fln = LENGTH,
:fpr = PRECISION,
:fic = INDICATOR,
:fsc = SCALE,
:fnl = NULLABLE/*, Core dump on OSF/1 & Solaris
:fnm = NAME */;
unless (sqlError (dbh))
return (0);
No name support for paramaters.
> Am I missing something? How do you get at the names of the positional
> parameters in DBI? Which DBMS provide names for the positional
> parameters? Given that some (possibly old) variants on preparse()
> expect :name notation to mark a placeholder, I can see that you could
> derive a name for such parameters. Informix does not support that
> notation, and has a separate meaning for the syntactic fragment
> (dbase@server:owner.table or dbase:table or dbase:owner.table) so it is
> not feasible to have DBI add such support for DBD::Informix.
>
> --
> Jonathan Leffler #include <disclaimer.h>
> STSM, Informix Database Engineering, IBM Data Management Solutions
> Phone: +1 650-926-6921 Tie-line: 630-6921
> Email: [EMAIL PROTECTED] ([EMAIL PROTECTED])
> Notes ID: Jonathan Leffler/Menlo Park/IBM@IBMUS
> Guardian of DBD::Informix v1.00.PC1 -- http://dbi.perl.org
> *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
> Please update your address book to use [EMAIL PROTECTED] because
> [EMAIL PROTECTED] will not work starting 2002-07-01. Expect
> slower responses because I can't use Lotus Notes as fast as Unix
> email. One day, this signature will shrink!
--
H.Merijn Brand Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using perl-5.6.1, 5.7.1 & 630 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.022 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/