Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti mustaqil ish



Yüklə 135,9 Kb.
səhifə4/7
tarix16.12.2023
ölçüsü135,9 Kb.
#183164
1   2   3   4   5   6   7
enbmbbmi

CREATE FUNCTION
Biz Update , Delete , Insert methods lariga funksiya
-- Create a function for adding a new user
CREATE FUNCTION dbo.AddUserFunction (@employee_id INT)
RETURNS INT
AS
BEGIN
-- Your logic for adding a new user goes here
-- You can access the new data using the @employee_id parameter

-- For example, you might want to log the addition of a new user


INSERT INTO UserLog (log_message)
SELECT 'New user added: ' + name
FROM Employee
WHERE employee_id = @employee_id;

RETURN 1; -- Return any value based on your needs


END;

-- Create a function for deleting a user


CREATE FUNCTION dbo.DeleteUserFunction (@employee_id INT)
RETURNS INT
AS
BEGIN
-- Your logic for deleting a user goes here
-- You can access the old data using the @employee_id parameter

-- For example, you might want to log the deletion of a user


INSERT INTO UserLog (log_message)
SELECT 'User deleted: ' + name
FROM Employee
WHERE employee_id = @employee_id;

RETURN 1; -- Return any value based on your needs


END;

-- Create a function for updating a user


CREATE FUNCTION dbo.UpdateUserFunction (@employee_id INT)
RETURNS INT
AS
BEGIN
-- Your logic for updating a user goes here
-- You can access both old and new data using the @employee_id parameter

-- For example, you might want to log the update of a user


INSERT INTO UserLog (log_message)
SELECT 'User updated: ' + name + ' -> ' + INSERTED.name
FROM INSERTED
INNER JOIN DELETED ON INSERTED.employee_id = DELETED.employee_id
WHERE INSERTED.employee_id = @employee_id;

RETURN 1; -- Return any value based on your needs


END;
PostgreSQLda "tasavvurlar" (schemas) va "sinonimlar" (synonyms) mavjud emas. Ammo, ularni o'rniga, schema va view (ko'rib chiqish)larni ishlatishingiz mumkin.


  1. Yüklə 135,9 Kb.

    Dostları ilə paylaş:
1   2   3   4   5   6   7




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin