我无法找到引用字符串未正确结束的错误。我到处寻找,我的语法似乎是正确的。这个问题只出现在我引入if语句时。任何想法,将不胜感激。谢谢。如果您需要更多信息,请与我们联系。
declare
bk_id book.book_code%type;
bk_authorName author.author_first%type;
bk_authorLastName author.author_last%type;
bk_title book.title%type;
bk_pubcode book.publisher_code%type;
bk_category book.type%type;
bk_price book.price%type;
bk_paper book.paperback%type;
TempData := 10;
cursor book_cursor is select author.author_first, author.author_last, book.title, book.type, book.price from book, author, wrote where book.book_code=wrote.book_code and author.author_num=wrote.author_num;
begin
open book_cursor;
dbms_output.put_line('First Name Last Name Title Type Price');
dbms_output.put_line('________________________________________________________________________');
dbms_output.put_line('Date: '||Systimestamp);
loop
fetch book_cursor into bk_authorName, bk_authorLastName, bk_title, bk_category, bk_price;
if(bk_price<TempData) then
dbms_output.put_line(bk_authorName || ' ' || bk_authorLastName || ' ' || bk_title || ' ' || bk_category || ' ' || bk_price || 'Special Deal');
else
dbms_output.put_line(bk_authorName || ' ' || bk_authorLastName || ' ' || bk_title || ' " || bk_category || ' ' || bk_price);
end if;
exit when book_cursor%notfound;
end loop;
close book_cursor;
end;
答案 0 :(得分:0)
实际上这种语法的问题是你使用双引号而不是单引号。 这是更正后的代码。试试这个,它应该有用。
declare
bk_id book.book_code%type;
bk_authorName author.author_first%type;
bk_authorLastName author.author_last%type;
bk_title book.title%type;
bk_pubcode book.publisher_code%type;
bk_category book.type%type;
bk_price book.price%type;
bk_paper book.paperback%type;
TempData := 10;
cursor book_cursor is select author.author_first, author.author_last, book.title, book.type, book.price from book, author, wrote where book.book_code=wrote.book_code and author.author_num=wrote.author_num;
begin
open book_cursor;
dbms_output.put_line('First Name Last Name Title Type Price');
dbms_output.put_line('________________________________________________________________________');
dbms_output.put_line('Date: '||Systimestamp);
loop
fetch book_cursor into bk_authorName, bk_authorLastName, bk_title, bk_category, bk_price;
if(bk_price<TempData) then
dbms_output.put_line(bk_authorName || ' ' || bk_authorLastName || ' ' || bk_title || ' ' || bk_category || ' ' || bk_price || 'Special Deal');
else
dbms_output.put_line(bk_authorName || ' ' || bk_authorLastName || ' ' || bk_title || ' ' || bk_category || ' ' || bk_price);
end if;
exit when book_cursor%notfound;
end loop;
close book_cursor;
end;