这个函数可以给出错误解决错误 [英] this function can given error solve error

查看:69
本文介绍了这个函数可以给出错误解决错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

create or replace function givegrade(p in number) return char is g char(15);
 begin
    if p >= 70 then
            g:='Distinction';

            return g;
    elsif p >= 60 then
            g:='First';
            return g;
    elsif p>= 50 then
            g:='Pass';
            return g;
    else
            g:='Fail';
            return g;
    end if;
 end;







给出错误

======================

消息156,级别15,状态1,第1行

关键字'或'附近的语法不正确。

消息156,等级15,状态1,行3

附近的语法不正确关键字'then'。

消息178,级别15,状态1,行6

带有返回值的RETURN语句不能在此上下文中使用。

消息132,级别15,状态1,行8

标签'g'已经被声明。标签名称在查询批处理或存储过程中必须是唯一的。

消息178,级别15,状态1,行9

不能使用带返回值的RETURN语句在这种情况下。

消息132,级别15,状态1,行11

标签'g'已经被声明。标签名称在查询批处理或存储过程中必须是唯一的。

消息178,级别15,状态1,行12

不能使用带返回值的RETURN语句在这种情况下。

消息132,级别15,状态1,行14

标签'g'已经被声明。标签名称在查询批处理或存储过程中必须是唯一的。

消息178,级别15,状态1,行15

不能使用带返回值的RETURN语句在这个上下文中。




error given
======================
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'or'.
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'then'.
Msg 178, Level 15, State 1, Line 6
A RETURN statement with a return value cannot be used in this context.
Msg 132, Level 15, State 1, Line 8
The label 'g' has already been declared. Label names must be unique within a query batch or stored procedure.
Msg 178, Level 15, State 1, Line 9
A RETURN statement with a return value cannot be used in this context.
Msg 132, Level 15, State 1, Line 11
The label 'g' has already been declared. Label names must be unique within a query batch or stored procedure.
Msg 178, Level 15, State 1, Line 12
A RETURN statement with a return value cannot be used in this context.
Msg 132, Level 15, State 1, Line 14
The label 'g' has already been declared. Label names must be unique within a query batch or stored procedure.
Msg 178, Level 15, State 1, Line 15
A RETURN statement with a return value cannot be used in this context.

推荐答案

如何从sql server使用此查询



你不能。

SQL Server函数语法与Oracle不同:所以你需要为SQL重写它。



因为这是你的功课,我不打算为你做这件事!

从互联网上随机停止抓取代码片段,然后开始查看你的课程文档。你应该能够自己做 - 或者你的导师不会设置它 - 所以坐下来解决它。如果你不这样做,那么下周的任务会变得更加困难,因为它会假设你知道这些东西......
"how can used this query from sql server"

You can't.
SQL Server function syntax is different from Oracle: so you would need to rewrite it for SQL.

And since it is your homework, I'm not about to do it for you!
Stop grabbing code fragments at random from the internet, and start looking at your course documentation. You should be able to do this yourself - or your tutor would not have set it - so sit down and work it out. If you don;t do this yourself, then next weeks task is going to be even harder as it will assume that you know this stuff...


这篇关于这个函数可以给出错误解决错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆