|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I am doing a select into a list of variables, but I don't know how to
tell if the select returns no rows, in which case I don't want to proceed. Is there a success value or other technique? Thanks! Tony |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Thu, 18 Oct 2007 08:18:51 -0700, Tony wrote:
> I am doing a select into a list of variables, but I don't know how to > tell if the select returns no rows, in which case I don't want to > proceed. Is there a success value or other technique? Some language libraries have a function for determining how many rows are returned in a data set. Others may leave you to do something like result_set = execute_mysql_query(my_query) WHILE (my_row = get_mysql_row(result_set) IS SUCCESSFUL) DO stuff in a loop DONE -- 50. My main computers will have their own special operating system that will be completely incompatible with standard IBM and Macintosh powerbooks. --Peter Anspach's list of things to do as an Evil Overlord |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Oct 18, 11:42 am, "Peter H. Coffin" <hell...@ninehells.com> wrote:
> On Thu, 18 Oct 2007 08:18:51 -0700, Tony wrote: > > I am doing a select into a list of variables, but I don't know how to > > tell if the select returns no rows, in which case I don't want to > > proceed. Is there a success value or other technique? > > Some language libraries have a function for determining how many rows > are returned in a data set. Others may leave you to do something like > > result_set = execute_mysql_query(my_query) > WHILE (my_row = get_mysql_row(result_set) IS SUCCESSFUL) > DO stuff in a loop > DONE > > -- > 50. My main computers will have their own special operating system that will > be completely incompatible with standard IBM and Macintosh powerbooks. > --Peter Anspach's list of things to do as an Evil Overlord I am in a stored procedure, so no PHP or other functions are available. Just native MySQL operations. Thanks, Tony |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
== Quote from Tony (google@sendto.org)'s article
> On Oct 18, 11:42 am, "Peter H. Coffin" <hell...@ninehells.com> wrote: > > On Thu, 18 Oct 2007 08:18:51 -0700, Tony wrote: > > > I am doing a select into a list of variables, but I don't know how to > > > tell if the select returns no rows, in which case I don't want to > > > proceed. Is there a success value or other technique? > > > > Some language libraries have a function for determining how many rows > > are returned in a data set. Others may leave you to do something like > > > > result_set = execute_mysql_query(my_query) > > WHILE (my_row = get_mysql_row(result_set) IS SUCCESSFUL) > > DO stuff in a loop > > DONE > > > > -- > > 50. My main computers will have their own special operating system that will > > be completely incompatible with standard IBM and Macintosh powerbooks. > > --Peter Anspach's list of things to do as an Evil Overlord > I am in a stored procedure, so no PHP or other functions are > available. Just native MySQL operations. Thanks, Tony what you need is a condition and a handler. the following will set a phoney sqlstate (there is one for no record found). if mysql hits that sqlstate it'll set the exit_loop to 1, you'd check that in your logic and exit accordingly and move on to the next record. DECLARE CONTINUE HANDLER FOR SQLSTATE '999999' SET exit_loop = 1; DECLARE CONTINUE HANDLER FOR SQLSTATE '939999' BEGIN statement_list END; -- POST BY: lark with PHP News Reader ;o) |
|
![]() |
| Outils de la discussion | |
|
|