RE: Ordinal number within a table

"Kapoor, Nishikant" <[email protected]>
Newsgroups gmane.comp.db.mysql.perl,gmane.comp.db.mysql.general
Message-ID <B4448B75FF74124ABB5793D8BFBEEA3901C13CAD@exccpgo04.corp.xcelenergy.com>
>  > How can I execute both (a) and (b) in my perl script?
> 
> The same way you would execute any two statements, one at a 
> time.  Something like:
> 
>    $conn->do('SET @row=0');
>    my $sql = 'SELECT @row:=@row+1 as row, <fields> FROM 
> <tables> WHERE ...';
>    my $sth = $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 
> equals one row in your 
> array -- in the same order!  Arrays are indexed, so display 
> data order is 
> already built into your array.  Display position = array 
> position + 1.  Why do 
> 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 <row> 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/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.