Questions tagged [mysql-function]

75 questions
0
votes
1 answer

How to pass binary (16) to a mysql function as an argument

I would like to pass the uuid of version varbinary(16) to a user-defined function in MySQL version 5.7.x - It throws an error 1406 - Data too long for column I have a table with uuid primary key of type varbinary(16) - I would like to convert the…
0
votes
1 answer

User defined Mysql Functions in where condition Fails

I have created Mysql function which gives result integer or NULL. It works fine for all values. If use this function in simple query it aslo works as expected like following query : select distinct(hsd.hotel_id) from hotel_season_detail hsd where…
Nikhil Lende
  • 129
  • 7
0
votes
1 answer

Call Custom MySql Function In Doctrine Query builders Query

i am having an error while using custom mysql function in doctrine query builders query string. [Syntax Error] line 0, col 32: Error: Expected known function, got 'ucfirst' mysql function is as below. DELIMITER $$ DROP FUNCTION IF EXISTS…
Amit Joshi
  • 456
  • 1
  • 8
  • 21
0
votes
1 answer

MYSQL - table not updating from Procedure

I want to get distance between two GeoPoints (using LatLong) for that I wrote GETDISTANCE function from solution provided [MySQL Function to calculate distance between two latitudes and longitudes. If I call function independently it works like…
0
votes
2 answers

MySQL LEFT JOIN with WHERE function-call produces wrong result

From MySQL 5.7 I am executing a LEFT JOIN, and the WHERE clause calls a user-defined function of mine. It fails to find a matching row which it should find. [Originally I simplified my actual code a bit for the purpose of this post. However in…
JonBrave
  • 4,045
  • 3
  • 38
  • 115
0
votes
1 answer

Query build automation

I have the following query select count(t1.guid) from table t1 where t1.id=X; X is a result-set from this query select ID from table t2 where t2.flags=65537; The above query returns 84 results, all of INT datatype. id is primary key in t2…
0
votes
0 answers

Check if a record doesn't exist OR if a condition is true, return the parameter in MySQL

Given a simple table like this: var1 | var2 0 | 3 2 | 4 6 | 5 I would need to return the lowest value (var1, as a multiple of 2) for which either a record does not exist (in this case, 4) or var2 is equal to 5 (in this case, 6). I'd…
Fed C
  • 143
  • 1
  • 13
0
votes
0 answers

Change the following MDX query into MYSQL query

In pentaho,I used the below is the MDX Query for dropdown , WITH MEMBER [Measures].[Years UniqueName] AS [Time].currentmember.UniqueName SET YEAR AS UNION( [Time].[All Years] , [Time].[Years].Members ) SELECT …
sarankumar
  • 71
  • 1
  • 8
0
votes
1 answer

Mysql function not returning the expected result

As I have mentioned in my question title below Mysql function returns null always : CREATE DEFINER=`root`@`localhost` FUNCTION `nextCode`(tbl_name VARCHAR(30), prv_code VARCHAR(30)) RETURNS varchar(30) CHARSET utf8 READS SQL DATA BEGIN …
Madushan Perera
  • 2,568
  • 2
  • 17
  • 36
0
votes
1 answer

mysql function variable set not working

I am writing a function that should return a floating value. BEGIN DECLARE due_amount DECIMAL(9,2); SET due_amount = (SELECT due_amount FROM ( SELECT id, MAX(date), due_amount, user_id FROM lunch_transaction …
Azima
  • 3,835
  • 15
  • 49
  • 95
0
votes
2 answers

How to create mysql function

i have the following sql query SELECT id, title, total_likes, IFNULL(SELECT 1 FROM 'likedata' WHERE user_id=$UID AND post_id=posts.id)0) AS is_liked FROM 'posts' I want to create mysql function to make my query bit shorter, i don't know…
0
votes
1 answer

ERROR 1064 (42000): SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ');

I am trying to write a mysql function... but I am getting the syntax error as ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '); My code…
rahul shalgar
  • 1,198
  • 5
  • 24
  • 39
0
votes
1 answer

MySQL error, "Not allowed to return a result set from a function"?

I'm trying to wrap my head around functions in mySQL and I'm currently making one that checks the column account_description and it's value to see if the description already exists. If it does exist already, display a message saying so. However, if…
Kasador
  • 405
  • 7
  • 18
0
votes
0 answers

Error declaring varchar variable inside MySQL Function

I am attempting to create a MySQL variable inside a stored function similar to this: CREATE DEFINER = CURRENT_USER FUNCTION t_func(cc char(2), lc char(2), os varchar(1000)) RETURNS varchar(1000) DETERMINISTIC READS SQL DATA BEGIN …
Adam
  • 4,590
  • 10
  • 51
  • 84
0
votes
1 answer

Mysql function, return more than one row

I have build a little mysq function who should check is the users in my table are still vaid, the have got a row validfrom and validto and my function should check if the validto date is older than now. CREATE DEFINER=`root`@`localhost` FUNCTION…
user8094514