Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3834 connectés 

  FORUM HardWare.fr
  Programmation
  SQL/NoSQL

  ORDER BY en transact-sql sous ASE

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

ORDER BY en transact-sql sous ASE

n°1007062
Nico5779
Posté le 09-03-2005 à 17:15:28  profilanswer
 

Bonjour,
Peut on faire un ORDER BY dans un select d'une procedure stockée sous sybase ?
qd je fait le create proc , y me dit "syntax error near keyword ORDER",
et bon si je fais un bete select a pars la ca marche...
une idée?
Voici le code de ma procedure

Code :
  1. CREATE PROC occup_machine
  2. @dateofday DATETIME
  3. AS
  4. DECLARE @machlib VARCHAR(50)
  5. DECLARE @idart NUMERIC(5)
  6. DECLARE @art VARCHAR(50)
  7. DECLARE @dd DATETIME
  8. DECLARE @df DATETIME
  9. DECLARE @ligne VARCHAR(150)
  10. DECLARE curs_occ CURSOR FOR
  11.  (SELECT machine.libelle, planning.id_article, planning.date_debut, planning.date_fin
  12.   FROM machine,planning
  13.   WHERE machine.id_machine = planning.id_machine
  14.   AND DATEPART(day,date_debut) = DATEPART(day,@dateofday)
  15.   AND DATEPART(month, date_debut) = DATEPART(month,@dateofday)
  16.   AND DATEPART(year,date_debut) = DATEPART(year,@dateofday)
  17.   )
  18. OPEN curs_occ
  19. FETCH curs_occ INTO @machlib,@idart,@dd,@df
  20. IF(@@sqlstatus = 2)
  21.  PRINT "planning vide"
  22. ELSE
  23.  WHILE(@@sqlstatus = 0)
  24.   BEGIN
  25.    SELECT @art = (SELECT libelles FROM articles WHERE id_article = @idart)
  26.    SELECT @ligne = @machlib + " pour " + @art + " de " + CONVERT(VARCHAR(25),@dd) + " a " +   CONVERT(VARCHAR(25),@df)
  27.    PRINT @ligne
  28.    FETCH curs_occ INTO @machlib,@idart,@dd,@df
  29.   END
  30. IF(@@sqlstatus = 1) PRINT "unhandled error"
  31. CLOSE curs_occ
  32. DEALLOCATE CURSOR curs_occ
  33. RETURN


 
Je voudrais rajouter "ORDER BY date_debut ASC", pour le gros select mais ca veut pas  :(


Message édité par Nico5779 le 09-03-2005 à 17:18:49
mood
Publicité
Posté le 09-03-2005 à 17:15:28  profilanswer
 

n°1007849
coolben
http://www.starbusiness.fr
Posté le 10-03-2005 à 11:02:27  profilanswer
 

salut  
As tu essayer de mettre :
"ORDER BY planning.date_debut ASC"
sinon c'est peut etre lié à la jointure.
perso je teste toujours mes requetes avec un client SQL avant de les mettre dans le code d'un procedure stocké. Cela me permet d'avoir des messages d'erreur plus explicite.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  SQL/NoSQL

  ORDER BY en transact-sql sous ASE

 

Sujets relatifs
[SGBD] select * from matable order by @varColonne dynamique dans une requête [SQL Server 2000 - Transact SQL]
[MySQL] order by "quoi ?" quand on veut ref1, ref2, ref10, ref11 ...[PHP/MySQL] ...ORDER BY (a+b) desc ???
[Sybase ASE 12 - BCP] Options du bcpProblèmes sur ORDER et de constituer un groupe de liste
ORDER BY en asp?!?Tri ORDER BY
Mysql & Order By[SQL] order by Sum(...)
Plus de sujets relatifs à : ORDER BY en transact-sql sous ASE


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)