![]() |
Pages (11): « First ... « 4 5 6 7 [8] 9 10 11 » Show 150 posts per page |
.dsy:it. (http://www.dsy.it/forum/)
- Basi di dati ~ informatica triennale (http://www.dsy.it/forum/forumdisplay.php?forumid=211)
-- Social network 2010/2011 (http://www.dsy.it/forum/showthread.php?threadid=41459)
Sviluppo Php
Qualcuno sa suggerire eventuali tools di supporto allo sviluppo in php?
Cakephp puo' tornare utile?
Ve ne sono altri ...?
Grazie
Re: Sviluppo Php
Originally posted by fcaridi
Qualcuno sa suggerire eventuali tools di supporto allo sviluppo in php?
Cakephp puo' tornare utile?
Ve ne sono altri ...?
Grazie
__________________
ho un problema... ho una procedura che esegue due comandi:
fa il DROP di una tabella se esiste;
Crea la tabella precedentemente eliminata;
poi ho il trigger che richiama la procedura quando accade un evento.
Il problema è che a fronte dell'evento io ottengo l'errore:
"Explicit or implicit commit is not allowed in stored function or trigger. "
Cosa c'è che non va? La procedura è così:
code:
DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `procedura`() BEGIN drop table if exists tabella; CREATE TABLE tabella SELECT a FROM b WHERE c AND d; END
Se sposti il codice della procedura dentro il trigger che la chiama?
__________________
Portale segnalazioni marchi-negozi di abbigliamento
http://www.ovojo.com
non mi permette nemmeno di crearlo segnalandomi lo stesso errore... :/
Credo che il problema sia la drop nel trigger che non vuole.
Col truncate e la insert hai provato?
__________________
Portale segnalazioni marchi-negozi di abbigliamento
http://www.ovojo.com
mi da l'errore anche solo con la create table...
io devo eliminare la tabella se già esiste e subito dopo crearla.
truncate e insert non agiscono sulla tabella ma sulle righe... sbaglio?
e poi ho letto questo che sconsiglia il truncate http://inderpreetsingh.com/2010/09/...ion-or-trigger/
Credo si riferisca a myisam, visto che su innodb la truncate non cancella la tabella e la ricrea.
Intendevo qualcosa del tipo:
CREATE TABLE tabella SELECT a FROM b WHERE c AND d if not exists tabella;
truncate table tabella;
INSERT INTO tabella SELECT a FROM b WHERE c AND d;
Edit: nella create potresti usare il like o l'as (controlla)
__________________
Portale segnalazioni marchi-negozi di abbigliamento
http://www.ovojo.com
Se rompe ancora il cazzo, prova a creare la tabella fuori dal trigger e dentro al trigger metti solo la truncate e la insert
__________________
Portale segnalazioni marchi-negozi di abbigliamento
http://www.ovojo.com
provo così e vediamo cosa succede per ora grazie
Nel caso puoi usare REPLACE al posto di truncate+insert.
__________________
Portale segnalazioni marchi-negozi di abbigliamento
http://www.ovojo.com
dunque confermo che la TRUNCATE provoca lo stesso messaggio di errore...
Per risolvere basta seguire il consiglio dell'articolo che ho linkato sopra
in sostanza al posto di:
TRUNCATE TABLE nometabella
bisogna mettere:
DELETE FROM nometabella
(senza l' * )
In sostanza:
1) creo la tabella la prima volta a mano
2) creo la procedura che svuota la tabella e la riempie di nuovo con i dati aggiornati
Così sembra funzionare tutto.
Grazie
Ottimo.
Ma è innodb la tabella su cui esegui la truncate?
Perché truncate = delete from senza where, quindi non capisco perché non vada.
Edit: ecco la spiegazione:
For an InnoDB table before version 5.0.3, InnoDB processes TRUNCATE TABLE by deleting rows one by one. As of MySQL 5.0.3, row by row deletion is used only if there are any FOREIGN KEY constraints that reference the table. If there are no FOREIGN KEY constraints, InnoDB performs fast truncation by dropping the original table and creating an empty one with the same definition, which is much faster than deleting rows one by one.
Si vede che non hai fk allora.
__________________
Portale segnalazioni marchi-negozi di abbigliamento
http://www.ovojo.com
si è innodb... il problema stando all'articolo nasce da questa osservazione:
Depending on version and storage engine, TRUNCATE can cause the table to be dropped and recreated. This provides a much more efficient way of deleting all rows from a table, but it does perform an implicit COMMIT. You might want to use DELETE instead of TRUNCATE.
Si si, infatti ti ho postato la spiegazione. Dalla versione 5.0.3 la truncate è diventata una drop + una create, mentre prima era una semplice delete.
__________________
Portale segnalazioni marchi-negozi di abbigliamento
http://www.ovojo.com
All times are GMT. The time now is 17:01. | Pages (11): « First ... « 4 5 6 7 [8] 9 10 11 » Show all 151 posts from this thread on one page |
Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.