BEGIN
  StrLocalWorkTableName:=TblnameW;
  StrLocalWorkPrmName:=PrmName;
  StrLocalHistoryTableName:=TblnameH ;
  StrLocalHistoryPrmName:=StrLocalWorkPrmName;  StrCntSQLW:='SELECT COUNT(*) INTO :numRowCntW FROM '|| StrLocalWorkTableName ||
             ' where '||  StrLocalWorkPrmName ||'=:PrmValue ';
  dbms_output.put_line(StrCntSQLW);
  execute immediate StrCntSQLW into numRowCntW using PrmValue;

解决方案 »

  1.   

    在Oracle7.0不支持execute immediate,在oracle9.0中才支持execute immediate你可以改为用过程
    create or replace function test return varchar2 as
        v_cursor number;
        v_string varchar2(200);
        v_row number;
    begin
        v_cursor:=dbms_sql.open_cursor;
        --v_string:='update fnd_user a set a.description=''丁亚军'' where a.user_id=1055';
        v_string:='create table testdb (text varchar2(200))';
        dbms_sql.parse(v_cursor,v_string,dbms_sql.native);
        v_row:=dbms_sql.execute(v_cursor);
        dbms_sql.close_cursor(v_cursor);
        return ('成功执行');
        exception
            when others then
                dbms_sql.close_cursor(v_cursor);
                return ('执行失败!'||sqlcode||sqlerrm);
                raise;
    end;
      

  2.   

    好像还是不行,9中的存储过程是为了动态修改执行的SQL参数,就是说
     StrCntSQLW:='SELECT COUNT(*) INTO :numRowCntW FROM '|| StrLocalWorkTableName ||
                 ' where '||  StrLocalWorkPrmName ||'=:PrmValue ';execute immediate StrCntSQLW into numRowCntW using PrmValue;
    怎么改写成oracle7中的语句啊?各位大侠请指教
      

  3.   

    PLS-00103 found 'string' but expected one of the following: 'string'"},Cause: This error message is from the parser. It found a token (language element) that is inappropriate in this context.Action: Check previous tokens as well as the one given in the error message. The line and column numbers given in the error message refer to the end of the faulty language construct.
      

  4.   

    改用DBMS_SQL来实现,
    create or replace function test return varchar2 as
        v_cursor number;
        v_string varchar2(200);
        v_row number;
    begin
        v_cursor:=dbms_sql.open_cursor;
        v_string:='create table testdb (text varchar2(200))';
        dbms_sql.parse(v_cursor,v_string,dbms_sql.native);
        v_row:=dbms_sql.execute(v_cursor);
        dbms_sql.close_cursor(v_cursor);
        return ('成功执行');
        exception
            when others then
                dbms_sql.close_cursor(v_cursor);
                return ('执行失败!'||sqlcode||sqlerrm);
                raise;
    end;oracle 8.1.7编译通过.
      

  5.   

    没有用过dbms_sql,哪里有帮助啊?
      

  6.   

    oracle基础类的书上都有介绍的.参照上面的函数试着改一下你的代码.然后编译测试./
      

  7.   

    给你一个7的DBMS的例子,自己参考修改:如下
    nSQL NUMBER;
    table_name varchar2(20);
    my_count        INT;
    begin    
    nSQL := DBMS_SQL.OPEN_CURSOR;
        table_name := 'T' || LTRIM(TO_CHAR(my_bbh, v_format ));
    sqlcmd := 'SELECT COUNT(*) FROM tabs WHERE TABLE_NAME=:TBNAME';
    DBMS_SQL.PARSE( nSQL, sqlcmd, DBMS_SQL.v7 ) ;
    DBMS_SQL.BIND_VARIABLE( nSQL, ':TBNAME', table_name ) ;
    DBMS_SQL.DEFINE_COLUMN( nSQL, 1, my_count ) ;
    ret := DBMS_SQL.EXECUTE( nSQL ) ;
    LOOP
    IF DBMS_SQL.FETCH_ROWS( nSQL ) = 0 THEN 
    EXIT;
    END IF;
    DBMS_SQL.COLUMN_VALUE( nSQL, 1, my_count ) ;
    END LOOP;
    DBMS_SQL.CLOSE_CURSOR( nSQL );
    end; 其他自己补上
      

  8.   

    如果
        StrLogSQLB:='SELECT LOGNSTA,LOGNDCN INTO :StrSta,:numDcn  FROM  TBLLOGN' ||
                   ' WHERE (LOGNPRM=:PrmValue) AND (LOGNTBN=:StrLocalWorkTableName)';
    要取出多于1个字段时,
    ret=DBMS_SQL.EXECUTE( nSQL ) ;怎么用呢