Home » SQL & PL/SQL » SQL & PL/SQL » Oracle and PL/SQL Help -Need some help please
Oracle and PL/SQL Help -Need some help please [message #8033] Tue, 22 July 2003 19:10 Go to next message
Nazma Bepat
Messages: 34
Registered: May 2003
Member
Can someone please help me out. I am stuck.
I would like to correct the following code to display “That Meat is Top Quality” , if the Grade Value entered is 4. Would someone be willing to help me find the problems with the code below and help me to make the necessary corrections?

#include <iostream>
using std::cout;
using std::endl;

int main()
{
int gradeValue;
cout >> “Enter the Grade Value: “
cin << gradevalue;
if (gradeValue = 4)
cout >> “That meat is Top Quality!”

return 0;
}
Re: Oracle and PL/SQL Help -Need some help please [message #8044 is a reply to message #8033] Wed, 23 July 2003 00:36 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
In PL/SQL it would be something like:
ACCEPT grade number PROMPT 'Enter grade: '
Begin
  If &grade = 4 Then
    Dbms_Output.Put_line('That meat is Top Quality!');
  End If;
End;


Put this code in a SQL script (yourfile.sql) and run it in SQL*Plus by using:
SQL> @yourfile.sql
or
SQL> STA[RT] yourfile.sql
A Procedure is possible too, and that would look like:
Procedure get_meat(p_grade in number)
Is
Begin
  If p_grade = 4 Then
    Dbms_Output.Put_line('That meat is Top Quality!');
  End If;
End;
In order to use DBMS_OUTPUT, you should enable the server output by entering
SQL> SET SERVEROUT[[PUT]] ON.

HTH,
MHE
Re: Oracle and PL/SQL Help -Need some help please [message #8047 is a reply to message #8033] Wed, 23 July 2003 03:36 Go to previous messageGo to next message
Shadab Anwer
Messages: 1
Registered: July 2003
Junior Member
#include <iostream.h>
using std::cout;
using std::endl;

int main()
{
int gradeValue;
cout >> “Enter the Grade Value: “
cin << gradevalue;
if (gradeValue == 4)
/* in if u r using = then it is Assignment operator in cpp, Comparison operator is ==
*/
cout >> “That meat is Top Quality!”

return 0;
}

Byeee take care
Re: C++ Programming -Need some help please [message #8051 is a reply to message #8033] Wed, 23 July 2003 09:13 Go to previous messageGo to next message
nazma
Messages: 2
Registered: July 2003
Junior Member
Sorry, I messed up.

It is C++ programming.

Nazma
Re: Oracle and PL/SQL Help -Need some help please [message #8056 is a reply to message #8047] Wed, 23 July 2003 17:58 Go to previous messageGo to next message
nazma
Messages: 2
Registered: July 2003
Junior Member
Shadab,

Thanks for your help. I am so sorry to put this C++ question on the Oracle forum. I really mean to say that it is a C++ question.

Would your answer be the same for C++?

Thanks

Nazma
C++ -Need some help please [message #8101 is a reply to message #8047] Sat, 26 July 2003 18:27 Go to previous message
Nazma Bepat
Messages: 34
Registered: May 2003
Member
I am trying to understand the difference between preincrement and postincrement. Is it possible for you to look at the following code and let me know the value of total when exiting each of the following while repetition structures (enter your answer after each while repetition structure):

int x = 1, total = 0;
while ( ++x <= 5 ) {
total += x;
}

int x = 1, total = 0;
while ( x++ <= 5 ) {
total += x;
}
Previous Topic: SUBQUERY HELP
Next Topic: Sequences
Goto Forum:
  


Current Time: Fri Apr 19 21:56:03 CDT 2024