Placeholder Image

Subtitles section Play video

  • creating these classes requires equipment and service.

  • Is that cost money?

  • If you appreciate this education, please think about going to Eli the computer guy dot com and offering a one time or monthly recurring donation.

  • Welcome back.

  • As you know I am.

  • He like the computer guy, and in today's clients, we're going to be talking about stored functions within my sequel of database servers.

  • So it's toward functions allow you to do is they essentially allow you to manipulate data within your tables within your my sequel databases to the example that I'm going to be showing you today is, Let's imagine we're trying to figure out with the retail price four.

  • Our inventory items should be so we have a parts table that I've created a number of classes ago.

  • Within that part's table.

  • We have a number of different records for parts, and then we have the price for those parts.

  • Now, let's imagine the price for those parts is the price that we pay for those parts, and so we want to figure out how much the parts should be.

  • If we're going be selling them, tow our customers.

  • I'm going to say in this event that we're just simply putting a 25% markup on all the parts.

  • So if we purchased it for $10 then we will sell it for $12.50.

  • We purchased it for $1.

  • We'll sell it for a dollar and 25 cents.

  • And so what we're going to do is we're going to create a stored function that will go through, and it will do the math of based off of that 25% markup.

  • So we'll actually be able to go through, basically, do something along the lines of a select all statement.

  • And then what will happen is we'll see our price.

  • It will see the original price on one side, and then we'll see what the new retail price should be on the other.

  • So we're talking about functions.

  • This is the type of thing that we're that we're looking at with.

  • Functions is a lot of times this is going to be mathematical manipulation of data within your tables to provide you some type of results.

  • So again, trying to figure out, let's say, sale item.

  • So let's say you have the prices for your inventory.

  • What it normally is.

  • And now you want to do a 10% off sale for the day of the week, or whatever you can guess.

  • Input that 10% off within a store function, and then it will give you the price that you should be charging your customers.

  • Now, I will say, when you start getting into store functions like many things like you've probably heard this before, like many things in the mice Equal world.

  • Wow, You go really deep on this stuff.

  • You can go into a rabbit hole as far stored functions are concerned.

  • One of the problems that I run into as somebody trying to teach you about things like store functions is how to teach you enough.

  • So you get the idea of what's going on with trying to teach you so much that again you give up and go be a florist.

  • So if you like what you're seeing here and you want to learn more about store functions, we will doom or classes about this in the future.

  • But obviously, you know, as with everything in here, go do a Google search.

  • Take a look at what's stored functions will offer you because store functions if you need them.

  • Like if your particular environment needs sword functions.

  • Store functions could be absolutely amazing that they can provide you a lot of solutions to the problems that you're having.

  • But it's one of those things.

  • If it gets very Mathey very quick, I know a lot of that's one things like with I t people.

  • A lot of people out there surprisingly don't like math, something they don't like.

  • My hand is really bad, man.

  • And so when the problems you get into a storage functions is basically this is math or is basically like a lot of equation e type stuff.

  • And so one of the problems you can get into is when you're trying to do very complex functions.

  • If you're not used to math, and if you're not really sure what you're trying to accomplish, you can get to the point of getting frustrated very quickly and like I say, giving up.

  • So I'm going to show you a very basic example today, just to give you an idea of how the stored functions work.

  • If you need to know more about it, please go out there and do some more research.

  • This the rabbit hole of this goes really, really, really deep.

  • There's a lot of interesting things that you could d'oh, but to be clear, we're just glossing over the very, very top of this particular set of information just so that you don't get too confused when you're trying to learn about horning horning, Will Robinson, horny and Warning should probably come up with another phrase to say, Who knows who knows all the copyright infringement rules and laws out there that hate to get hate to get hit by saying the warning warning.

  • Will Robinson is that trademarked?

  • I don't know.

  • But anyways, there is a bit of a warning, a warning.

  • Will Robinson with this particular class, something that a lot of new people or people that might not be used to programming and databases may get confused about is Remember, whenever you're dealing with databases and whenever you're dealing with programming in general, there is what is cold.

  • There is permanent data and impermanent, so there's permanency and impermanent.

  • Why, that's important with what we're doing.

  • Only dealing with today is what we're going to be doing is we're going to be creating impermanent values.

  • So when we come up with the retail price, that will be showing you in these tables.

  • So again we're gonna have a parts table within that part's table.

  • We have the prices that we paid for the item, and then we're going to do a store function to tell us what we should be selling those items for.

  • So when you're looking, a table will say, like the part I d the part name the park Price, the vendor i D.

  • And then at the end, it will say what the retail price should be.

  • The important thing to understand here is that retail price at the end, when you're looking at that view, that is impermanent data that is not actually at this time being stored, and a lot of people could get confused about this.

  • So it's so that data that's permanent with what we're dealing with today is the data that's in the table.

  • So the part i d.

  • Number is permanent.

  • It is there.

  • If we shut off the server and turn the server back on that data is there.

  • The part name is permanent.

  • It's there.

  • The part price, the price that we're paying is there on the vendor.

  • I d we're not worried about that today, but that is there.

  • That is all data that is permanent.

  • And you can you can actually work against it in the normal flow of a sequel statement so you can don't go, you know, select.

  • You know, whatever part name where part price is over such and such, right?

  • So with permanent data within within the database, you can actually interact with that that data relatively easily that they retail price that we're creating today.

  • When we're doing this function, we're creating what's called impermanent data.

  • Basically, that data only exists when you call the function right, So we have the table and the table is there, right?

  • And then we're gonna create a function to create the retail price.

  • Well, the table as it was before, and the table after we leave the function are the same.

  • We're not actually modifying that table at all.

  • We're not actually inserting any data into the table.

  • We're not doing an update.

  • Operation on the table were signed.

  • It kind of just kind of like scribbling like think about mentally, as it were, like scribbling notes on the side.

  • And so that's just something toe think about whenever you're looking at things like views and you're thinking and you're working with these tables is think about what data is permanent and what data is impermanent.

  • Because as you're going, be building out your database for for whatever project that you're gonna be doing.

  • If you do things like create functions and then you do not save the data that's created by those functions into a table basically out, put them in some way, then it will be very hard for you to be able to interact with those values going onto the future.

  • A TTE this point, you may be so new that maybe a little bit confusing.

  • This might be one of those lessons were like five classes.

  • From now you go.

  • Oh, that's what Eli is talking about.

  • But the warning here is that when we're when we're doing these stored functions, today we're creating in permanent data, more or less, you will not be able to do additional calculations or work based upon the data that we've created, and as soon as you leave the function that data disappears, you don't quite grasp what I'm talking about.

  • Don't worry, it's okay.

  • Probably in the future it will start to make a little bit more sense.

  • But that is just the warning.

  • Here is just because Because that's one thing like when you're looking at a view when you look at a view of something like a table gonna select all.

  • It's very easy to get confused between the view and the table itself.

  • So if you do this function, you get the retail price.

  • It's very easy to think.

  • Oh, that retail price is now inside the table and is not inside the table.

  • It's in the view.

  • It's not on the table.

  • I should probably stop now before you get even more confused so that let's go over the computer and I can show you how the story functions work.

  • Okay, so here we are my computer Again.

  • Again.

  • I have a Mac book Pro.

  • I am running virtual box within an instance, on virtual box, I'm running a button to desktop 18.4 Lt s And then I used something called Task Cell to install the entire lamp stack on to this Lennox desktop.

  • So I have Apache, my sequel and PHP so more or less.

  • That's how you get to the lab environment that you're dealing with.

  • Here, go down here.

  • You go up to search.

  • Obviously we type in Terminal two terminal.

  • Now we have our terminals.

  • The first thing we're gonna do is we're going to log in.

  • So get my sequel.

  • Uh, hyphen you are User name is Bob Hyphen.

  • P password.

  • Inner password is 123456 And hey, now we are in my sequel.

  • From that, I will get control l to clear the screen to make this a little bit easier to see.

  • Uh, now again, toe, always make sure we know what's going on with our database server.

  • Uh, we do type show databases, semi colon.

  • That shows us the databases that we're dealing with on the server.

  • So we want to use the class DBS.

  • We're going to use class B semi colon de limiter again when you're dealing with store procedures and store functions, that the limiter becomes very important concept.

  • So again, currently, we're using to semi colon as a delimit er we're going to go in.

  • So we're in the class d B now.

  • We're gonna do show tables just so we know what we're dealing with with the tables.

  • So we have the tables, we have parts and we have vendors.

  • We do describe parts, so describe the E S.

  • C will describe the information basically the schema of the parts table semi colon so we can see we have a field we've apart i d number.

  • So this is just kind of like the the I.

  • D.

  • Number for parts.

  • It is an auto increments.

  • So every part has its own number, and it is a primary key.

  • We don't really worry about that.

  • That's just use more for again the back and stuff to make sure the database doesn't screw anything up.

  • Then we have apart hyphen R Apart, underscore name that is a text type.

  • Then we have part underscore Price.

  • That's what we're gonna be dealing with today.

  • That is a float.

  • So the the data type is going to be important here.

  • And then we had the vendor underscore I d that we're not going to worry about at all today, and that is going to be an integer.

  • Then just to see what's going on with this particular table.

  • Would you select all, uh, from parts.

  • So this will select all columns, all records from parts table.

  • And so, as we can see here, we have a cog with a rod.

  • We have a sprocket nut, a washer and a flan, and we've got prices $11.50 $2.50 $8.50 So on and so forth.

  • So this is one of the important things, right?

  • If you're gonna be creating something, a stored function, make sure that you're a table exists makes you your table.

  • The schema for your table looks, how it's supposed to look on.

  • Then make sure there's actually some records within the table.

  • You know, a lot of people go out there and they'll create a function to an empty table or they'll create a function and they'll screw everything up because they don't know what data types or whatever their table allows for.

  • So the big one that we're gonna be looking at today is park Underscore Price and the data type for that is flock.

  • And we can see again $11.50 $2.50 $8.50.

  • So again, when your time out an integer an integer is a data type that is a whole number 1 10 220 that is an integer A float is basically with a decimal 2200.11 11.52 point five, 6.252 point one That is a float.

  • There's also decimal data types and all kinds of other data times.

  • But we just use float today and all I need to know is that it is a full s with that let me control clear of screen again.

  • And so now the first thing that we need to do is we need to set the delimit er just like we did in the store procedures class.

  • Eso we do is delimit er and then we're going to do dollar sign dollar side.

  • You could put this theoretically to whatever delimit or you want it to be on dso.

  • What this means is that my sequel will not try to process what we type in Dill sees dollar sign, dollar sign and then I hit enter.

  • When I create the function that I'm about to show you, there's gonna be a number of different semi colons in there.

  • If we did not modify the delimit er at this point in time, as soon as I typed in semi Colon then I hit enter.

  • It would try toe process, the half aborted crap that I had just written before I could actually complete everything.

  • Right.

  • So you really need to modify this delimit er this is one of those things.

  • I agree with you.

  • It is stupid.

  • It is.

  • It is idiotic.

  • It is all the bad words I probably can't say anymore.

  • But it's true.

  • Just cause it's stupid doesn't mean it's not true, right?

  • So, yes, you need to modify that eliminator, whatever the hell you want it to be.

  • Dollar sign.

  • Dollar science is easy, and it's a lot of the example.

  • So we're modifying the deliver $2 sign dollar sign from this.

  • We're then going to create our functions.

  • We're going to create a function called retail cap.

  • That's we're going to do create function, just like we create a lot of things that we say.

  • What?

  • The name is retail.

  • Cal s Oh, this could be whatever name you want to be.

  • So we're going to calling this function when we're doing our normal statements based off of whatever you call it.

  • So I'm calling this retail count.

  • You could name this whatever you want.

  • They were going to open parentheses at this point.

  • We're then going to say what variables and what data types of variables we're going be giving this particular function s o the first thing we're gonna do this part underscore price.

  • So part underscore price that's going to be coming from the continent apart.

  • Price column within the parts table.

  • And I'm going to say that this is a float.

  • So part price is the name, and the data type is a float I'm going to do comma.

  • Next variable that we're gonna be dealing with is the markup, and that will also be a float.

  • And then for this, I'm only giving it to variables, so I will close the parentheses.

  • Now, it is important that your data types are correct again.

  • If you haven't int in your table, you may not want to say that it's a float.

  • Here.

  • You have floated the table.

  • You probably don't want to say it's an interior.

  • So you do have to make sure that that the data types correspond with what you want them to be past that we're then going to say returns.

  • So what is what data type Is this function going to return it?

  • So it's also going to return a float S O.

  • This is important here, eh?

  • So when we return a float, that's going to be a number with a decimal point.

  • So if you returned an integer an end that would not have a decimal point So you could do all this math and they literally strip off anything past the decimal point.

  • So it was supposed to be, If the final price is supposed to $11.50 it would simply give you $11.

  • It was supposed to be $2.25 would simply give you $2 right?

  • That's an important thing to be thinking about with the data time again, with the float here, I'm actually doing a float just because it's the easiest again to be clear.

  • When I teach you things, I try to make it as easy as possible.

  • We're actually going to see a problem by using the data type flow.

  • Once we get done with this and we actually run this particular function because it's actually going to give us too many numbers past the decimal place.

  • So it'll be like 12 $12.37 a half cents.

  • So that's the kind of thing that you need to be thinking about, like with the data with the end result that you're gonna be giving to your end user one.

  • Is it correct?

  • So again, if you're stripping off the final decimal points, that's bad.

  • That's simply incorrect.

  • Or two is a usable If you're giving your your your end user too many too many numbers at the end, that can run into problems.

  • But I'll show you that.

  • The main thing here is that you're just simply saying, what kind of data are you going to returning?

  • So for us to be easiest, we're just gonna be doing they're gonna get dinner and then, just like where they stored procedure, we're going.

  • It begin s o.

  • This now begins the function, and the first thing that we need to do is we need to declare a variable within this function.

  • So basically what we're going to be returning so when we multiple multiply the park price by the markup that will be the retail price that will be returning.

  • So we're gonna reach, declare retail price.

  • Um, and that again is going to be a float data type.

  • Then we're going to do semi colon now because we modify the delimit er up here, we should not run into any problems.

  • Inner Hey, don't you understand if I had not modified the DL emitter when I did that semicolon that I hit enter literally my sequel try to process that half, and then it just gets ugly on The worst part is it doesn't always necessarily completely fail out.

  • Sometimes it does part of it, which is even worse.

  • So, yeah, just just due to deliver, uh, okay, now we're gonna do is we're gonna set the value of the variable retail price.

  • So retail price.

  • So we're going to set the value of the variable retail prices going to equal, and it's going to equal part the value of part underscore price, uh, times market.

  • And so basically, this is the math that you're gonna be writing.

  • And so this math could be very simple or could be very easy.

  • And whatever the equation is is the equation that you put in there.

  • So what I'm gonna be doing is for this mark up, I'm simply gonna be doing, like 1.25 So we're going to increase the price of the part by 25%.

  • So I'm going to multiple multiply the park price by 1.25 and that should give me the additional 25% prices.

  • The final retail price.

  • How you come up with that math is basically completely up to you.

  • So this part right here, this is whatever wacky asked Matthew decide to put in there and just realized just realize again, you can have something that functions but is also incorrect.

  • At the same time, a lot of new people get that confused when they're doing this kind of math.

  • Like you can put in whatever, Matthew, you wanna put in whatever equation you want right here.

  • It doesn't necessarily mean you're getting the right answer or the answer that you need out of that equation.

  • So whenever you're doing any kind of math stuff, always get somebody toe check what you're doing, or at least at least go back and make sure the math.

  • The results that you're getting is what they're supposed to be, because that's what happens with a lot of new coders.

  • Is they code?

  • Everything right?

  • It runs perfectly.

  • The problem they run into, though, is they screw up this math, and so the values that are being returned or incorrect.

  • The computer's computing the values fine, but the value itself is wrong because the equation is wrong.

  • Uh, do the semi colon there and we entered to go down to the next line, and then we're going to return retail price.

  • So we're going to return the value of the variable retail price we're going to do semi Colon again and then we're gonna say end they were going to dollar dollar sign because we are now completely finished with us.

  • So we created a function called retail Couch.

  • We're putting in two variables a part underscore price, which is a float a markup, which is a float.

  • It is going to return a float.

  • We began the function by declaring a variable called retail price that is also a flipped.

  • We're going to set the value of retail price to be equal to part price Time's mark up.

  • We're then going to return the value of retail price that as long as I didn't do something stupid, I should hit inner.

  • Should all be OK.

  • Yeah, a query.

  • Okay.

  • Zero Rose.

  • You don't know every time I type in one of these things.

  • I'm always so happy when I didn't screw anything up.

  • You folks don't see it, but in order to do these classes, I did a lab, like, 10 times beforehand.

  • Oh, you don't know how many times I forget a calmer semi, Colin.

  • Er.

  • Anyway, uh, now, the next thing that we need to do, the very next thing that we need to do as soon as we get this.

  • Okay, the next thing that we need to do is we need to set the delimit er back to being in semi colon.

  • Because if you don't do that, you can run into major problems.

  • So don't get me wrong.

  • Like if you're If you're doing Maur that you're creating Maur stored procedures or more store functions.

  • Obviously don't reset the deliverer.

  • But if you're doing anything else other than those two things resettle emitter back to this cynical.

  • But now from here, what we're going to do is we're actually going to run this new functions, hit control l to clear the screen.

  • And so now what we're going to do is we're gonna say select.

  • Also, I'm gonna select all columns from the table, but then we're also going be adding in this function.

  • So we put comma so common ad in the function, and we're going to say retail, Cal.

  • So this is the name of the function that we're going to be calling, and then we're going to give it the variables that we're gonna be dealing with.

  • So part underscore Price.

  • So this corresponds to the column name within the parts table.

  • Then we're going to do comma.

  • And then, as far as bark up is concerned, we're then going to 1.25 so essential as far as that function, because we're going to multiply part price by 1.25 and so that should give us our 25% markup.

  • Um, and then we're going to close the parentheses, so we're gonna be calling the retail count function.

  • We're going to be giving these two variables based off of that function that we created.

  • This will then be calculated and then we want to return, basically, actually present the results as retail.

  • So what's gonna happen is we look at the table at the end of the table.

  • There's going to be a new what appears to be a column.

  • It's a view column, but remember, this data is not stored within the table itself.

  • But there's a column that you can now view that will be called Retail with these numbers at the end.

  • And then we're going to say from the parts table So select dolls.

  • It's like all cotton columns, Comma, we're going to call the funk ships or I'll call the function a retail count we're going, then put it in Park Price.

  • It's gonna be times 1.25 We're then going to return that as retail from parts, and then we're going to hit semi colon and we're gonna enter s Oh, now, Now we have what looks like the old table, but at the end is the retail price.

  • So this is the retail price that we should be charging.

  • Our customers know again, says I just use the basic float.

  • You can now see where you can run into problems with data types, especially when you start doing these types of calculations.

  • Because if I have a customer come in, they say, How much is the cause?

  • I want to buy a cog.

  • I tell them $14.37 a half cents that's not actually useful.

  • It is to be clear it is correct.

  • It's not useful.

  • And so this is one of those things you need to be thinking about with the data types.

  • And that's where that's why Sometimes you use an energy.

  • Er, sometimes you use afloat sometimes use a decimal.

  • So with a decimal you can actually state how many places for the decimal point it should go, so that might be a more useful data type here.

  • I'm just using floats again to make it easier for you to see how all this works and that that's basically all there is the function again if I do select all from parts.

  • So with the parts table hit hit, enter Sir Michael intimate in her.

  • So what you can see here is, as I was saying before, is that this retail this retail value here.

  • This is not permanent, right?

  • This is not actually part of the parts table.

  • We only view that when we're using the function within the sequel statement, as soon as I go back to simply doing select all from parts, we can see that it disappears again.

  • This will become Maur important as you create more complicated databases.

  • And so if you need to be able to calculate and then output those calculations into the table so that it actually gets saved, that's something that you have to be dealing with future now past that.

  • One of the things we can make life a lot easier is we can then create a stored procedure based off of this sequel statement with a function right.

  • So Okay, so this makes our life easier because we can now see the retail price relatively easy.

  • But what if I want to make it even even easier still and simply be able to call a stored procedure and you have the sequel statement run to give me the results so that I don't even have to type in all of this crap all the time?

  • So to do that again, we could do a store procedure like we did before.

  • It's already a limiter.

  • Dollar sign, Dollar sign.

  • How do you control L?

  • A Clear the screen.

  • And so now we can do a create, so d'oh, create pros.

  • See, Jer?

  • Right.

  • Um and then what?

  • We're going to create the procedure we're going to call a price.

  • That's a list, Uh, open parentheses, closed parentheses.

  • So this all comes from this store procedure class that we did before.

  • We're going to enter that we're going to begin enter again, and then we're going to type in this sequel statement that we just had eso select.

  • So let's, uh, all comma.

  • And then we're going to say retail, uh, count and then open parentheses.

  • And then we're gonna d'oh part underscore price like we did before, comma in the 1.25 So we're going to multiply part price by close parentheses.

  • Um, they were going to say, as retail from parts.

  • Right.

  • So this is the basic sequel statement.

  • Select all comma retail, couch function, part price, blah, blah, blah.

  • They were gonna hit inner.

  • Then we're going to do from here.

  • You're simply going to say and dollars dollars side.

  • There you go.

  • Everything's okay.

  • The next thing that I do is set the delimit er back to semi colon.

  • And now what?

  • I could do it since I created this price list store procedure.

  • Now, instead of typing all that crap out, But I could do was I could simply do call, uh, price list semicolon.

  • And now I get the the values here, just like I wanted.

  • So again.

  • So this is one of those things that could be very useful for you is you can create functions that will then go through an old manipulate data within your tables.

  • And then you can create a stored procedure based off of that stored function, and then you can go from there.

  • So, like, with this 1.25 I could modify this in the future so I could delete the procedure price list and then re create it and have this value be 1.10 or I could have the one not 50 or having 1.55.

  • And then as far as my users are concerned, oh, they have to type in is called price list, and then they will simply get the results.

  • So this is how you can take those store functions.

  • You then use a stored functions within a store procedure, and then you can make life a lot easier for your users.

  • Simply do call priceless and again for a lot of the new kids out there for long.

  • The new kids out here, this looks ugly, is held.

  • But to be clear when I start in the professional world back in the early nineties, this is what computers look.

  • It says this is how we interact with computers.

  • Back in the old days, it was let me clear the screen again.

  • And now we can dio.

  • One of the things that we need to look at is to see what functions we have for this particular database.

  • So in order to see what functions we have for this particular database, we can do in this show function.

  • So we're going to do are the show, uh, function, uh, that ISS looks a lot like the store procedure where d B equals single quotation mark class, the be close single quotation mark And then we're going to see Michael again.

  • So this is going to say show functions down is where the database equals class.

  • Devi hit, Enter on dso It spits out some information and down here we can see the retail cap So we have a retail couch function that was created by Bob.

  • It was created at this time.

  • It was modified at this time, so on and so forth.

  • So the show function status where d b equals whatever databases that will show you all these toward functions that you have.

  • But again, just like with store procedure is great.

  • You know what the hell the name of it is, But that doesn't actually tell you what it does.

  • So the next thing that you need to do is you need to type in the show, create function to show how that function was created.

  • But again, this is one of reported thanks to to be thinking about with like naming conventions is the more the names for things like functions and procedures just make sense, the easier it will be to maintain your database and especially hand off your database when you get promoted or you go to the next job.

  • So again, retail count.

  • If I look at retail couch, I have an idea that's probably calculating retail price.

  • Oh, I know there's a function that calculates a retail price, and that's called retail cow.

  • So I bet you that's the function were again with the store procedures.

  • I just called it nasty.

  • I annoyed you.

  • Withheld nasty.

  • So again, you need to be thinking about names.

  • When you're when you're doing this, there is what is technically correct.

  • And then there's human readable.

  • Think about making things human readable.

  • That's all I know is we need to see what the retail Cappie actually does.

  • So we're going to do, show, create function, retail.

  • So this basically says, Show me how the function retail count was created that we're going to do a semicolon.

  • I think I talked all that correctly.

  • We're going to hit, Enter on that's gonna give us a whole bunch of information that we don't care about.

  • Basically, we're gonna be looking for is the beginning.

  • So begin and the end, everything in between.

  • That is what our function actually is.

  • We're going to see it declare, it declares a retail price that's a float sets the value of retail price to be equal to part underscore price.

  • Time's mark up.

  • It's not Return the retail price.

  • Eso again if you're having problems with the math for some reason, if you're trying to figure out why the numbers are are coming up to what you think, the number should be basically just to show how the function was created and you might find again this part right here, this is going to be the big hang up.

  • You can put in an equation that the computer processes that gives you garbage out.

  • So just just to be clear, they're finally doing control.

  • L.

  • In order to get rid of a function well you have to do is ah, drop and then you're going to say function.

  • So whenever you're deleting something, drop table drop, database drop, whatever, we're going to drop the function.

  • That function is going to retail Coke already.

  • Semi colon.

  • Drop the function.

  • Now the function is gone, and so that's how you can create a function.

  • That's how you can use the function within the stored procedures, as I showed you before.

  • That's how you can then see what functions was stored.

  • Functions are on the database that you're using.

  • You can see how the function was created and you can see how to delete the function.

  • And that's really the basics of stored functions for you.

  • And so now at least you have a basic idea of stored functions within my sequel database servers.

  • At the end of the day, like most of this stuff, it's relatively easy.

  • The problem that you're gonna get into here is understanding how to technically make functions.

  • Work is relatively easy right, you know, create function, blah, blah, blah began and blah, blah, blah, blah, blah, blah, right, all that kind of stuff blah blah, blah.

  • The problem that you're gonna get running or you're gonna run into is creating those equations.

  • It is hilarious.

  • It's weird.

  • It's weird, like people that are not in technology think that everybody that's in technology or like math whizzes.

  • It is shock.

  • It is shocking how bad So many I T professionals are at a very basic math, very basic math or oh, they could do after directory so they could do active directory, that canoe back up ski ves.

  • They could be amazing with technology and just be a horrible with math of the exact same time is a problem that you're going to run into with the store functions is again.

  • You can have a function that processes perfectly and gives you a garbage answer on that, something that you really do have to be careful about again, especially as you start building out your database system.

  • Because what's gonna happen is in the beginning you have a couple of tables.

  • You're going to compute things based off of those couple of tables.

  • And maybe in the beginning, if you're a little bit off, it's a little bit wonky.

  • You're a little bit off, and what really matters far as a business concern won't really matter.

  • But then, if you start tying those results and do other functions, and those were also a little bit off and then those results are tied into other functions, all of a sudden you can go from being like 1% off, where the business isn't even gonna notice that there's a problem to be massively off, and especially if you have to have things like corporate auditors come in when the last.

  • The last thing in the world you want to find out is that you've got over or under billing.

  • You know all of your customers by, like, half a cent, because it's like, how do I don't even deal with that?

  • How do either a refund it or be bringing into our normal accounting system?

  • That could just be, like, absolutely horrible.

  • So be very careful with math.

  • If you're gonna be using these functions, any production environment again for things like point of sale system, any kind of invoicing system, anything like that.

  • Have somebody else verify your math, right When you're gonna write the equation, put in front of somebody else, goes.

  • This is what I'm trying to accomplish.

  • Does that equation make sense to you?

  • And if they say no, go back to the drawing board again, it's very important to understand something.

  • You can have a function run perfectly and give absolutely garbage results of the same time, So be very careful with that.

  • Beyond that, also, do you remember, like in the database world is when we start doing things like functions and we're looking at a view, remember that retail at retail column that we created is impermanent, right?

  • It is only there when we call the function.

  • When you go back and do a normal select all for the parts table.

  • It disappears because it's not permanent.

  • Doesn't doesn't permanently reside within the database again, this could be important.

  • As you start building out your database, you may want to actually be able to interact with those results.

  • And in that case, then you're gonna want to make sure that you actually update the records in the table with those results.

  • We may or may Tough night may or may not talk about that in the future, but if you need to do that just to go and do some research on, it's pretty easy to figure out.

  • But those are some of the things to be kind of thinking about when you started dealing with these functions and so it could be very valuable again.

  • If you're starting to think about like Mark ups for price.

  • If you think about sales, anything about other ways that you can compute things it could be, this could be a very useful tool for you and something that gets overlooked by a lot of people that are new to my sequel databases.

  • So, as always, I enjoy doing this video forcing out the next one.

  • Apparently, the type of content you just saw is not what Susan W.

  • Wants for the future of YouTube.

  • This means that recommendations by YouTube to this channel have dropped massively, and views are becoming a comically small I hate to ask.

  • I used to say I would never ask, but if you could subscribe like common and most importantly, share the videos that you appreciate, that may help slow the death of this channel.

  • Do you remember that if anything at all happens to this channel, you can go to Eli, the computer guy dot com, to view the content and access information not available on YouTube.

creating these classes requires equipment and service.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it