Skip to content

Tag: sql

Cannot create trigger if-delete-clause

Here is the code I have which checks if there is more than 5000 entries after an insert, then deletes all entries which are greater than 2 hours old I am getting you have an error in your mysql syntax near IF (SELECT … DELETE FROM … I am using MariaDB, can someone help me understand where is the e…

SQL query optimisation by replacing subquery

The following query works and gives me the expected result but i’d like to optimise it. Is there a way to avoid the subquery, using only the conditions in the main query to arrive at the same result: PS: In PLSQL, NVL function lets us substitute a value when a null value is encountered Thanks for any in…

Loop custom type object ion procedure

I created the following type: Inside of a procedure then I accept this parameter and want to loop through it: I keep getting this error though: Answer It is possible that you want to create a collection type and then pass that collection to your procedure If that is not what you are looking for, please edit y…

Select where all columns in list item

How do I do the equivalent of the following in SQL Server? I only want to match rows where There can be an arbitrary number of match conditions. The only solution I have been able to find is the above, but doubt it would scale to 1000s of dynamic values. Answer Put those value in temp table or use Table