2016-03-28 33 views
0

在SQL Server存儲過程我有這樣的代碼:PL-SQL等同於T-SQL 「UPDATE FROM」 子句臨時表

UPDATE #tbinforesult 
SET prifix = '' 
FROM #tbmax t 
    INNER JOIN #tbinforesult i 
     ON i.prifix = t.prifix 
      AND i.PropertyID = t.PropertyID 
      AND i.GroupID = t.GroupID 
      AND i.NID <> t.id 

什麼是PL-SQL相當於用不PL-SQL集合全球臨時表?

回答

1

TSQL:

UPDATE 
    Table_A 
SET 
    Table_A.col1 = Table_B.col1, 
    Table_A.col2 = Table_B.col2 
FROM 
    Some_Table Table_A 
INNER JOIN 
    Other_Table Table_B 
ON 
    Table_A.id = Table_B.id 
WHERE 
    Table_A.col3 = 'cool' 

PLSQL:

UPDATE table1 t1 
    SET (name, desc) = (SELECT t2.name, t2.desc 
         FROM table2 t2 
         WHERE t1.id = t2.id) 
WHERE EXISTS (
    SELECT 1 
     FROM table2 t2 
    WHERE t1.id = t2.id) 

OR:

UPDATE (SELECT t1.id, 
       t1.name name1, 
       t1.desc desc1, 
       t2.name name2, 
       t2.desc desc2 
      FROM table1 t1, 
       table2 t2 
     WHERE t1.id = t2.id) 
    SET name1 = name2, 
     desc1 = desc2 

來源:enter link description here

+1

的代碼是在T-SQL,我想在等效pl-sql不是t-sql? – SajjaD

+1

試試這個:http://www.techonthenet.com/oracle/update.php – SnakeFoot

+0

感謝您的回覆,但我怎樣才能做到這一點與pl-sql集合,特別是與嵌套表? – SajjaD