Untitled

mail@pastecode.io avatar
unknown
html
7 months ago
6.1 kB
3
Indexable
Never
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>triggers for shraavniii</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
      background-image: url("https://images.unsplash.com/photo-1589810264340-0ce27bfbf751?q=80&w=1887&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");
      background-size: cover;
      background-position: center;
      color: #000;
      background-color: black;
    }

    header {
      position: relative;
      background: rgba(255, 83, 158, );
      color: rgb(0, 0, 0);
      padding: 20px 0;
      text-align: center;
    }

    p {
      margin-left: 20px;
      /* Adjust the margin value as needed */
    }
  </style>
  <header>
    <h1>shraavniiittejuu tutorials😃🥰😝</h1>
  </header>
</head>

<body>
  <h1>triggers</h1>

  <p style="margin-left: 20px;">
    hiee chimnuuu
    <br>
    triggers mnje 1 predefined program ahe database mdhe je ki konti action perform zali ki trigger hot
    <br>
    mnje triggers mnje mhitiy na tu dharun bsli astes bgh mi jvl alo ki "NIGHHH" boltes
    <br>
    mnje bgh mi jvl alo hi ek action zali ani mi jvl alya alya tu trigger hotes ani nighhh he shoot krtes
    <br>
    tasach trigger ast database mdhe konti action perform zali ki te data la modify krt mnje shoot krt
    <br>
    ata ik he nsel smjl pn ata smjel example vrun smjel triggers actually ky asta ni kuthe vaprtat
    <br>
    ata smj tuzyakde table ahe groccery name cha tyat attributes ahet name and cost
    <br>
  </p>
  <table border="1" style="margin-left: 20px;">
    <tr>
      <th>Grocery Item</th>
      <th>Cost</th>
    </tr>
    <tr>
      <td>Apples</td>
      <td>100</td>
    </tr>
    <tr>
      <td>Bread</td>
      <td>200</td>
    </tr>
    <tr>
      <td>Milk</td>
      <td>50</td>
    </tr>
    <tr>
      <td>Eggs</td>
      <td>60</td>
    </tr>
    <tr>
      <td>Cheese</td>
      <td>150</td>
    </tr>
    <tr>
      <td>Tomatoes</td>
      <td>70</td>
    </tr>
    <tr>
      <td>Chicken</td>
      <td>200</td>
    </tr>
    <tr>
      <td>Total</td>
      <th>830</th>
    </tr>
  </table>
  <p style="margin-left: 20px;">
    ata smj ya vrchya table mdhe tula khi add kraych asel tr tu kru shkshil pn khali total mhnun pn 1 ahe bgh
    <br>
    tithe thodi tu change kru shktes
    <br>
    tithe database change krto
    <br>karn tithe trigger set kelela asto
    <br>
    jasa nvin khi aad hoil total should be updated asa trigger asto
    <br>
    ata amazon ch example ghe cart ch jasa tu nvin item add krtes tithe automatically total price update hote na tr
    tithe trigger set kelela asto
    <br>
    nvin item aala ki total coset = before cost + (new item cost * quantity)
    <br>
    mnje nvin item ala ki he trigger shoot hoil ani update hoil value
    <br>
    triggers genlaary table mdhe DML command use zalyavr shoot hoto mnje
    <br>
    tu nvin item add kelas cart mdhe kiva item chi cost offer mule kmi zali kiva to item ch delete kelas tr total value
    apoaap kmi hoil karn trigger set kela asel
    <br> <br>
    ha khalcha code bgh
    <br><br>

  <pre style="margin-left: 20px;">
CREATE TRIGGER update_order_total_cost                      // ithe trigger create kela 
AFTER INSERT ON orders                                      // inset zalyavr 
FOR EACH ROW                                                // prtek row sathi 
BEGIN                                                       // he operation begin hoil 
-- Calculate the total cost from the order_items table      // calculation cha operation 
SELECT SUM(item_price * quantity) INTO @totalCost           // sum hoil prtek row chi ani @totalCost ya mdhe store hoil @totalCost he 1 user defined variable ahe ithe 
FROM order_items                                            // table name ahe he 
WHERE order_id = NEW.id;                                    // nvin row aali ki 
-- Set the total cost for the new order
SET NEW.total_cost = @totalCost;  /                         // new total cost chi value update hoil te @ vala variable assign kely bgh mndade 
END;
</pre>
  <p style="margin-left: 20px;">
    ha ata ha code smjla?
    <br>
    ha ek predefined program zala nvin khi insert update delete zal ki ha trigger program shoot hoil
    <br>
    ani ata 2 type che trigger astat 1 before ani ek after
    <br>
    before trigger mnje tu cart mdhe khi add krtes teva ji total aste ti before trigger mule aste
    <br>
    after trigger mnje tu khi add kiva delete kelas ki total cost aste ti update hote ti after trigger mule
    <br>
    before trigger action chya aadhi trigger hoto ani after trigger action zalyavr trigger hoto
    <br>
    ata tya pdf mdhl anser nko bghus he khalch bgh ani paste krun thev mndaduu he sopa vala ahe
    <br>
  <pre style="margin-left: 20px;">
    1. *What is a Trigger?*
    - A trigger is like a predefined software program in a database.
    - It automatically runs when certain operations happen in the database.(like an insertion, update, or delete)
 
 2. *Types of Triggers:*
    - *Before Trigger:*
      - Runs before a change (like an insertion, update, or delete) happens in the database.
      - It can check or change data before the change takes place.
 
    - *After Trigger:*
      - Runs after a change has happened in the database.
      - Often used for recording what happened or sending notifications.
 
 3. *Example:*
    - Imagine a shopping website.
    - Before you buy something (Before Trigger), it checks if you have enough money.
    - After you buy (After Trigger), it updates your purchase history.
 
 4. *Use Cases:*
    - Triggers help keep data accurate and secure.
    - They're used for things like checking data, logging changes, and sending alerts.
 
 Remember, triggers are like automatic helpers in a database. They can do tasks before or after something happens, making sure everything works smoothly.
  </pre>

  </p>

</body>

</html>
Leave a Comment