我有以下pl / sql块 我收到PL / SQL错误:数字或值错误:字符到数字转换错误 但我没有发现任何这样的转换问题 请帮忙
Oracle Pl / Sql Block
declare
Menu_Item_ID integer :=80;
SelectedColumns varchar2(800):='';
IsBlank Number(2);
V_Column_Name varchar2(150);
V_Column_Name_Value Varchar2(200);
V_Url_Column_Name varchar2(100);
SelectedColumnsTemp varchar(8000):=SelectedColumns;
cursor c1 is
Select Column_Name,Column_Name_Value,Url_Column_Name
From COM_MST_REPORT_DEFAULT_COLUMN
Where Link_ID = Menu_Item_ID;
Begin
if SelectedColumnsTemp = ''
then
IsBlank := 1;
Else
IsBlank := 0;
End if;
FOR DefaultColumns in c1
LOOP
V_Column_Name := '';
V_Column_Name_Value := '';
V_Url_Column_Name := '';
V_Column_Name := '"' + TO_CHAR(DefaultColumns.Column_Name) + '"';
V_Column_Name_Value := TO_CHAR(DefaultColumns.Column_Name_Value);
V_Url_Column_Name := TO_CHAR(DefaultColumns.Url_Column_Name);
if(nvl(V_Url_Column_Name,'') <> '')
then
V_Column_Name_Value := V_Url_Column_Name + ' as ' + V_Column_Name;
Else
V_Column_Name_Value := V_Column_Name_Value + ' as ' + V_Column_Name;
End if;
if IsBlank = 0
then
SelectedColumnsTemp := replace(SelectedColumnsTemp,V_Column_Name,V_Column_Name_Value);
Else
SelectedColumnsTemp := SelectedColumnsTemp + V_Column_Name_Value + ',';
End if;
END LOOP;
DBMS_OUTPUT.PUT_LINE(SelectedColumnsTemp);
End;
答案 0 :(得分:1)
在Oracle中,字符串由||
连接(或CONCAT()
鲜为人知)而不是+
e.g。
V_Column_Name := '"' || TO_CHAR(DefaultColumns.Column_Name) || '"';
而不是
V_Column_Name := '"' + TO_CHAR(DefaultColumns.Column_Name) + '"';