DECLARE DBName VARCHAR(100); ApplicationURL VARCHAR(100);
BEGIN
select NAME into DBName FROM v$database;
IF DBName = 'WAMDEV' THEN ApplicationURL := 'http://srpwam10:9080/maximo';
ELSIF DBName ='WAMDEVPJ' THEN ApplicationURL := 'http://srpwam10:9080/maximo';
ELSIF DBName = 'WAMTST' THEN ApplicationURL := 'http://wamtest/maximo'
ELSIF DBName = 'WAMTSTPJ' THEN ApplicationURL := 'http://wamtest/maximo'
ELSIF DBName = 'WAMQA' THEN ApplicationURL := 'http://wamqa/maximo'
ELSIF DBName = 'WAMQAPJ' THEN ApplicationURL := 'http://wamqa/maximo'
ELSE DBName = 'WAMP' THEN ApplicationURL := 'http://wam/maximo'
END IF ;
DBMS_OUTPUT.PUT_LINE(ApplicationURL)
END
它给了我错误: ORA-06550:第9行,第7栏: PLS-00103:遇到以下任何一种情况时遇到符号“ELSIF”:
答案 0 :(得分:1)
添加了您缺少的半冒号
DECLARE
DBNAME VARCHAR(100);
APPLICATIONURL VARCHAR(100);
BEGIN
SELECT NAME INTO DBNAME FROM V$DATABASE;
IF DBNAME = 'WAMDEV' THEN
APPLICATIONURL := 'http://srpwam10:9080/maximo';
ELSIF DBNAME = 'WAMDEVPJ' THEN
APPLICATIONURL := 'http://srpwam10:9080/maximo';
ELSIF DBNAME = 'WAMTST' THEN
APPLICATIONURL := 'http://wamtest/maximo';
ELSIF DBNAME = 'WAMTSTPJ' THEN
APPLICATIONURL := 'http://wamtest/maximo';
ELSIF DBNAME = 'WAMQA' THEN
APPLICATIONURL := 'http://wamqa/maximo';
ELSIF DBNAME = 'WAMQAPJ' THEN
APPLICATIONURL := 'http://wamqa/maximo';
ELSE
DBNAME := 'WAMP';
APPLICATIONURL := 'http://wam/maximo';
END IF;
DBMS_OUTPUT.PUT_LINE(APPLICATIONURL);
END;
也可以使用CASE声明,在某些人看来,它看起来更干净。