将Sybase存储过程转换为Oracle时出现编译时错误

时间:2016-05-12 13:49:39

标签: oracle stored-procedures

目前我正在将Sybase存储过程迁移到Oracle。一旦我在Oracle中迁移SP并调试SP,它就会抛出多个语法错误。

目前我被困在一个SP中,我遇到一个接一个的select语句。

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语句引起的。

如何解决此错误?

1 个答案:

答案 0 :(得分: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