Learning pl/sql
Hi,
I am working on SQL but does not have much knowledge on pl/sql.Institutes are also not providing in depth. What is your suggestion in mastering pl/sql.
Please guide me.
thankyou
satya
Take a look at Oracle Documentation:
http://www.oracle.com/pls/db112/portal.portal_db?selected=5&frame=#sql_and_pl_sql_languages
Similar Messages
-
Suggested books/video series for learning oracle sql?
What are some good books/ videos for a beginner to learn oracle sql?
I learn best by being able to go through exercises.
I am using Oracle 11g express edition and sql developer. In sql developer I have only one connection to the HR schema.
Also, can I connect to the SCOTT schema in oracle 11g?Hi,
The SQL Language reference is a great book, but its a bit dry for a beginner.
How about starting with the Getting Started and 2 Day guides here
http://docs.oracle.com/cd/E17781_01/index.htm
There are a lot of tutorials here as well
https://apex.oracle.com/pls/apex/f?p=44785:1:0::NO
google will also bring up lots of hits as well
Regards
Andre -
Learning PL/SQL in Oracle 10G XE
Successfully installed Oracle 10G XE on my desktop. I'm a newbie Oracle user who wants to learn PL/SQL through Oracle 10G XE.
Is this possible? Hope you can give me tips and advice on how I would start with this?
Thanks!Certainly possible. I would suggest you crack open the PL/SQL Users Guide. DO you have previous programming experience? If so, looks at the examples.
-
Learning PL/SQL ... a query
hi all,
i v jus started learning pl/sql. i v a question
the following is my pl/sql block
set serveroutput on;
declare
name varchar(50);
empid number := &emp;
begin
select last_name into
name
from hr.employees
where employee_id=empid;
dbms_output.put_line('name of employee is '||name);
exception
when no_data_found
then
dbms_output.put_line('no data for employee with the id:'||empid);
when others
then
dbms_output.put_line('error');
end;when i run this code i m asked to enter emp. if i type the emp no. which exists in the db then i get the name of the employee and if that emp_id is not present in the database i get a output saying "no data for employee with the id:<empid>".
now my question is ... when asked to enter the emp_id if i just hit enter i.e. i enter a null value, the exception block does not catch the error.
it throws an error
Enter value for emp:
old 3: empid number := &emp;
new 3: empid number := ;
empid number := ;
ERROR at line 3:
ORA-06550: line 3, column 17:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
The symbol "null" was substituted for ";" to continue.what am i missing??are we dependent on the front end so that a null value is not sent to the db??Your example used simple substitution variables directly in a sql (or pl/sql) statement. When you entered nothing and hit enter, SQL Plus basically did nothing and sent the block to the db for execution. That's just the way SQL Plus works.
Your application will not behave in this manner.
Ideally, your program (Java or whatever) will use bind variables (I hope). In that case, the statement sent to the database will not have the syntax error you saw above. (however, it will not return any results because of the null variable). -
Learning Pl/SQL here: Help creating a trigger
Hello everyone.
I am just learning PL/SQL here and have tasked with creating at trigger. The trigger basically needs to fire off a email when any records are updated on a specific table.
So far, I was going to use the built in procedure utl_smtp. I have that part configured, but where I am struggly is how to tell the trigger work when the table is updated with new data.
I am a little lost here so any help is greatly appreciated.
Thanks,
JWHello! I have following code for a trigger that fires when some record inserted in the table. However I got following error. Like this for example "ERROR at line 38: PL/SQL: Statement ignored". What is wrong whith the code?
CREATE OR REPLACE TRIGGER "SPEAKERS_T2"
AFTER
insert on "SPEAKERS"
for each row
declare
sender varchar2(80) := '[email protected]';
recipient varchar2(80) := '[email protected]';
smtpHost varchar2(80) := 'smtp.hotmail.com';
smtpUser varchar2(256) := 'someusername';
smtpPassword varchar2(256) := '<password>';
mail_conn utl_smtp.connection;
separator varchar2(1) := ' ';
content_charset varchar2(8) := 'utf8';
procedure send_header(name in varchar2, header in varchar2) as
begin
utl_smtp.write_raw_data(mail_conn, UTL_RAW.cast_to_raw(name||': '||header||utl_tcp.CRLF));
end;
begin
mail_conn := utl_smtp.open_connection(smtpHost, 25);
utl_smtp.helo(mail_conn, smtpHost);
-- If Authentication required for SMTP
-- After upgrade to Oracle 9i, replace demo_base64.encode
-- with the native utl_encode.base64_encode for better performance.
utl_smtp.command(mail_conn, 'AUTH LOGIN');
utl_smtp.command(
mail_conn, utl_raw.cast_to_varchar2(
utl_encode.base64_encode(utl_raw.cast_to_raw(smtpUser))
utl_smtp.command(
mail_conn, utl_raw.cast_to_varchar2(
utl_encode.base64_encode(utl_raw.cast_to_raw(smtpPassword))
utl_smtp.mail(mail_conn, sender);
utl_smtp.rcpt(mail_conn, recipient);
utl_smtp.open_data(mail_conn);
send_header('From', sender);
send_header('To', recipient);
send_header('CC', recipient);
send_header('Subject', 'Test');
send_header('MIME-Version', '1.0');
send_header('Content-Type', 'text/plain; charset="utf8"');
utl_smtp.write_raw_data(
mail_conn, utl_raw.cast_to_raw(utl_tcp.CRLF||' ')
utl_smtp.close_data(mail_conn);
utl_smtp.quit(mail_conn);
end; -
Good book for learning pl/sql quickly
Please suggest me a good book that covers all aspects of pl/sql in depth.
Thanks in advance. :-)A good book for learning PL/SQL quickly?
That is not a function of the book. That is a function of your ability to learn and understand new concepts. No book can make you learn "faster".
Also, even before trying to learn PL/SQL, there are concepts and fundamentals to understand. Specifically:
- [url http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/toc.htm]Oracle® Database Concepts
- [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/toc.htm]Oracle® Database Application Developer's Guide - Fundamentals
- [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm]Oracle® Database PL/SQL User's Guide and Reference
And after that, also have a look at Application Developer's Guide - Large Objects, Application Developer's Guide - Object-Relational Features. Not to mention the SQL Reference and the PL/SQL Packages and Types Reference guides.
All available via http://tahiti.oracle.com -
Good Books for learning PL/SQL
Hello,
Any information regarding a good book to help me learn pl/sql is most appreciated.
ThanksThe best: http://www.amazon.com/Oracle-PL-SQL-Programming-4th/dp/0596009771/ref=pd_bbs_sr_1/104-3233311-7887103?ie=UTF8&s=books&qid=1190300018&sr=8-1
others that are good:
http://www.amazon.com/Oracle-Database-10g-SQL-Programming/dp/0072230665/ref=pd_bbs_sr_2/104-3233311-7887103?ie=UTF8&s=books&qid=1190300018&sr=8-2
http://www.amazon.com/Oracle-SQL-Dummies-Michael-Rosenblum/dp/0764599577/ref=pd_bbs_sr_3/104-3233311-7887103?ie=UTF8&s=books&qid=1190300018&sr=8-3
You can just watch this Forum too, lots of good info here!
Jim P. -
Recommened book for learning PL/SQL
I've been trying to learn PL/SQL from Oracle's documentation, and I'm a bit tired of it.
All the information is there, but you really need to scan back and forth to collect all the bits you need. It is rather difficult.
Can you recommend a good book? I want to learn all the idea and concepts, not just the syntax. So please don't direct me to "Learn PL/SQL in 21 days".
Thanks.It may be true that one can get away with documentation. However, it greatly depends on your background. If you learn language X, and this is your very first exposure to programming, you won't find documentation inspirational. You will suffer with badly chosen textbook too. As you progress, the matter of a good book becomes less and less important. You may find that for learning your second language you don't need a book, and this is especially true in the era of internet, when there is a great competition among web tutorials.
My apology for not being specific, but the matter of finding a good book is easy -- you just go to amazon, find several with high ASR, and chose the one based upon readers reviews. You will unlikely to expect better feedback to your question here. -
Literature for learning PL/SQL
Hi all
Can someone advise me about good books to learn PL/SQL. I am newbie.Oracle PL/SQL Programming by Steven Feuerstein & Bill Pribyl is very good.
I also liked Mastering Oracle PL/SQL: Practical Solutions by Connor McDonald.
I haven't read the Tim Hall one but I'm sure it's worth a look if you are not put off by the publisher's fondness for annoying marketing phrases phrases like "Expert Secrets" and "High Performance Programming".
Avoid Oracle Database 10g PL/SQL Programming (Oracle Press), Urman/Hardman/Mclaughlin, it's terrible.
Edited by: William Robertson on Nov 29, 2008 3:44 PM
Turns out links can't contain quote characters. -
Learning PL/SQL with SQL plus
I'm looking to teach myself PL/SQL with SQL Plus, it's a works pc so I can not use any other software than SQL plus.
When starting SQL plus I'm asked for a username, password and host string.
I'm taking it the host string is the db I want to connect to and obviously supply the username and password for level of access?
Also what I ideally need is a sample db on my local machine to connect to with SQL plus to learn that way.
Can anyone point me in the right direction please. Any help is greatly appreciated.Use the net8 configuration assistant preferably as it'll get the syntax correct.
Otherwise you copy the sample one up one folder and edit that.
Connection information (SID, Server/IP, port number) you'll have to get off your DBA.
The name at the start of a tnsnames entry is the name that you want to reference the database as, so you can call it FRED if you like.
e.g.
FRED =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = <server name or ip address>)
(PORT = <port>) -- usually 1521 but can differ if more than one instance on the server
(CONNECT_DATA =
(SID = <database SID>) -- the name of the database on the server.
)Once that's set up you can then log onto the database in the following way:
sqlplus <user>/<password>@fred
What happens is that the TNS Listener service (that should be running on your PC) will look up "fred" in the tnsnames.ora file and then use the information from that to make the connection to the server on the correct port and connect you to the actual database on there.
After that.... it's up to you.
:) -
How to learn programming in PL/SQL in Oracle?
Hello Guru's,
I want to learn the programming in PL/SQL. I am new and I work in ETL tools, I started learning PL/SQL and very much confused with all study material online.
I want to learn different ‘for loop' types and when we use each type. Please guide me which internet link is good to learn.
Thanks,user13034857 wrote:
I want to learn the programming in PL/SQL. I am new and I work in ETL tools, I started learning PL/SQL
PL/SQL is part of the ALGOL family of languages - most modern languages have ALGOL syntax and structure roots. Pascal, C, C++, Java, Python, Perl, Ada, C#, etc.
These roots are:
- functions
- methods
- passing by value or reference
- processing structures like begin/end, if-else, case/switch and while/loop/until.
The point is that programming starts with understanding these roots - irrespective of the ALGOL family language being learned. And if you have not yet learned these basic concepts, do not know an existing ALGOL family language well enough to serve as a baseline, then you need to attend a basic programming course. These concepts need to be learned in a proper educational environment. You cannot expect to learn these concepts online and without personal assistance.
I want to learn different ‘for loop' types and when we use each type. Please guide me which internet link is good to learn.
Wrong. You should learn how to solve problems first - and then how to implement the solution programmatically.
Horse. First. Cart. Second. -
Want to start learning Oracle or PL/SQL from scratch.
Hello All,
Please guide me as how to start learning PL/SQL and Oracle from scratch.
Whether I should follow a particular book and go on as given in the book or should I directly take the queries and all and start solving them.
Thanks in advance...Its a good track. For start you should know the PL/sql and sql very well and you can start it like ORacle developer if not directly DBa and then taking kknowledge of administrationand other modules like Backup and REcovery and Performance tuning you can shift to the DBA side.
job prospects are very good but you need to be very confident and very alert in this job plus llittle clever as well.
But for now stop thinking so far and just start learning it and start doing it. Doing it means perform every thing practically.
Regards,
Navneet -
SQL query with multiple tables - what is the most efficient way?
Hello I am learning PL/SQL. I have a simple procedure where I need to find number of employees and departments per location as per user input of location_id.
I have 3 Tables:
LOCATIONS
location_id (pk)
location_name
DEPARTMENTS
department_id (pk)
location_id (fk)
department_name
EMPLOYEES
employee_id (pk)
department_id (fk)
employee_name
1 Location can have 0-MANY Departments
1 Employee has 1 Department
Here is the query I came up with for PL/SQL procedure:
/*Ecount, Dcount are NUMBER variables */
SELECT SUM (EmployeeCount), COUNT(DepartmentNumber)
INTO Ecount, Dcount
FROM
(SELECT COUNT(employee_id) EmployeeCount, department_id DepartmentNumber
FROM employees
GROUP BY department_id
HAVING department_id IN
(SELECT department_id
FROM departments
WHERE location_id = userInput));
I do get the correct result, but I am just wondering if my query is on the right track and if there is a more "efficient" way of doing this.
Thanks in advance for helping a newbie out.Hi,
Welcome to the forum!
Something like this will be more efficient:
SELECT COUNT (employee_id) AS ECount
, COUNT (DISTINCT department_id) AS DCount
FROM employees
WHERE department_id IN ( SELECT department_id
FROM departments
WHERE location_id = :userInput
;You should also try a join instead of the IN subquery.
For efficiency, do only the things you need to do.
For example, you don't need a count of employees in each department, so don't compute one. That means you won't need the in-line view, so don't have one.
You don't need PL/SQL for this job, so don't use PL/SQL if you don't have to. (I realize this question was out of context, so you may have good reasons for doing this in PL/SQL.)
Do all filtering as early as possible. Don't waste effort computing things that won't be used .
A particular example of this is: Never use a HAVING clause when you can use a WHERE clause. What's the difference between a WHERE clause and a HAVING clause? The WHERE clause is applied before aggregate functions are computed, and the HAVING clause is applied after; there's no other difference. Therefore, if the HAVING clause isn't referencing an aggregate function, it could be done in a WHERE clause instead. -
PL/SQL block error message
Hi,
I'm still learning PL/SQL. In my application, I created a PL/SQL block which contains an update and an insert statement. When I click Apply Changes, I receive the following error message:
1 error has occurred
ORA-06550: line 24, column 5: PL/SQL: ORA-00933: SQL command not properly ended ORA-06550: line 19, column 2: PL/SQL: SQL Statement ignored
This is my code. I'm not seeing the problem very clearly. Can someone help me out? Thanks.
BEGIN
update
HISA_AGREEMENTS
set
CREATED_BY=V('APP_USER'),
LAST_UPDATED_BY=V('APP_USER'),
APPROVER_SALUTATION=:P7_APPROVER_SALUTATION,
APPROVER_FIRST_NAME=:P7_APPROVER_FIRST_NAME,
APPROVER_MIDDLE_INITIAL=:P7_APPROVER_MIDDLE_INITIAL,
APPROVER_LAST_NAME=:P7_APPROVER_LAST_NAME,
APPROVER_NAME_SUFFIX=:P7_APPROVER_NAME_SUFFIX,
APPROVER_EMAIL_ADDR=:P7_APPROVER_EMAIL_ADDR,
SPONSOR_EMAIL_ADDR=:P7_SPONSOR_EMAIL_ADDR,
APPROVER_TITLE=:P7_APPROVER_TITLE
where
ORG_KEY_LE=:P7_ORG_KEY_LE;
insert into
HISA_AGREEMENT_DOCS
(ORG_DOC_CURR_KEY)
values
(:P7_DOCUMENT)
where
ORG_KEY_LE=:P7_ORG_KEY_LE;
END;Hello,
insert into
HISA_AGREEMENT_DOCS
(ORG_DOC_CURR_KEY)
values
(:P7_DOCUMENT)
where
ORG_KEY_LE=:P7_ORG_KEY_LE;
is wrong. The WHERE clause needs to be omitted...or you need an update.
Greetings,
Roel
http://roelhartman.blogspot.com/
You can reward this reply by marking it as either Helpful or Correct ;-) -
Temporary table in a pl/SQL block
Hi all. I am in the process of learning PL/SQL and right now I focusing on Temporary Tables & PL/SQL blocks. without going into great detail I have created a cursor for loop that will retrive records from a table based on my criteria. I now need to insert this information into a temporary table. I am somewhat familiar on the usage of a temporary table by itself but I am confused by its usage in the PL/SQL block itself. For example, does it need to be declared?
pl/SQl block or PL/SQl table(associate array) ?
this example will help, if i got is correct
SQL> declare
2 cur_emp sys_refcursor;
3 type t_obj is record( empno number, ename varchar2(25));
4 type t_tab is table of t_obj index by binary_integer;
5 tt t_tab;
6 begin
7 open cur_emp for
8 select empno,ename from emp where deptno=10;
9 loop
10 fetch cur_emp BULK collect into tt;
11 exit when cur_emp%notfound;
12 end loop;
13 for i in 1..tt.count loop
14 dbms_output.put_line('empno :' ||tt(i).empno||' ename :'||tt(i).ename);
15 end loop;
16 end;
17 /
empno :7782 ename :CLARK
empno :7839 ename :KING
empno :7934 ename :MI_LL_ER
PL/SQL procedure successfully completed.
Maybe you are looking for
-
ECC = SNC ReplenishmentOrderNotification custom message through SAP PI
Helllo, I have one issue during proxy call in SNC. We are implementing SNC system with our ECC 6.0 system for PO processing, PO Confirmation Processing. The interfaces used is the standard SNC PI package from SAP through SAP PI; however, we have exte
-
Reinstall OS X Mavericks on Macbook Pro
Trying to reinstall OS after the machine wouldn't work when I tried OS upgrade. I formatted Macintish HD. It looks like it downloads successfully but never restarts afterwards. No matter what I try it just boots into OS X Utilities. When I go int
-
I have been using Firefox for a long time with no problem! Then my provider Comcast went from Smartzone to XfinityConnect and now I can not open my E-mails and the people for Comcast say they don't know why?
-
BW query as Iview(Urgent)
Dear Folks, I am trying to create BW related BEx queries as Iview in EP. Every thing is fine,but when I am checking the preview of the view its showing the query direct output, instead of showing Query Selection screen first. How can I show the Selec
-
TM switches itself off once-a-week...
As the subject line says... it starts again after I switch the slider back to ON in Time Machine Preferences. My TM volume is an external USB-disk that's left on 24/7, also when sleeping my Mac Mini overnight, and is still there when it awakens. The