Hi, guys. Say, I have a query:
select t.value, my_stored_function(t.value)
from my_table t
where my_stored_function(t.value) = n_Some_Required_Value
I have rewritten it in the following way:
select value, func_value
from (select t.value, my_stored_function(t.value) func_value
from my_table t) subquery
where subquery....
I keep getting this error:
Result consisted of more than one row
I have this function:
DROP FUNCTION IF EXISTS db.GetUserIDByCourseID;
CREATE FUNCTION db.`GetUserIDByCourseID`(CourseID int) RETURNS int(11)
BEGIN
SELECT (c.user_id + COALESCE(pi.user_id, 0) + COALESCE(p.user_id, 0))
INTO @user_id
FROM courses c
...
I'm trying to make a function that recursively builds a path for a specific category
CREATE FUNCTION getPath(inId INT)
RETURNS TEXT
DETERMINISTIC
BEGIN
DECLARE return_path TEXT;
DECLARE return_parent_id INT;
SELECT CONCAT('/', name) INTO return_path FROM article_categories WHERE id = inId;
SELECT parent_id INTO return_pa...
I tried this example via phpMyAdmin
http://www.databasejournal.com/features/mysql/article.php/3569846/MySQL-Stored-Functions.htm
mysql> DELIMITER |
mysql>
CREATE FUNCTION WEIGHTED_AVERAGE (n1 INT, n2 INT, n3 INT, n4 INT)
RETURNS INT
DETERMINISTIC
BEGIN
DECLARE avg INT;
SET avg = (n1+n2+n3*2+n4*4)/8;
RETURN avg;
...
Is it possible for a SQL Stored Procedure to call a .NET object? In my situation, I need to take a string parameter and return a hashed result that can be consumed by my secure client.
I can either have this SP called on a per result basis (once per row), or I can possibly return multiple rows. It all depends on what SQL will support ...
Hi guys,
I have a database which contains a lot of geospatial data ... basically information on 10s of thousands of people, with coordinates for each of them.
The coordinates are currently stored as two floats for latitude and longitude, and I use a function to determine the distance between the coordinates in that record and a coord...
Hi, I have just started to create a stored function this is my first time so I am having a few problems. Currently I call the fucntion using SELECT test(); (test is the function name for now). I want to send a number to the function (username ID) and have the username returned.
I have this working by using SELECT test(1); 1 is the ID of...
I'm working with SQL Server Reporting Services 2008, which is somewhat new to me, as most of my experience is with LAMP development. In addition, moving most of the logic to SQL as stored procedures is something I'm not very familiar with, but would like to do. Any help or direction would be greatly appreciated.
I need a list of accep...
I'm getting a 1064 error when trying to call a stored function from within a stored procedure. It only happens on the line where I try to do this: SET account_id = get_account_id(user);. What is the problem and how can I fix it?
Account ID Stored Functions:
CREATE DEFINER=`aaron`@`%` FUNCTION `get_account_id`(user VARCHAR(255)) RETUR...