Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    Stored Procedure complessa

    Non riesco a far funzionare tutta la stored
    La query è corretta ma non me la esegue

    Codice PHP:

    /* stored procedure */
    Delimiter 
      
    BEGIN
    TRUNCATE TABLE ranks 
    ;
    TRUNCATE TABLE defrank ;

        DECLARE 
    max_rank INT;
        
        
    SELECT max(max_links)-1 INTO max_rank FROM 
        
    (
          
    SELECT Count(host) AS max_links
          FROM rels 
          GROUP BY linkedhost
        
    ) AS tb2;
       
    INSERT INTO ranks (host,links,rank)
         
    SELECT hostlinks, (10 * (links-1) ) / max_rank
         FROM
         
    (
           
    SELECT linkedhost AS host,count(host) AS links 
           FROM rels
           GROUP BY linkedhost
           ORDER BY links desc
         
    )AS tb1 ;
         
          
    INSERT INTO defrank (host,links,points)
            
    SELECT rels.linkedhost as thost,
               (
                
    SELECT links 
                FROM ranks
                WHERE host 
    thost
                limit 1
                
    ) AS links,
                
    sum(
                ( 
    SELECT rankpoints.points
                  FROM ranks INNER JOIN rankpoints on rankpoints
    .rank ranks.rank
                  WHERE ranks
    .host rels.host limit 1) )
                                    +
                ( 
    SELECT rankpoints.points
                  FROM ranks INNER JOIN rankpoints on rankpoints
    .rank ranks.rank
                  WHERE ranks
    .host thost limit 1) AS pr
              FROM rels 
              GROUP BY rels
    .linkedhost
              ORDER BY pr desc
    ;

      
    END$
    Delimiter 
    Praticamente l'errore l'ho qui :
    TRUNCATE TABLE ranks ;
    TRUNCATE TABLE defrank ;


    Non mi svuota le 2 tabelle
    Se faccio così tutto bene:

    TRUNCATE TABLE ranks ;
    TRUNCATE TABLE defrank ;
    CALL calc_rank() ;


    Non è possibile far svuotare le tabelle in automatico ?
    Lo so che è poco sbattimento ma volevo capire se sbagliavo io

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    460
    Hai provato con DELETE * FROM TABLE ?
    There are 10 types of people in the world - those who understand binary and those who don't.

  3. #3
    ma con il delete non mi azzera l'autoincrement dell'id

  4. #4
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    460
    [edit per commento poco utile]
    There are 10 types of people in the world - those who understand binary and those who don't.

  5. #5
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    460
    Cercando su google la prima cosa che ho trovato e' che sembra che sia un bug. Ti da' problemi di locked table?

    http://www.google.com/search?q=trunc...en-US:official
    There are 10 types of people in the world - those who understand binary and those who don't.

  6. #6
    infatti bug di mysql

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.