views:

92

answers:

2

hi here is a short version of function which im using on daily basis, it works fine except it throws a warning 'No data - zero rows fetched, selected, or processed (errno. 1329)'. and since i start using this function with django there cant be any warning or error because it stop the whole process

i have read that there is no warning filtering in django so i must get rid off it it occurs on select statement where i check for unique entry .. so when this select return no data everything is ok and it may continue to next data check but since it return nothing mysql throw warning

any idea how to fix this?

DELIMITER $$

DROP FUNCTION IF EXISTS objtree_node_add $$
CREATE FUNCTION objtree_node_add(i_name VARCHAR(255), i_parent_id BIGINT, i_type_id    BIGINT) RETURNS bigint(20)
BEGIN

DECLARE a_name VARCHAR(255);

IF NOT i_name RLIKE '^[a-zA-Z0-9_-]+$' THEN
    RETURN -1;
END IF;

SELECT name INTO a_name FROM objtree_nodes WHERE parent_id = i_parent_id AND name = i_name;

IF NOT a_name IS NULL THEN
    RETURN -5;
END IF;

...
+1  A: 

I don't know where you read that there is no warnings filtering in Django. Django is just Python, so you can use the Python warnings module.

import warnings
warnings.filterwarnings("ignore", "No data .*")
Daniel Roseman
sr, i know about this because i work in python, but my coleague start working on django recently and told me it isnt possible :) ... so i was looking for another solutionsthanks
nabizan
+1  A: 
import warnings
warnings.filterwarnings("ignore", "No data .*")