PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Select Into Question for Stored Procedure
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Select Into Question for Stored Procedure

Réponse
 
LinkBack Outils de la discussion
Vieux 18/10/2007, 17h18   #1
Tony
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Select Into Question for Stored Procedure

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

  Réponse avec citation
Vieux 18/10/2007, 17h42   #2
Peter H. Coffin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Select Into Question for Stored Procedure

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
  Réponse avec citation
Vieux 18/10/2007, 18h57   #3
Tony
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Select Into Question for Stored Procedure

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

  Réponse avec citation
Vieux 18/10/2007, 20h17   #4
lark
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Select Into Question for Stored Procedure

== 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)
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 00h46.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10438 seconds with 12 queries