[htmltmpl] Ordinal number within a table
Brought to you by:
samtregar
From: Kapoor, N. <nis...@xc...> - 2005-06-28 17:20:51
|
I am looking to populate my template loop by assigning it the entire = resultset in one shot as follows: =20 my $str =3D "SELECT \@row:=3D\@row+1 as row, <fields> FROM <tables> = WHERE ..."; my $sth =3D $conn->prepare($st); $sth->execute(); my $dataArr =3D $sth->fetchall_arrayref( {} ); $template->param(dataLoop =3D> $dataArr); I am getting NULL for row. The solution suggested by following thread = does it for command line, but I need to run it from inside my perl = script. http://lists.mysql.com/mysql/185626 a) SET @row=3D0; b) SELECT (@row:=3D@row+1) AS row, ename, empno FROM emp ORDER BY empno; And I don't know how to run both (a) and (b) together in one statement. = Running just (b) is what is producing NULL for row. Thanks for your help, Nishi |