Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL help needed in using Function inside query
PL/SQL help needed in using Function inside query [message #579900] Sun, 17 March 2013 01:52 Go to next message
ashishpatel1992
Messages: 38
Registered: February 2013
Location: India
Member
What Exactly I wanted to do is
To display highest marks,least marks,average marks,total marks of the student name entered.

desc stud;
Name Null? Type
----------------------------------------- -------- ----------------------------
SID NUMBER
NAME VARCHAR2(20)
M1 NUMBER
M2 NUMBER

How do I do that using PL/SQL and without Cursor.


Re: PL/SQL help needed in using Function inside query [message #579901 is a reply to message #579900] Sun, 17 March 2013 02:09 Go to previous messageGo to next message
ashishpatel1992
Messages: 38
Registered: February 2013
Location: India
Member
Here is Solution:-
declare
s stud%rowtype;
smax number;
savg number;
stot number;
begin
select sid,greatest(m1,m2),(m1+m2)/2,(m1+m2) into s.sid,smax,savg,stot
from stud where sid=&Student_id;
display('Student ID: '||s.sid||', Greatest: '||smax||', Avg Marks: '||savg||', Total Marks:'||stot);
end;
Re: PL/SQL help needed in using Function inside query [message #579903 is a reply to message #579901] Sun, 17 March 2013 02:14 Go to previous messageGo to next message
Michel Cadot
Messages: 59147
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
DISPLAY function does not exist.

Please format your code.
If you don't how to do it, learn it using SQL Formatter.

Regards
Michel

[Updated on: Sun, 17 March 2013 02:15]

Report message to a moderator

Re: PL/SQL help needed in using Function inside query [message #579906 is a reply to message #579903] Sun, 17 March 2013 05:54 Go to previous messageGo to next message
ashishpatel1992
Messages: 38
Registered: February 2013
Location: India
Member
Michel Cadot wrote on Sun, 17 March 2013 12:44
DISPLAY function does not exist.

Please format your code.
If you don't how to do it, learn it using SQL Formatter.

Regards
Michel


You can replace display with dbms_output.put_line
Re: PL/SQL help needed in using Function inside query [message #579908 is a reply to message #579906] Sun, 17 March 2013 06:02 Go to previous message
Michel Cadot
Messages: 59147
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
With any SQL or PL/SQL question, please, Post a working Test case: create statements for all objects so that we will be able work to reproduce what you have.

Please format your code.
If you don't how to do it, learn it using SQL Formatter.

Regards
Michel
Previous Topic: to look for data only for few days
Next Topic: Star printing in PL/SQL Program Problem
Goto Forum:
  


Current Time: Sun Sep 21 05:21:41 CDT 2014

Total time taken to generate the page: 0.07509 seconds