declare
tablenames varchar2(50);
var_sql varchar2(200);
Cursor tablename_cursor is
select t.table_name from user_tab_comments t where t.table_name like 'EXIT2010010500%';
begin
open tablename_cursor;
loop
fetch tablename_cursor into tablenames;
exit when tablename_cursor%notfound;
if tablename_cursor%found then
var_sql:='update test.'||tablenames||' t set t.vehiclelicense=t.vehiclelicenseauto where t.vehiclelicense=||' '; execute immediate var_sql;
end if;
end loop;
close tablename_cursor;
end;
问题:
var_sql:='update test.'||tablenames||' t set t.vehiclelicense=t.vehiclelicenseauto where t.vehiclelicense=||' ';这句中的空格一直显示错误。用了vehiclelicense is null也不行,用length(vehiclelicense)=0也不行,请大家帮忙看看!
------解决方案--------------------------------------------------------
先对vehiclelicense字段trim一下,length(trim(vehiclelicense))=0
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
报错的信息没有帖出来啊。
另外,如果匹配不上 空格,也不会报错啊。 最多就是没一条记录,被UPDATE而已,不会影响执行。
怀疑,如果是报错,那就是语法没有通过。
感觉最有问题的是这部分
t.vehiclelicense=||' '
要用引号,应当再加个引号
t.vehiclelicense=||'' ''
------解决方案--------------------------------------------------------
怎么感觉引号多一个啊~~~
var_sql:='update test.'||tablenames||' t set t.vehiclelicense=t.vehiclelicenseauto where t.vehiclelicense is null '; execute immediate var_sql;