2 star902 star902 于 2013.10.31 15:03 提问

orcal 存储过程第一次写,编译的时候报错,大侠帮帮忙,急!!

sql脚本如下:
create or replace procedure "PageList"(tbName IN VARCHAR2,tbFieldsIN VARCHAR2, orderField IN VARCHAR2,orderType IN INT,strWhere IN VARCHAR2,pageSize IN INT,pageIndex IN INT,pageRecord 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<>'') then
whereStr:= CONCAT(' where ',strWhere,' ');
else
whereStr:= ' ';
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);

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!