因为VF里导出TAB分隔符的TXT,然后通过SQLLOADER导入ORACLE里,所有字符型字段均会自动加上引号,
导入ORACLE后需将双引号去除,代码如下,但是在第16行报错,帮忙看下。以下这段代码是在PL/SQL
里运行的:
DECLARE
  CURSOR cur IS
    select column_name from USER_TAB_COLUMNS where lower(table_name)='gzyhfx' and data_type='VARCHAR2';
  V_COUNTER NUMBER;
  v_count number;
BEGIN
V_COUNTER := 0;
v_count:=0;
execute immediate 'truncate table hbh_3g_promotion_count';
commit;
insert into hbh_3g_promotion_count(col1,col2) VALUES('统计开始',sysdate);
update hbh_3g_promotion_count set zs=(select count(*) from USER_TAB_COLUMNS where (table_name)='GZYHFX' and data_type='VARCHAR2');
commit;
  FOR row IN cur LOOP    update gzyhfx set row.column_name=replace(row.column_name,'"','');
    commit;
     V_COUNTER := V_COUNTER + 1;
   v_count:=v_count+1;
   update hbh_3g_promotion_count set js=v_count;--计算更新的条数
     commit;
  END LOOP;
   update hbh_3g_promotion_count set col3=sysdate;
   update hbh_3g_promotion_count set time=ROUND(TO_NUMBER(col3 - col2) * 24 * 60 * 60);--计算程序运行秒数
  commit;
END;

解决方案 »

  1.   

    ora-06550: line 16,column 39:
    pl/sql:ora-00904: : invalid identifier
    ora-06550,column 5:
    pl/sql:sql statement ignored
      

  2.   


    --同样的问题,看上一个帖子
    update   gzyhfx   set   row.column_name=replace(row.column_name, ' " ', ' '); 
      

  3.   

    update   gzyhfx   set   row.column_name=replace(row.column_name, ' " ', ' '); 
    有问题的应该是这一句,就是如何表达表中字段名这个地方update   gzyhfx   set   row.column_name
    这个地方,字段名是个变量
      

  4.   


    我是要把gzyhfx表中的字符型字段的双引号去除,我也觉得是这里有问题,但是要如何表达这个字段名称呢?
    用动态变量好像也不行:
     v_column varchar2(100);   
    select column_name into v_column from USER_TAB_COLUMNS where lower(table_name)= 'gzyhfx' and column_name=row.column_name;
    update gzyhfx set ('||v_column||')=replace('||v_column||', ' " ', ' ');   
    也是报错哦
    invalid user.table.column,table.column,or column specification
      

  5.   

    你这个样子,无论怎么拼写都是不行的,因为你的sql是属于动态sql文,你可以这样做,
    首先把你的sql还是用你上面的写法拼好,然后将拼好的sql赋值给一个变量,然后用exec sql的形式来执行动态的sql文就可以了
      

  6.   

    update gzyhfx set row.column_name=replace(row.column_name, ' " ', ' '); 
    commit; 
    .........................
    1.这是要干什么?  row.column_name是列名而不是 值
    2.有row.column_name应该用execute immediate