Skip to content

Tag: sql

PL/SQL table mutation and trigger Format

I just started with triggers, I want the trigger to give me the msg error if the new tauxHoraire is 50% greater than the current tauxHoraire (so *1.5 >). The trigger compiles but I’m getting ORA-04091: table name is mutating, trigger/function may not see it. There might a problem in how I wrote it. O…

Return list of Students by ZipCode Count

I am trying to get a list of students that live in the same zip code where zip code count > 1. I tried the following and get nothing in my query. If I remove s.Student, I get results of zipcode and count, but I want to include student also. Below are the database tables I am using. Answer I

How to get a SQL trigger to increment by 1 on an update?

I am trying to create a trigger that updates one column on a specific row when it is updated but I am getting this error ORA-04091: table table_name is mutating, trigger/function may not see it when I go to test the trigger. This is my trigger code: It is suppose to only update that certain Employees ID revis…

Convert SQL commands to Python

I have the following code in SQL: I’ve been trying to rewrite it in python like so: but I keep getting a generic error message. What am I doing wrong? EDIT: added the error message Answer IIUC, you could try the following: The equivalent of SELECT DISTINCT col is drop_duplicates(col) and the equivalent …

How to find employee department changes?

I have a table that has the old departments and new departments of various employees: EmployeeID OldDept NewDept 123 Design Design 234 Software Engineering 345 Design Software 456 Advertising Software How can I create a table that looks like this: Dept TransfersIn TransfersOut Software 2 1 Design 0 1 Advertis…