Dear student, welcome to Gate Smashers In this video I'm going to example PL-SQL pro grammes for beginner So I'll tell you that on PL-SQL first video I've uploaded long time ago on the PL-SQL basic block what it is, its basic structure I've told you about each and every point Link of that you'll get in description box But here I'm going to start with program I'll discuss 2 programer in this video. first we'll discuss about and with that I'm also telling you its execution also I'll show here don't worry don't think that how I'll execute on
board, that I'll not do on board you'll see the execution on Oracle live at the end of the video Here I'll tell you some important points Even in description box all the major programer of PL-SQL So file of that also you'll get there So guys I'm giving so this much so in return there is a demand to subscribe the channel if haven't done yet and if you've subscribed also so please do it from other devices also So I can only request you that’s all so lets start with the video So here first program is find
the sum of 2 numbers So if we talk about sum of 2 numbers So see whatever it the programming logic of that remains same somehow but major difference is of syntax Here what we've this is called declarative section means here we declare So then from begin till end we executable section where we write executable commands So here we've to do sum of 2 numbers a int , remember this only that is a normal programming int a and int b so here a int, b int and c int so we've to write in such way then
after begin we wrote a:= here assignment, normal assignment that we do in C+ here we do := So := and here I've written &a; Actually it is like this a:=10 a:=10 here if you want to give direct value that also you can do and if you want to take value from user you can take it from user using &% so I'm telling you these small points because because sometimes question on these can be asked in your interview or viva so it is important there On competitive exams there are not much questions on these so there
chances are less So see &a, &b we used to take user input then C=a+b c:=a+b sum of both is inserted in c, as we do normally this is important dbms_output.put_line dbms_output.put_line meaning of this line in actual is Print F like in c, print F and in C++, we write c out just to print the value there is not shortcut of this line, this is actually this big line you've to remember it as is Rest again if there is sum of a and b we write this in single quotes and here or symbol ( straight line
) with that we've written c and this is braces are closed and here I've written ; here always ; will come apply end, as this is your begin and this is your end open parenthesis and close that is here so this was your executive part and this is your declarative I'll show you this by executing then you'll know that how this shows output so there it is sum of 2 number then greatest of 2 numbers In greatest of 2 number we'll talk about if and else then you'll have idea also of if/else that how we
use and what is the syntax So see Declare and a,b 2 variable I've taken here data type of both we've taken int begin here and executable part starts from here So from begin to end there is all executable part So see a:=&a if you want to give direct value that you can give 10,20,30 anything and if want to take from user then &a and &b if a > b, as we write normally then, here we write then again there is dbms_output.put_line( a is greater ) else b is greater so print that or if you want
values to be print then same that we did here with this anything that you want to print a or here you want to print b, so this way you can amend this so here it is So at last I'll tell you an important point that it is very important to end if this is end of begin but here end of if also very important otherwise it will show error so end if is very important here So this is the basic program Now we'll see its execution Lets see the execution part so see here same to
find the sum of two number program I've written here So we'll copy this and move to oracle live so oracle live you only need to log in by adding you user name and name and all you've log in, a user mail will come to you So you can use it online here I've pasted after pasting I've, will show you a little by zooming So like this we've pasted and this from here we run so as soon as we run this and error came this error I'll tell you it is not that I did it earlier
and then I'm showing you I'm showing you this purposely so that you get to know about error also because if you learn programming through errors then you can learn more because you get to know that what type of error is coming and how to remove it So here error is, there is error in line number 6 and that & & So I'll tell you that I already told you that why we use & we use it to take input form the users but in live this actually don't work So in live we've to give direct
value like we've given 10 and here I've given 20 Will tell you that it don't work in live but if you download in your system like oracle 10 or 12 it will there so I've given 10 and 20 value here so will run it and as soon as I run this So here it is showing output that is sum of a and b is 30 so whatever changes you want to do in this like sum of a and b = so that you can see properly So this is our program and sum of a and
b =30 So like this we executive our program So next if we talk about another program So see other program also Greatest of 2 number So in greatest of 2 number So we copied the code and there we've just pasted it you don't to copy and paste code Code we need to write, but I've written there so I'm pasting from there only please don't say this that I myself is doing copy paste there I've written myself so again here there will be & error So I'll change its value prior only, lets say we've done its
value 10 and 20 now we'll simply run this So see A value is 10 and B is 20 So it is showing that b is greater B is greater only if you want to print value you can do that by adding simply or and ad or symbol in this also So will run program again so see b is greater and value of b is 20 So you can print in any way that you want Note this small points if asked in your viva or interview so you can answer this thank you