2016-05-12 63 views
-1

當前我正在將Sybase存儲過程遷移到Oracle。一旦我在Oracle中遷移了SP並調試了SP,它就拋出了多個語法錯誤。將Sybase存儲過程轉換爲Oracle時出現編譯時錯誤

目前我被困在一個SP中,我有一種情況使用一個選擇語句。

CREATE OR REPLACE PROCEDURE proc1 
(var1 IN VARCHAR2 DEFAULT NULL , 
    var2 IN NUMBER DEFAULT NULL) 
AS 
BEGIN 
    Select 
     (SELECT display_value 
       FROM table1) AS COLONE, 
      CASE a.someColumn 
       WHEN 0 THEN NULL 
      ELSE CAST(CAST(a.someColumnAS VARCHAR2(8)) AS DATE) 
       END someColumn, 
      (SELECT col1 
       FROM someTable 
       WHERE TabCod = 'STATUS' 
         AND LinCod = a.col) COLTWO, 
      (SELECT DESCRIPTION 
       FROM table 
       WHERE column = CAST(a.col AS NUMBER(18)) 
         AND inactive_dt IS NULL) ColThree, 
      (SELECT LinVal 
       FROM table 
       WHERE TabCod = 'EXTCOLTR' 
         AND LinCod = a.column) ColFour, 
      a.SeqIdentifier , 
      c.NAME 
     FROM FirstTable a, 
      SecondTable b, 
      ThirdTable c 
     WHERE a.CustAccount = var1 
       AND a.SeqIdentifier = var2 
       AND b.CustAccount = a.CustAccount 
       AND b.SeqIdentifier = a.SeqIdentifier 
       AND c.CustAccount = a.CustAccount 
       AND c.SeqIdentifier = a.SeqIdentifier 
     GROUP BY a.CustAccount,a.SeqIdentifier,a.Clo1,a.Col2,a.Col3,a.Col4,a.Col5,c.NAME; 
END proc1; 

我已經解決了,除了一個錯誤,是後BEGIN陸續因一個select語句幾乎所有的錯誤。

如何解決此錯誤?

+0

您還沒有包括你的錯誤。你在第一個'cast()'的'AS'之前缺少一個空格,開始時,你的兩個參數都被稱爲'var1',但不知道編輯過程中會發生什麼,以隱藏真實的表名等。錯誤堆棧通常指向錯誤所在的行和字符編號 - 它並不總是有幫助,但它是一個很好的起點。 –

+1

你必須選擇你的查詢INTO東西 – thatjeffsmith

+0

錯誤是錯誤(10,3):PL/SQL:SQL語句被忽略。 –

回答

0

下面是一些提示,請執行這些

SELECT (SELECT display_value 
      FROM table1) AS colone --remove that select from here 
     ,CASE a.somecolumn 
     WHEN 0 THEN 
      NULL 
     ELSE 
      CAST(CAST(a.somecolumnas VARCHAR2(8)) AS DATE) -- fix that CAST 
     END somecolumn 
     ,(SELECT col1 
      FROM sometable 
     WHERE tabcod = 'STATUS' 
      AND lincod = a.col) coltwo --remove that select from here 
     ,(SELECT description 
      FROM TABLE 
     WHERE column = CAST(a.col AS NUMBER(18)) 
      AND inactive_dt IS NULL) colthree --remove that select from here 
     ,(SELECT linval 
      FROM TABLE 
     WHERE tabcod = 'EXTCOLTR' 
      AND lincod = a.column) colfour --remove that select from here 
     ,a.seqidentifier 
     ,c.name 
    FROM firsttable a 
     ,secondtable b 
     ,thirdtable c 
     --make joins for "table1", "sometable" and "TABLE" 

WHERE a.custaccount = var1 
    AND a.seqidentifier = var2 
    AND b.custaccount = a.custaccount 
    AND b.seqidentifier = a.seqidentifier 
    AND c.custaccount = a.custaccount 
    AND c.seqidentifier = a.seqidentifier 
GROUP BY a.custaccount  --what is that group by here? 
     ,a.seqidentifier 
     ,a.clo1 
     ,a.col2 
     ,a.col3 
     ,a.col4 
     ,a.col5 
     ,c.name 
+0

Oracle預測中允許嵌套選擇。所以不知道這些建議是多麼有幫助。 – APC

+0

他們被允許,但我不認爲他們被推薦...我從來沒有見過一個開發人員使用,因爲它是導致 - >「(SELECT display_value FROM table1)作爲colone」我不認爲是允許或有效的 – Thomas