Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jdizajn
Starting Member
2 Posts |
Posted - 2012-08-09 : 07:06:44
|
| My knowledge of SQL programming is the beginner level. This above formula, we made a friend. Everything works great when one table. I'd like to do the same function works with another table. I tried to make two stored procedures, but could not manage to run both procedures in triggers. Thanks for your answers. Best regards Joseph.Here's the whole formula, so if you could just explain how to connect with the formula product_rac table that should have - amount.DELIMITER $$DROP PROCEDURE IF EXISTS lunasoft.kalkulacija$$CREATE DEFINER=root@localhost PROCEDURE kalkulacija()BEGINupdate aos_products_cstm as t1set t1.kolicina=COALESCE( (select sum(t2.product_pri) from aos_products_quotes as t2 where t2.product_id=t1.id_c and t2.deleted=0 and pro_usluga_c='proizvod' group by t2.product_id),0);*set t1.kolicina=COALESCE( -(select sum(t2.product_rac) from aos_products_quotes as t2 where t2.product_id=t1.id_c and t2.deleted=0 and pro_usluga_c='proizvod' group by t2.product_id),0);*END$$DELIMITER ;DELIMITER $$DROP TRIGGER /!50032 IF EXISTS / lunasoft.racun_unos$$CREATE /!50017 DEFINER = 'root'@'localhost' / TRIGGER racun_unos AFTER INSERT ON aos_products_quotes FOR EACH ROW BEGIN call kalkulacija; END; $$DELIMITER ;DELIMITER $$DROP TRIGGER /!50032 IF EXISTS / lunasoft.racun_izmjena$$CREATE /!50017 DEFINER = 'root'@'localhost' / TRIGGER racun_izmjena AFTER UPDATE ON aos_products_quotes FOR EACH ROW BEGIN call kalkulacija; END; $$DELIMITER ;DELIMITER $$DROP TRIGGER /!50032 IF EXISTS / lunasoft.racun_brisanje$$CREATE /!50017 DEFINER = 'root'@'localhost' / TRIGGER racun_brisanje AFTER DELETE ON aos_products_quotes FOR EACH ROW BEGIN call kalkulacija; END; $$DELIMITER ; |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-08-09 : 07:16:29
|
Try to ask over at www.dbforums.comThis is a Microsoft SQL Server dedicated forum. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
jdizajn
Starting Member
2 Posts |
Posted - 2012-08-09 : 07:19:50
|
Thanks. Sincerely Josephquote: Originally posted by SwePeso Try to ask over at www.dbforums.comThis is a Microsoft SQL Server dedicated forum. N 56°04'39.26"E 12°55'05.63"
|
 |
|
|
|
|
|