Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql (STOREDPROC)生成的SELECT语句:查找要使用的接近NULL的正确语法_Mysql_Sql_Vb.net_Stored Procedures_Tableadapter - Fatal编程技术网

Mysql (STOREDPROC)生成的SELECT语句:查找要使用的接近NULL的正确语法

Mysql (STOREDPROC)生成的SELECT语句:查找要使用的接近NULL的正确语法,mysql,sql,vb.net,stored-procedures,tableadapter,Mysql,Sql,Vb.net,Stored Procedures,Tableadapter,我正在使用存储过程创建表适配器。这是我的语法: DELIMITER $$ DROP PROCEDURE IF EXISTS `lcs_rdb`.`sp_EmployeeListReport`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_EmployeeListReport`(in where_clause TEXT) BEGIN SET @sql = CONCAT("SELECT

我正在使用存储过程创建表适配器。这是我的语法:

DELIMITER $$

DROP PROCEDURE IF EXISTS `lcs_rdb`.`sp_EmployeeListReport`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_EmployeeListReport`(in where_clause TEXT)
BEGIN
        SET @sql = CONCAT("SELECT        
                emp.employee_id, 
                group_concat(distinct `ext`.`extension_number` separator ',') AS extension_number,
                emp.employee_lastname, emp.employee_firstname, 
                dept.department_description, 
                divs.division_description, 
                grps.group_description, 
                st.site_name, emp.audit_date,
                group_concat(distinct `cst_ctr`.`cost_center_description` separator ',') AS cost_center_description
                FROM employees emp INNER JOIN
                 employee_extensions emp_ext ON emp_ext.employee_id = emp.employee_id INNER JOIN
                 extensions ext ON ext.extension_id = emp_ext.extension_id INNER JOIN
                 departments dept ON emp.department_id = dept.department_id INNER JOIN
                 divisions divs ON dept.division_id = divs.division_id INNER JOIN
                 groups grps ON divs.group_id = grps.group_id INNER JOIN
                 sites st ON emp.site_id = st.site_id LEFT OUTER JOIN
                 employee_cost_centers emp_cstctr ON emp.employee_id = emp_cstctr.employee_id LEFT OUTER JOIN
                 cost_centers cst_ctr ON emp_cstctr.cost_center_id = cst_ctr.cost_center_id
                where ", where_clause ,"");
 PREPARE stmt FROM @sql;
 EXECUTE stmt;
 DEALLOCATE PREPARE stmt;
   END$$

DELIMITER ;
这是我执行它时的错误:
“生成SELECT语句。 您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以获取第1行中接近“NULL”的正确语法”

我认为,问题在于where条款。但我不知道如何修复它。请帮忙。谢谢。

CONCAT()
如果任何值为
NULL
,则返回
NULL
。也许你想要这样的东西:

CONCAT('select . . .',
       COALESCE(where_clause, '1 = 1'))
CONCAT()
如果任何值为
NULL
,则返回
NULL
。也许你想要这样的东西:

CONCAT('select . . .',
       COALESCE(where_clause, '1 = 1'))

哦,等等。看看我的代码(它表示:*未将参数“where_子句”指定为“Public Overridable重载函数Fill(dataTable作为LCSRDBDataSet.CostCenterStandardDataTable,where_子句作为字符串)作为整数”。**语法为:*daCostCenterStandard.Fill(dtCostCenterStandard)尽管如此,在准备好的语句的第1行错误处使用接近“NULL”的正确语法意味着
@sql
确实为NULL,因为至少有一个参数(意外地)为NULL。解决方案将涉及找出哪个参数。哦,等等。看看我的代码(它表示:*未将参数“where_子句”指定为“Public Overridable重载函数Fill(dataTable作为LCSRDBDataSet.CostCenterStandardDataTable,where_子句作为字符串)作为整数”。**语法为:*daCostCenterStandard.Fill(dtCostCenterStandard)尽管如此,在预处理语句的第1行错误处使用接近“NULL”的正确语法意味着
@sql
确实为NULL,因为至少有一个参数(意外地)为NULL。解决方案将涉及确定哪一个参数。