2013-10-22 22 views
0

問題:我試圖檢查表中是否有可用的記錄。對於這個檢查,我使用兩列id和isAlive。不存在子句給出無效數字錯誤

Insert into table1 (id,name,isAlive) 
    Select t2.id, 
     t2.name, 
     null as isAlive 
    From table2 t2 
    Where Not exist (select 1 
         from table1 t1 
         where t1.id=t2.id 
         and t1.column2 is null) 

Table1 Data: 
{id,name,isAlive} 
{123,'Test','Y'} 
{234,'Test1',null} 

Table2 Data: 
{id,name} 
{123,'Test'} 
{234,'Test1'} 
{456,'Test2'} 

當我嘗試在t1表中插入456,我的SQL與下面的錯誤

ORA-01722: invalid number 
01722. 00000 - "invalid number" 
*Cause:  
*Action: 
+3

您可能試圖將一個varchar2列插入到數字列中。你認爲varchar列有數字,但它只需要1行就可以得到這個錯誤 – tbone

+0

查詢工作正常,如果我有包含t1.column2的記錄爲空,但如果沒有找到空記錄時會給出錯誤 – sharadborhade

+4

請顯示COMPLETE和EXACT錯誤消息和您的表架構定義。我們不介意讀者。 – OldProgrammer

回答

0

列一個失敗的是varchar,而我以編號 由於比較它。已解決

相關問題