FAQ Database Discussion Community

mysql: stored function call + left join = very very slow

I have two tables: module_339 (id,name,description,etc) module_339_schedule(id,itemid,datestart,dateend,timestart,timeend,days,recurrent) module_339_schedule.itemid points to module_339 fist table holds conferences second one keeps the schedules of the conferences module_339 has 3 items module_339_schedule has 4000+ items - almost evenly divided between the 3 conferences I have a stored function - "getNextDate_module_339" - which will compute...

Why does this MySQL stored function return null?

can anybody explain, why the following MySQL stored function returns always null? If I replace exchange_rate within SET @dollar = euro * exchange_rate; by 1.1013 it works great. DROP FUNCTION IF EXISTS euro_to_dollar; DELIMITER $$ CREATE FUNCTION euro_to_dollar(euro double) returns double BEGIN DECLARE dollar double; DECLARE exchange_rate double; SET @exchange_rate...

User defined function sql, Incorrect syntax near the keyword 'return'

I'm trying to write a function that takes an input of a date, and calculates the difference between current day and the inputed date, then returns it as an integer of days. (So if I input yesterday 2015-5-8 it returns 1). So far I'm getting this error and can't really...

Disallow NULL parameters to stored procedures in MySQL/MariaDB

I can specify that table columns are NOT NULL, but how do I make a stored procedure or function only be compatible with non-null arguments? Adding NOT NULL after the argument name doesn't work.

Oracle stored function - pass table name as parameter

I'm trying to create a stored function in Oracle that will count the table rows..i want to make the table name dynamic, so i passed it as a parameter, the stored function code looks like this create type tes_jml_obj is object(jumlah integer); create type tes_jml_table is table of tes_jml_obj; create...