RE: Ordinal number within a table

RE: Ordinal number within a table

am 29.06.2005 14:26:25 von nishikant.x.kapoor

> > How can I execute both (a) and (b) in my perl script?
>=20
> The same way you would execute any two statements, one at a=20
> time. Something like:
>=20
> $conn->do('SET @row=3D0');
> my $sql =3D 'SELECT @row:=3D@row+1 as row, FROM=20
> WHERE ...';
> my $sth =3D $conn->prepare($sql);
> $sth->execute();
> return $sth->fetchall_arrayref( {} );

Well, that's exactly what I was looking for. Thank you sooooo much.


> You are returning an arrayref! One row in your results=20
> equals one row in your=20
> array -- in the same order! Arrays are indexed, so display=20
> data order is=20
> already built into your array. Display position =3D array=20
> position + 1. Why do=20
> you need a redundant field in each row?

The arrayref resultset, being an array, does have an index, but that is =
implicit. I need to have a separate field so that the receiver can map =
each field to some place-holder in her construct. To be more exact, I =
am using a template system that uses the received arrayref to populate =
its place-holders, and is one of them.

Thanks again,
Nishi


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules @m.gmane.org