因为VF里导出TAB分隔符的TXT,然后通过SQLLOADER导入ORACLE里,所有字符型字段均会自动加上引号,
导入ORACLE后需将双引号去除,代码如下,但是在第16行报错,帮忙看下:
ora-06550: line 16,column 39:
pl/sql:ora-00904: : invalid identifier
ora-06550,column 5:
pl/sql:sql statement ignored。
以下这段代码是在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;
导入ORACLE后需将双引号去除,代码如下,但是在第16行报错,帮忙看下:
ora-06550: line 16,column 39:
pl/sql:ora-00904: : invalid identifier
ora-06550,column 5:
pl/sql:sql statement ignored。
以下这段代码是在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;
一般直接用用PLSQL DEV直接导入
现在是要解决这个问题哦。还请帮忙看一下。
update gzyhfx set row.column_name=replace(row.column_name, ' " ', ' ');
这一句代码有问题,gzyhfx这个表的字段用row.column_name表达好像不行。求解决方法(详细代码)
--你这是在改变游标的值啊,肯定有问题啊,为什么要改变游标的值呢?
update gzyhfx set row.column_name=replace(row.column_name, ' " ', ' ');
我是要把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
execute immediate yoursql;
这个是没有返回结果的,你要注意!