All language subtitles for [SubtitleTools.com] What Is PL And SQL- - Learning Oracle 12c [Video]

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,450 --> 00:00:04,780 In this lesson, we're going to take a look at PL/SQL. 2 00:00:04,780 --> 00:00:06,280 So what is PL/SQL? 3 00:00:06,280 --> 00:00:07,660 And what do we mean? 4 00:00:07,660 --> 00:00:09,980 How does that relate to SQL, for instance? 5 00:00:09,980 --> 00:00:14,320 Well, PL/SQL stands for Programming Language/Structured 6 00:00:14,320 --> 00:00:15,700 Query Language. 7 00:00:15,700 --> 00:00:18,970 So these are programmatic extensions, just SQL, 8 00:00:18,970 --> 00:00:20,710 to the SQL language. 9 00:00:20,710 --> 00:00:23,950 So why would SQL need programmatic extensions? 10 00:00:23,950 --> 00:00:28,540 SQL is a 4GL, or Fourth-Generation Language. 11 00:00:28,540 --> 00:00:31,270 It's designed to be closer to natural language 12 00:00:31,270 --> 00:00:33,880 and easier for a user to learn. 13 00:00:33,880 --> 00:00:35,800 But a fourth-generation language that 14 00:00:35,800 --> 00:00:40,090 is that easy to manipulate and use, as well as learn, 15 00:00:40,090 --> 00:00:42,130 doesn't have all of the extensions 16 00:00:42,130 --> 00:00:46,870 and the functionality that a programming language may need. 17 00:00:46,870 --> 00:00:50,890 For instance, if you want to do if/then logic in SQL, 18 00:00:50,890 --> 00:00:52,600 that's difficult to do. 19 00:00:52,600 --> 00:00:55,510 Things like looping over variables, 20 00:00:55,510 --> 00:00:58,660 type variable control, all of those things 21 00:00:58,660 --> 00:01:00,130 are difficult to do in SQL. 22 00:01:00,130 --> 00:01:02,360 And it really wasn't designed for that. 23 00:01:02,360 --> 00:01:05,300 But what was designed for that is PL/SQL. 24 00:01:05,300 --> 00:01:08,770 And PL/SQL is a full third-generation language. 25 00:01:08,770 --> 00:01:13,660 It uses constructs, such as variables, conditional logic, 26 00:01:13,660 --> 00:01:17,410 iteration, all of the things that we think of in terms 27 00:01:17,410 --> 00:01:21,100 of a regular programming language, if you will, 28 00:01:21,100 --> 00:01:23,440 one that we're more familiar with, 29 00:01:23,440 --> 00:01:27,010 third-generation languages like C and Java. 30 00:01:27,010 --> 00:01:30,500 PL/SQL is appropriate for data applications. 31 00:01:30,500 --> 00:01:35,080 So one of the truly remarkable things about PL/SQL 32 00:01:35,080 --> 00:01:39,190 is how well it processes the data layer in the database. 33 00:01:39,190 --> 00:01:42,370 So any application has many different layers. 34 00:01:42,370 --> 00:01:44,830 They may have a presentation layer, 35 00:01:44,830 --> 00:01:48,310 which is what the user sees, a logic layer, 36 00:01:48,310 --> 00:01:51,340 where the programmatic thinking happens. 37 00:01:51,340 --> 00:01:52,870 And then you have the data layer, 38 00:01:52,870 --> 00:01:55,390 where the data is actually retrieved and sent 39 00:01:55,390 --> 00:01:59,460 back to the other layers and eventually to the user. 40 00:01:59,460 --> 00:02:03,990 PL/SQL is extremely useful in the heavy lifting that's 41 00:02:03,990 --> 00:02:09,590 done at the data layer if you're using an Oracle database. 42 00:02:09,590 --> 00:02:12,180 PL/SQL is what we call block-structured. 43 00:02:12,180 --> 00:02:16,020 So it has and is made up of a number of different blocks 44 00:02:16,020 --> 00:02:20,880 of code within any given piece of PL/SQL code 45 00:02:20,880 --> 00:02:23,620 that each do a specific function. 46 00:02:23,620 --> 00:02:26,130 And those work in concert together in order 47 00:02:26,130 --> 00:02:30,780 to get the job done of the overall PL/SQL code. 48 00:02:30,780 --> 00:02:32,760 It's important to understand that PL/SQL 49 00:02:32,760 --> 00:02:36,990 is Oracle-specific, which means it runs on Oracle databases. 50 00:02:36,990 --> 00:02:40,470 Whereas SQL is an ANSI standard language that's 51 00:02:40,470 --> 00:02:43,530 used in many different relational databases, 52 00:02:43,530 --> 00:02:46,170 PL/SQL is specific to Oracle. 53 00:02:46,170 --> 00:02:49,440 So there is no way to take PL/SQL code 54 00:02:49,440 --> 00:02:52,560 in any kind of persistent way, if you will, 55 00:02:52,560 --> 00:02:56,370 and move it over to an IBM DB2 system. 56 00:02:56,370 --> 00:02:59,970 You could take it and rewrite it because it would be similar. 57 00:02:59,970 --> 00:03:03,300 But you can't take it code for code, line for line, 58 00:03:03,300 --> 00:03:06,210 and move it over to SQL Server or DB2 59 00:03:06,210 --> 00:03:07,720 or any other relational database. 60 00:03:07,720 --> 00:03:09,360 It's Oracle-specific. 61 00:03:09,360 --> 00:03:10,980 We should probably also understand 62 00:03:10,980 --> 00:03:13,740 that even though PL/SQL is specific to Oracle, 63 00:03:13,740 --> 00:03:16,950 a lot of those different RDBMS systems 64 00:03:16,950 --> 00:03:20,670 will have their own version of something like PL/SQL. 65 00:03:20,670 --> 00:03:23,100 For instance, Microsoft SQL Server 66 00:03:23,100 --> 00:03:28,830 has a 3GL called TSQL that performs the same kinds 67 00:03:28,830 --> 00:03:31,320 of duties that PL/SQL does. 68 00:03:31,320 --> 00:03:33,660 Finally, PL/SQL gives us the ability 69 00:03:33,660 --> 00:03:36,570 to have something called persistent code. 70 00:03:36,570 --> 00:03:38,700 And persistent code means code that 71 00:03:38,700 --> 00:03:41,700 lives inside the database for our purposes. 72 00:03:41,700 --> 00:03:46,200 So we can create pieces of code in PL/SQL 73 00:03:46,200 --> 00:03:48,450 and actually store those in the database. 74 00:03:48,450 --> 00:03:50,890 But we don't have to store them in the database. 75 00:03:50,890 --> 00:03:54,090 We can use PL/SQL as a scripting language, 76 00:03:54,090 --> 00:03:57,540 almost, to run a script from the file system, 77 00:03:57,540 --> 00:04:00,720 for instance, that does that PL/SQL work. 78 00:04:00,720 --> 00:04:02,700 So let's take a look at what's called 79 00:04:02,700 --> 00:04:05,160 an anonymous block of PL/SQL. 80 00:04:05,160 --> 00:04:07,500 So anonymous block PL/SQL is more 81 00:04:07,500 --> 00:04:09,090 of the scripting type of language 82 00:04:09,090 --> 00:04:10,910 that we're talking about. 83 00:04:10,910 --> 00:04:14,130 Here, we say that it is block-oriented or 84 00:04:14,130 --> 00:04:15,600 block-structured. 85 00:04:15,600 --> 00:04:19,170 And so we have the beginning of a block here called DECLARE, 86 00:04:19,170 --> 00:04:21,090 where we declare all the variables that 87 00:04:21,090 --> 00:04:22,630 are going to be involved. 88 00:04:22,630 --> 00:04:24,720 So here we just have a character variable 89 00:04:24,720 --> 00:04:27,270 that contains the string Hello World. 90 00:04:27,270 --> 00:04:29,940 And then BEGIN starts the next block. 91 00:04:29,940 --> 00:04:33,330 And then we use a call to dbms_output 92 00:04:33,330 --> 00:04:37,170 that just prints this variable, which contains Hello World. 93 00:04:37,170 --> 00:04:40,630 And so when we run it, it prints out "Hello World." 94 00:04:40,630 --> 00:04:42,160 And then the last is the END. 95 00:04:42,160 --> 00:04:45,090 Another block that you don't see here, which is optional, 96 00:04:45,090 --> 00:04:48,660 is the exception block, where we can write exception handlers 97 00:04:48,660 --> 00:04:49,800 in the code. 98 00:04:49,800 --> 00:04:54,060 So this would be anonymous block PL/SQL. 99 00:04:54,060 --> 00:04:56,490 The other kind of PL/SQL we can have 100 00:04:56,490 --> 00:04:59,190 is what's called a named program unit. 101 00:04:59,190 --> 00:05:02,820 This is the persistent code that we were discussing earlier. 102 00:05:02,820 --> 00:05:04,830 So a named program unit is actually 103 00:05:04,830 --> 00:05:08,160 stored in the database as a database object. 104 00:05:08,160 --> 00:05:11,940 And it can be manipulated, just as a database object would be. 105 00:05:11,940 --> 00:05:15,510 So we say something like CREATE PROCEDURE. 106 00:05:15,510 --> 00:05:17,300 And then we give it a name, hello_there. 107 00:05:17,300 --> 00:05:20,310 And then we have variables for parameters 108 00:05:20,310 --> 00:05:22,860 that come in to the procedure. 109 00:05:22,860 --> 00:05:25,590 So we're passing a value into the procedure. 110 00:05:25,590 --> 00:05:29,220 And then it does its job and completes. 111 00:05:29,220 --> 00:05:32,610 So to call a procedure called hello_there, 112 00:05:32,610 --> 00:05:34,230 we use the execute commands. 113 00:05:34,230 --> 00:05:37,590 We say execute hello_there, which is this procedure, 114 00:05:37,590 --> 00:05:40,300 passing in the value Fred. 115 00:05:40,300 --> 00:05:43,400 Fred goes into a variable for p_name. 116 00:05:43,400 --> 00:05:46,790 And then when we make the print call, if you will, 117 00:05:46,790 --> 00:05:50,780 it says "Hello there" and then appends the p_name variable 118 00:05:50,780 --> 00:05:52,470 to the end of it. 9547

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.