Posts

Showing posts from July, 2024

lab7

// Insert a document into a collection named 'users'  db.users.insertOne({ name: "John", age: 30, city: "New York" });  // Find all documents in the 'users' collection  db.users.find();  // Find documents with a specific condition  db.users.find({ age: { $gte: 25 } });  // Find users with age greater than or equal to 25  // Update a document in the 'users' collection  db.users.updateOne({ name: "John" }, { $set: { age: 35 } });  // Delete a document from the 'users' collection  db.users.deleteOne({ name: "John" });

lab6

CREATE OR REPLACE PROCEDURE Merge_RollCall_Data AS  CURSOR N_RollCall_Cursor IS  SELECT *  FROM N_RollCall;  v_N_RollCall_Record N_RollCall%ROWTYPE;  BEGIN  FOR v_N_RollCall_Record IN N_RollCall_Cursor LOOP -- Check if data already exists in O_RollCall table  SELECT COUNT(*)  INTO v_Count  FROM O_RollCall  WHERE EMPNO = v_N_RollCall_Record.EMPNO  AND ROLL_DATE = v_N_RollCall_Record.ROLL_DATE; -- If data doesn't exist, insert into O_RollCall  IF v_Count = 0 THEN  INSERT INTO O_RollCall (EMPNO, ROLL_DATE, STATUS)  VALUES  (v_N_RollCall_Record.EMPNO,  v_N_RollCall_Record.STATUS);  END IF;  END LOOP;  COMMIT;  END Merge_RollCall_Data;  /