SQL

M-am intalnit azi cu o chestie f misto…. functii facute direct in sql pe care. Mi-am facut cateva chestii de care chiar aveam nevoie pentru a reduce traficul.

Exemple(nu de alta, dar sa le am undeva notate:p):

DELIMITER $$

DROP PROCEDURE IF EXISTS `l2jserver`.`change_passwd` $$
CREATE DEFINER=`l2jserver`@`%` PROCEDURE `change_passwd`(IN s_username TEXT,IN old_passwd TEXT, IN new_passwd TEXT)
BEGIN
UPDATE `l2jserver`.`web_accounts`
SET `password`=new_passwd
WHERE `password`=old_passwd AND `username` = s_username;
UPDATE `l2jserver`.`accounts`
SET `password`=new_passwd
WHERE `password`=old_passwd AND `login` = s_username;
END $$

DELIMITER ;

And also:

DROP VIEW IF EXISTS `l2jserver`.`users`;
CREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `l2jserver`.`users` AS select `l2jserver`.`web_accounts`.`id` AS `id`,`l2jserver`.`accounts`.`login` AS `Username`,`l2jserver`.`web_accounts`.`password` AS `Password`,`l2jserver`.`web_accounts`.`email` AS `email`,`l2jserver`.`web_accounts`.`accesslevel` AS `Level access`,`l2jserver`.`accounts`.`lastactive` AS `Last Active`,`l2jserver`.`accounts`.`lastIP` AS `From IP last time` from (`l2jserver`.`accounts` join `l2jserver`.`web_accounts` on((`l2jserver`.`web_accounts`.`username` = `l2jserver`.`accounts`.`login`)));

Leave a Reply