在期待以下sql之一时遇到符号“@”

时间:2014-02-27 14:21:27

标签: sql oracle

我正在尝试创建一个存储过程,将马添加到我当前的表中,但我收到此错误。有谁知道为什么会出现这个错误?

    CREATE OR REPLACE PROCEDURE ADDHORSE (
 HorseID IN INTEGER,
 Stable IN VARCHAR2,
 Horse_Name IN VARCHAR2,
 DateofBirth IN DATE,
 Sex Char:=1);
 Height FLOAT,
 Dam VARCHAR2:=30),
 Sire VARCHAR2:=30)
)

 AS 
 BEGIN
  INSERT INTO horse(
      [HorseID],
      [Stable],
      [Horse_Name],
      [DateofBirth],
      [Sex],
      [Height],
      [Dam],
      [Sire]
  ) VALUES (
      HorseID,
      Stable,
      Horse_Name,
      DateofBirth,
      Sex,
      Height,
      Dam,
      Sire
 )
END ADDHORSE;

2 个答案:

答案 0 :(得分:2)

我注意到您的'varchar以及遗失的'{'}缺少引号(char)在insert

的末尾

这对我有用:

CREATE OR REPLACE PROCEDURE ADDHORSE (
 HorseID IN INTEGER,
 Stable IN VARCHAR2,
 Horse_Name IN VARCHAR2,
 DateofBirth IN DATE,
 Sex Char := '1',
 Height FLOAT,
 Dam VARCHAR2 := '30',
 Sire VARCHAR2 := '30'
)
 AS 
 BEGIN
     INSERT INTO horse(
      HorseID,
      Stable,
      Horse_Name,
      DateofBirth,
      Sex,
      Height,
      Dam,
      Sire
  ) VALUES (
      HorseID,
      Stable,
      Horse_Name,
      DateofBirth,
      Sex,
      Height,
      Dam,
      Sire
 );
END ADDHORSE;

答案 1 :(得分:1)

你的参数列表中有一个分号和一个额外的括号,这对你有用吗......

CREATE PROCEDURE ADDHORSE (
     HorseID INTEGER,
     Stable VARCHAR2,
     Horse_Name VARCHAR2,
     DateofBirth DATE,
     Sex CHAR(1),
     Height FLOAT,
     Dam VARCHAR2(30),
     Sire VARCHAR2(30)
)

 AS 
 BEGIN
      INSERT INTO horse(
          [HorseID],
          [Stable],
          [Horse_Name],
          [DateofBirth],
          [Sex],
          [Height],
          [Dam],
          [Sire]
      ) VALUES (
          HorseID,
          Stable,
          Horse_Name,
          DateofBirth,
          Sex,
          Height,
          Dam,
          Sire
     )
END ADDHORSE;