问题描述
- orcal 存储过程第一次写,编译的时候报错,大侠帮帮忙,急!!
- sql脚本如下:
create or replace procedure ""PageList""(tbName IN VARCHAR2tbFieldsIN VARCHAR2 orderField IN VARCHAR2orderType IN INTstrWhere IN VARCHAR2pageSize IN INTpageIndex IN INTpageRecord OUT INT)
is
BEGIN/*定义变量*/declare m_begin_row INT DEFAULT 0;declare m_limit_string varchar2(64);declare m_order_string varchar2(128);declare orderStr varchar2(64);declare whereStr varchar2(1000);/*构造语句*/if orderType = 1 then
orderStr:= 'asc';
else
orderStr:= 'desc';
end if;if (strWhere<>'') thenwhereStr:= CONCAT(' where 'strWhere' ');elsewhereStr:= ' ';end if; m_begin_row:= (pageIndex - 1) * pageSize;m_limit_string:= CONCAT(' LIMIT ' m_begin_row ' ' pageSize);m_order_string:= CONCAT(' order by 'orderField' 'orderStr);@COUNT_STRING:= CONCAT('SELECT COUNT(*) INTO @ROWS_TOTAL FROM ' tbName ' ' whereStr);@MAIN_STRING:= CONCAT('SELECT ' tbFields ' FROM ' tbName ' ' whereStr ' ' m_order_string m_limit_string);/*预处理*/PREPARE count_stmt FROM @COUNT_STRING;EXECUTE count_stmt;DEALLOCATE PREPARE count_stmt;SET pageRecord = @ROWS_TOTAL;PREPARE main_stmt FROM @MAIN_STRING;EXECUTE main_stmt;DEALLOCATE PREPARE main_stmt;
END
报的错误:
错误:PLS-00103: Encountered the symbol ""IF"" when expecting one of the following:begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior The symbol ""begin"" was substituted for ""IF"" to continue.
行:12
错误:PLS-00103: Encountered the symbol ""COUNT_STMT"" when expecting one of the following:
:= . ( @ % ;
行:29
文本:@COUNT_STRING:= CONCAT('SELECT COUNT(*) INTO @ROWS_TOTAL FROM ' tbName ' ' whereStr);错误:PLS-00103: Encountered the symbol ""COUNT_STMT"" when expecting one of the following:
:= . ( @ % ; immediate
行:30
文本:@MAIN_STRING:= CONCAT('SELECT ' tbFields ' FROM ' tbName ' ' whereStr ' ' m_order_string m_limit_string);
时间: 2024-09-21 15:10:53