<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6014437777354318039</id><updated>2025-05-29T17:34:43.213-07:00</updated><title type='text'>SQL ,PLSQL , Unix</title><subtitle type='html'>Tips and Tricks on PLSQL programming, SQL programming and Unix shell scripting</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>50</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-8709802898142197421</id><published>2021-08-05T05:57:00.002-07:00</published><updated>2021-08-05T05:57:17.142-07:00</updated><title type='text'>Identify current and prev details of a customer</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;create table customer_rating(&lt;/p&gt;&lt;p&gt;id char,&lt;/p&gt;&lt;p&gt;name char,&lt;/p&gt;&lt;p&gt;irrating char,&lt;/p&gt;&lt;p&gt;jcrrating char,&lt;/p&gt;&lt;p&gt;procDate date,&lt;/p&gt;&lt;p&gt;flag char&lt;/p&gt;&lt;p&gt;);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;insert into customer_rating values(&#39;A&#39;,&#39;D&#39;,&#39;X&#39;,&#39;Y&#39;,&#39;28-Jul-21&#39;,&#39;M&#39;);&lt;/p&gt;&lt;p&gt;insert into customer_rating values(&#39;A&#39;,&#39;D&#39;,&#39;M&#39;,&#39;L&#39;,&#39;27-Jul-21&#39;,&#39;M&#39;);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Select &lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;cr.id,&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;cr.name,&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;cr_prev.irrating pcob_rating,&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;cr.irrating cob_rating,&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;cr_prev.jcrrating pcob_jcr_rating,&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;cr.jcrrating cob_jcr_rating&lt;/p&gt;&lt;p&gt;From &lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Customer_Rating cr join&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;Customer_Rating cr_Prev&amp;nbsp; ON&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;cr.procdate = &#39;28-Jul-21&#39; AND&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;cr_prev.id = cr.id AND&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;cr_prev.procdate = (&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;Select max(procdate) from Customer_Rating&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;Where id=cr.id and procdate &amp;lt; cr.procdate&lt;/p&gt;&lt;p&gt;) ;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/8709802898142197421/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/8709802898142197421?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/8709802898142197421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/8709802898142197421'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2021/08/identify-current-and-prev-details-of.html' title='Identify current and prev details of a customer'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-4423267616350729616</id><published>2016-04-26T22:05:00.001-07:00</published><updated>2016-04-26T22:05:36.173-07:00</updated><title type='text'>Design and Operations ( Employee- Model )</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre style=&quot;-webkit-text-size-adjust: auto; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;pre style=&quot;white-space: pre-wrap; word-wrap: break-word;&quot;&gt;-- DB design
drop table emp_Salary;
drop table emp_Designation;
drop table emp;
drop table Designations;
drop table Departments;
drop table Salary_Bands;
drop table Addresses;

Create table emp(
        emp_id                  number,
        emp_Name                varchar2(20),
        emp_address_id          varchar2(10),
        emp_created_date        date,
        emp_created_by          varchar2(20),
        constraint e_pk primary key(emp_id)
);

Create table Departments(
        dept_id                 number,
        dept_name               Varchar2(20),
        constraints dept_pk primary key(dept_id)
);

Create table Designations(
        dept_id number references Departments(dept_id),
        desg_id number,
        desg_description varchar2(20),
        constraints desg_pk primary key(dept_id,desg_id)        
);

Create table emp_Designation(
        emp_id                  number references emp(emp_id),
        emp_des_dept_id         number references departments(dept_id),
        emp_desg_id             number
);

Create table Salary_Bands(
        band_id         number,
        band_amount     float(20),
        constraints sal_band_pk primary key(band_id)
);

Create table emp_Salary(
        emp_id                  number  references emp(emp_id),
        emp_sal_band_id         number  references Salary_Bands(band_id),
        emp_sal_percentage      number,
        constraints emp_sal_pk primary key(emp_id,emp_sal_band_id)
);

Create table Addresses(
        address_id number,
        address_zip varchar2(10),
        address_country varchar2(100),
        address_city varchar2(100),
        address_town varchar2(100),
        address_street varchar2(100),
        address_desc varchar2(100),
        constraint addr_pk primary key(address_id)                
);


--Populate master details that do not have dependency on EMP data 
--Addresses
insert into addresses(address_id,address_zip,address_country,address_city,address_town,address_street,address_desc)
values(1001,&#39;&lt;a dir=&quot;ltr&quot; href=&quot;tel:1360072&quot; x-apple-data-detectors-result=&quot;0&quot; x-apple-data-detectors-type=&quot;telephone&quot; x-apple-data-detectors=&quot;true&quot;&gt;1360072&lt;/a&gt;&#39;,&#39;Japan&#39;,&#39;Tokyo&#39;,&#39;Koto&#39;,&#39;Ojima&#39;,&#39;4-1-3-749&#39;);
insert into addresses(address_id,address_zip,address_country,address_city,address_town,address_street,address_desc)
values(1002,&#39;&lt;a dir=&quot;ltr&quot; href=&quot;tel:1360072&quot; x-apple-data-detectors-result=&quot;1&quot; x-apple-data-detectors-type=&quot;telephone&quot; x-apple-data-detectors=&quot;true&quot;&gt;1360072&lt;/a&gt;&#39;,&#39;Japan&#39;,&#39;Tokyo&#39;,&#39;Koto&#39;,&#39;Ojima&#39;,&#39;4-1-3-750&#39;);
insert into addresses(address_id,address_zip,address_country,address_city,address_town,address_street,address_desc)
values(1003,&#39;&lt;a dir=&quot;ltr&quot; href=&quot;tel:1360072&quot; x-apple-data-detectors-result=&quot;2&quot; x-apple-data-detectors-type=&quot;telephone&quot; x-apple-data-detectors=&quot;true&quot;&gt;1360072&lt;/a&gt;&#39;,&#39;Japan&#39;,&#39;Tokyo&#39;,&#39;Koto&#39;,&#39;Ojima&#39;,&#39;4-1-3-751&#39;);
insert into addresses(address_id,address_zip,address_country,address_city,address_town,address_street,address_desc)
values(1004,&#39;&lt;a dir=&quot;ltr&quot; href=&quot;tel:1360072&quot; x-apple-data-detectors-result=&quot;3&quot; x-apple-data-detectors-type=&quot;telephone&quot; x-apple-data-detectors=&quot;true&quot;&gt;1360072&lt;/a&gt;&#39;,&#39;Japan&#39;,&#39;Tokyo&#39;,&#39;Koto&#39;,&#39;Ojima&#39;,&#39;4-1-3-752&#39;);
insert into addresses(address_id,address_zip,address_country,address_city,address_town,address_street,address_desc)
values(1005,&#39;&lt;a dir=&quot;ltr&quot; href=&quot;tel:1360072&quot; x-apple-data-detectors-result=&quot;4&quot; x-apple-data-detectors-type=&quot;telephone&quot; x-apple-data-detectors=&quot;true&quot;&gt;1360072&lt;/a&gt;&#39;,&#39;Japan&#39;,&#39;Tokyo&#39;,&#39;Koto&#39;,&#39;Ojima&#39;,&#39;4-1-3-753&#39;);
insert into addresses(address_id,address_zip,address_country,address_city,address_town,address_street,address_desc)
values(1006,&#39;&lt;a dir=&quot;ltr&quot; href=&quot;tel:1360072&quot; x-apple-data-detectors-result=&quot;5&quot; x-apple-data-detectors-type=&quot;telephone&quot; x-apple-data-detectors=&quot;true&quot;&gt;1360072&lt;/a&gt;&#39;,&#39;Japan&#39;,&#39;Tokyo&#39;,&#39;Koto&#39;,&#39;Ojima&#39;,&#39;4-1-3-754&#39;);
insert into addresses(address_id,address_zip,address_country,address_city,address_town,address_street,address_desc)
values(1007,&#39;&lt;a dir=&quot;ltr&quot; href=&quot;tel:1360072&quot; x-apple-data-detectors-result=&quot;6&quot; x-apple-data-detectors-type=&quot;telephone&quot; x-apple-data-detectors=&quot;true&quot;&gt;1360072&lt;/a&gt;&#39;,&#39;Japan&#39;,&#39;Tokyo&#39;,&#39;Koto&#39;,&#39;Ojima&#39;,&#39;4-1-3-755&#39;);

--Departments
insert into departments(dept_id,dept_name) values(100,&#39;IT Solutions&#39;);
insert into departments(dept_id,dept_name) values(200,&#39;Marketing&#39;);
insert into departments(dept_id,dept_name) values(300,&#39;Customer Desk&#39;);
insert into departments(dept_id,dept_name) values(400,&#39;Reception&#39;);
insert into departments(dept_id,dept_name) values(500,&#39;Business Department&#39;);
insert into departments(dept_id,dept_name) values(1,&#39;Office of CEO&#39;);

-- Designations
insert into Designations(dept_id,desg_id,desg_description) values(100,1,&#39;Developer&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(100,2,&#39;Tester&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(100,3,&#39;Senior Developer&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(100,4,&#39;Technical Lead&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(100,5,&#39;Sr.Staff&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(200,1,&#39;Executive&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(200,2,&#39;Junior Executive&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(300,1,&#39;Desktop Engineer&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(300,2,&#39;Customer Person&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(400,1,&#39;Receptionist&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(500,1,&#39;Biz User&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(500,2,&#39;BA Architect&#39;);
insert into Designations(dept_id,desg_id,desg_description) values(1,1,&#39;CEO&#39;);

--- Salary_Bands
insert into salary_bands(band_id,band_amount) values(1,100000);
insert into salary_bands(band_id,band_amount) values(2,200000);
insert into salary_bands(band_id,band_amount) values(3,300000);
insert into salary_bands(band_id,band_amount) values(4,400000);
insert into salary_bands(band_id,band_amount) values(5,500000);
insert into salary_bands(band_id,band_amount) values(6,600000);
insert into salary_bands(band_id,band_amount) values(7,700000);
insert into salary_bands(band_id,band_amount) values(8,800000);
insert into salary_bands(band_id,band_amount) values(9,900000);
insert into salary_bands(band_id,band_amount) values(10,1000000);
insert into salary_bands(band_id,band_amount) values(11,1100000);
insert into salary_bands(band_id,band_amount) values(12,1200000);
insert into salary_bands(band_id,band_amount) values(13,1300000);
insert into salary_bands(band_id,band_amount) values(14,1400000);
insert into salary_bands(band_id,band_amount) values(15,1500000);
insert into salary_bands(band_id,band_amount) values(16,1600000);
insert into salary_bands(band_id,band_amount) values(17,1700000);
insert into salary_bands(band_id,band_amount) values(18,1800000);
insert into salary_bands(band_id,band_amount) values(19,1900000);
insert into salary_bands(band_id,band_amount) values(20,2000000);
insert into salary_bands(band_id,band_amount) values(21,2100000);
insert into salary_bands(band_id,band_amount) values(22,2200000);
insert into salary_bands(band_id,band_amount) values(23,2300000);
insert into salary_bands(band_id,band_amount) values(24,2400000);
insert into salary_bands(band_id,band_amount) values(25,2500000);
insert into salary_bands(band_id,band_amount) values(26,2600000);
insert into salary_bands(band_id,band_amount) values(27,2700000);
insert into salary_bands(band_id,band_amount) values(28,2800000);
insert into salary_bands(band_id,band_amount) values(29,2900000);
insert into salary_bands(band_id,band_amount) values(30,3000000);
insert into salary_bands(band_id,band_amount) values(35,3500000);
insert into salary_bands(band_id,band_amount) values(40,4000000);
insert into salary_bands(band_id,band_amount) values(45,4500000);
insert into salary_bands(band_id,band_amount) values(50,5000000);

--Employee data 
insert into emp(emp_id,emp_name,emp_address_id,emp_created_date,emp_created_by) values(10001,&#39;Name 1&#39;,1003,sysdate,user);
insert into emp(emp_id,emp_name,emp_address_id,emp_created_date,emp_created_by) values(10002,&#39;Name 2&#39;,1001,sysdate,user);
insert into emp(emp_id,emp_name,emp_address_id,emp_created_date,emp_created_by) values(10003,&#39;Name 3&#39;,1002,sysdate,user);
insert into emp(emp_id,emp_name,emp_address_id,emp_created_date,emp_created_by) values(10004,&#39;Name 4&#39;,1004,sysdate,user);
insert into emp(emp_id,emp_name,emp_address_id,emp_created_date,emp_created_by) values(10005,&#39;Name 5&#39;,1005,sysdate,user);
insert into emp(emp_id,emp_name,emp_address_id,emp_created_date,emp_created_by) values(10006,&#39;Name 6&#39;,1006,sysdate,user);
insert into emp(emp_id,emp_name,emp_address_id,emp_created_date,emp_created_by) values(10007,&#39;Name 7&#39;,1003,sysdate,user);
insert into emp(emp_id,emp_name,emp_address_id,emp_created_date,emp_created_by) values(10008,&#39;Name 8&#39;,1004,sysdate,user);
insert into emp(emp_id,emp_name,emp_address_id,emp_created_date,emp_created_by) values(10009,&#39;Name 9&#39;,1007,sysdate,user);
insert into emp(emp_id,emp_name,emp_address_id,emp_created_date,emp_created_by) values(10010,&#39;Name 10&#39;,1005,sysdate,user);

--Emp department and Designation
insert into emp_designation(emp_id,emp_des_dept_id,emp_desg_id) values(10001,100,1);
insert into emp_designation(emp_id,emp_des_dept_id,emp_desg_id) values(10002,100,1);
insert into emp_designation(emp_id,emp_des_dept_id,emp_desg_id) values(10003,200,1);
insert into emp_designation(emp_id,emp_des_dept_id,emp_desg_id) values(10004,200,1);
insert into emp_designation(emp_id,emp_des_dept_id,emp_desg_id) values(10005,300,1);
insert into emp_designation(emp_id,emp_des_dept_id,emp_desg_id) values(10006,300,2);
insert into emp_designation(emp_id,emp_des_dept_id,emp_desg_id) values(10007,100,2);
insert into emp_designation(emp_id,emp_des_dept_id,emp_desg_id) values(10008,100,2);
insert into emp_designation(emp_id,emp_des_dept_id,emp_desg_id) values(10009,500,1);
insert into emp_designation(emp_id,emp_des_dept_id,emp_desg_id) values(10010,500,2);

--Emp Salary
insert into emp_salary(emp_id,emp_sal_band_id,emp_sal_percentage) values(10001,1,100);
insert into emp_salary(emp_id,emp_sal_band_id,emp_sal_percentage) values(10002,2,100);
insert into emp_salary(emp_id,emp_sal_band_id,emp_sal_percentage) values(10003,3,100);
insert into emp_salary(emp_id,emp_sal_band_id,emp_sal_percentage) values(10004,4,100);
insert into emp_salary(emp_id,emp_sal_band_id,emp_sal_percentage) values(10005,1,100);
insert into emp_salary(emp_id,emp_sal_band_id,emp_sal_percentage) values(10006,2,100);
insert into emp_salary(emp_id,emp_sal_band_id,emp_sal_percentage) values(10007,4,100);
insert into emp_salary(emp_id,emp_sal_band_id,emp_sal_percentage) values(10008,5,100);
insert into emp_salary(emp_id,emp_sal_band_id,emp_sal_percentage) values(10009,2,100);
insert into emp_salary(emp_id,emp_sal_band_id,emp_sal_percentage) values(10010,6,100);

commit;


--Get All Employees Details ( Department, Salary , Designation , Address ) order by Department
SELECT e.emp_id, e.emp_name, d.desg_description, sb.band_amount,
          a.address_country
       || &#39; &#39;
       || a.address_city
       || &#39; &#39;
       || a.address_town
       || &#39; &#39;
       || a.address_street
       || &#39; &#39;
       || a.address_desc address
  FROM emp e,
       emp_designation ed,
       emp_salary es,
       addresses a,
       designations d,
       salary_bands sb
 WHERE 1 = 1
   AND es.emp_sal_band_id = sb.band_id
   AND ed.emp_desg_id = d.desg_id
   AND ed.emp_des_dept_id = d.dept_id
   AND e.emp_address_id = a.address_id
   AND e.emp_id = es.emp_id
   AND e.emp_id = ed.emp_id
Order by 3;


--Find out employees who share the same address
Select  e1.emp_id,
        e1.emp_name,
        a.* 
from    emp e1,
        emp e2,
        addresses a
Where 1=1
and e1.EMP_ADDRESS_ID = a.ADDRESS_ID
and e1.EMP_ID != e2.EMP_ID
and e1.EMP_ADDRESS_ID = e2.EMP_ADDRESS_ID
order by e1.emp_address_id,e1.emp_id;

--Find out employees who get max salary in the same department 
SELECT all_details.dept_name, all_details.emp_id, all_details.emp_name,
       all_details.band_amount amount
  FROM (SELECT   ed.emp_des_dept_id dept_id, MAX (sb.band_amount) max_salary
            FROM emp e, emp_designation ed, emp_salary es, salary_bands sb
           WHERE emp_sal_band_id = band_id
             AND e.emp_id = es.emp_id
             AND e.emp_id = ed.emp_id
        GROUP BY ed.emp_des_dept_id) maxsalary,
       (SELECT e.emp_id, e.emp_name, ed.emp_des_dept_id, d.dept_name,
               sb.band_amount
          FROM emp e,
               emp_designation ed,
               emp_salary es,
               salary_bands sb,
               departments d
         WHERE d.dept_id = ed.emp_des_dept_id
           AND emp_sal_band_id = band_id
           AND e.emp_id = es.emp_id
           AND e.emp_id = ed.emp_id) all_details
 WHERE all_details.band_amount = maxsalary.max_salary
   AND all_details.emp_des_dept_id = maxsalary.dept_id;&lt;/pre&gt;
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/4423267616350729616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/4423267616350729616?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/4423267616350729616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/4423267616350729616'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2016/04/design-and-operations-employee-model.html' title='Design and Operations ( Employee- Model )'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-6764943446425953549</id><published>2016-04-09T22:26:00.000-07:00</published><updated>2016-04-09T22:26:16.126-07:00</updated><title type='text'>Read Live Logs from SQL</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
How to read live logs from SQL?&lt;br /&gt;&lt;br /&gt;Consider that you want to read the following application log from SQL.&lt;br /&gt;/var/log/appDaily.log&lt;br /&gt;&lt;br /&gt;1. Create a directory&lt;br /&gt;CREATE OR REPLACE DIRECTORY live_Log_Directory AS &#39;/var/log&#39;;&lt;br /&gt;&lt;br /&gt;2. Create external table&lt;br /&gt;CREATE TABLE Live_APP_Log(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; log_text CHAR(250)&lt;br /&gt;)&lt;br /&gt;ORGANIZATION external(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type Oracle_Loader&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Default Directory live_Log_Directory&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; records delimited by newline&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOCATION(&#39;appDaily.log&#39;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Reject limit unlimited;&lt;br /&gt;&lt;br /&gt;3. Create a view on Live_APP_Log&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create or Replace view App_Log_Information&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select * from Live_APP_Log;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;4. Grant necessary permissions to users&lt;br /&gt;5. Now Query Live_APP_Log whenever you want to fetch log information from SQL&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/6764943446425953549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/6764943446425953549?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/6764943446425953549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/6764943446425953549'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2016/04/read-live-logs-from-sql.html' title='Read Live Logs from SQL'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-3947307852752115394</id><published>2015-11-04T03:02:00.000-08:00</published><updated>2015-11-04T03:02:16.164-08:00</updated><title type='text'>SQL - Binary Search Tree</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 18.0pt; margin-bottom: 7.5pt; vertical-align: baseline;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Problem Statement&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 18.0pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;You are given a table,&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;BST&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;,
containing two columns:&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;N&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;and&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;P,&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;where&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;N&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;represents
the value of a node in&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;BST&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;, and&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;P&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;is the
parent of&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;N&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 18.0pt; margin-bottom: 12.0pt; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-no-proof: yes;&quot;&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id=&quot;_x0000_t75&quot;
 coordsize=&quot;21600,21600&quot; o:spt=&quot;75&quot; o:preferrelative=&quot;t&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot;
 filled=&quot;f&quot; stroked=&quot;f&quot;&gt;
 &lt;v:stroke joinstyle=&quot;miter&quot;/&gt;
 &lt;v:formulas&gt;
  &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;/&gt;
  &lt;v:f eqn=&quot;sum @0 1 0&quot;/&gt;
  &lt;v:f eqn=&quot;sum 0 0 @1&quot;/&gt;
  &lt;v:f eqn=&quot;prod @2 1 2&quot;/&gt;
  &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;/&gt;
  &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;/&gt;
  &lt;v:f eqn=&quot;sum @0 0 1&quot;/&gt;
  &lt;v:f eqn=&quot;prod @6 1 2&quot;/&gt;
  &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;/&gt;
  &lt;v:f eqn=&quot;sum @8 21600 0&quot;/&gt;
  &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;/&gt;
  &lt;v:f eqn=&quot;sum @10 21600 0&quot;/&gt;
 &lt;/v:formulas&gt;
 &lt;v:path o:extrusionok=&quot;f&quot; gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot;/&gt;
 &lt;o:lock v:ext=&quot;edit&quot; aspectratio=&quot;t&quot;/&gt;
&lt;/v:shapetype&gt;&lt;v:shape id=&quot;Picture_x0020_1&quot; o:spid=&quot;_x0000_i1027&quot; type=&quot;#_x0000_t75&quot;
 alt=&quot;https://s3.amazonaws.com/hr-challenge-images/12888/1443818507-5095ab9853-1.png&quot;
 style=&#39;width:236.25pt;height:105pt;visibility:visible;mso-wrap-style:square&#39;&gt;
 &lt;v:imagedata src=&quot;file:///C:\Users\MCSMUR~1\AppData\Local\Temp\msohtmlclip1\01\clip_image001.gif&quot;
  o:title=&quot;1443818507-5095ab9853-1&quot;/&gt;
&lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;!--[endif]--&gt;&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 18.0pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Write a query to find the
node type of&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;BST&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;ordered
by the value of the node. Output one of the following for each node:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 16.8pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 30.0pt; margin-right: 0in; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in; vertical-align: baseline;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #39424e; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 13.5pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; font-stretch: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Root&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;: If
node is root node.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 16.8pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 30.0pt; margin-right: 0in; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in; vertical-align: baseline;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #39424e; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 13.5pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; font-stretch: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Leaf&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;: If
node is leaf node.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 16.8pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 30.0pt; margin-right: 0in; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in; vertical-align: baseline;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #39424e; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 13.5pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; font-stretch: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Inner&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;: If
node is neither root nor leaf node.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 18.0pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Sample
Input&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse; width: 128px;&quot;&gt;
 &lt;colgroup&gt;&lt;col span=&quot;2&quot; style=&quot;width: 48pt;&quot; width=&quot;64&quot;&gt;&lt;/col&gt;
 &lt;/colgroup&gt;&lt;tbody&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 15.0pt;&quot;&gt;
  &lt;td class=&quot;xl63&quot; height=&quot;20&quot; style=&quot;height: 15.0pt; width: 48pt;&quot; width=&quot;64&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;xl63&quot; style=&quot;border-left: none; width: 48pt;&quot; width=&quot;64&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 15.0pt;&quot;&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; height=&quot;20&quot; style=&quot;border-top: none; height: 15.0pt;&quot;&gt;1&lt;/td&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; style=&quot;border-left: none; border-top: none;&quot;&gt;2&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 15.0pt;&quot;&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; height=&quot;20&quot; style=&quot;border-top: none; height: 15.0pt;&quot;&gt;3&lt;/td&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; style=&quot;border-left: none; border-top: none;&quot;&gt;2&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 15.0pt;&quot;&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; height=&quot;20&quot; style=&quot;border-top: none; height: 15.0pt;&quot;&gt;6&lt;/td&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; style=&quot;border-left: none; border-top: none;&quot;&gt;8&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 15.0pt;&quot;&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; height=&quot;20&quot; style=&quot;border-top: none; height: 15.0pt;&quot;&gt;9&lt;/td&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; style=&quot;border-left: none; border-top: none;&quot;&gt;8&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 15.0pt;&quot;&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; height=&quot;20&quot; style=&quot;border-top: none; height: 15.0pt;&quot;&gt;2&lt;/td&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; style=&quot;border-left: none; border-top: none;&quot;&gt;5&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 15.0pt;&quot;&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; height=&quot;20&quot; style=&quot;border-top: none; height: 15.0pt;&quot;&gt;8&lt;/td&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; style=&quot;border-left: none; border-top: none;&quot;&gt;5&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 15.0pt;&quot;&gt;
  &lt;td align=&quot;right&quot; class=&quot;xl63&quot; height=&quot;20&quot; style=&quot;border-top: none; height: 15.0pt;&quot;&gt;5&lt;/td&gt;
  &lt;td class=&quot;xl63&quot; style=&quot;border-left: none; border-top: none;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; null&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 18.0pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Sample
Output&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: white; border: solid #C2C7D0 1.0pt; mso-border-alt: solid #C2C7D0 .75pt; mso-element: para-border-div; padding: 15.0pt 15.0pt 15.0pt 15.0pt;&quot;&gt;

&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; line-height: 13.5pt; margin-bottom: 0.0001pt; padding: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #454c59; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;1 Leaf&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; line-height: 13.5pt; margin-bottom: 0.0001pt; padding: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #454c59; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;2 Inner&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; line-height: 13.5pt; margin-bottom: 0.0001pt; padding: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #454c59; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;3 Leaf&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; line-height: 13.5pt; margin-bottom: 0.0001pt; padding: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #454c59; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;5 Root&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; line-height: 13.5pt; margin-bottom: 0.0001pt; padding: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #454c59; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;6 Leaf&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; line-height: 13.5pt; margin-bottom: 0.0001pt; padding: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #454c59; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;8 Inner&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; line-height: 13.5pt; margin-bottom: 0.0001pt; padding: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #454c59; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;9 Leaf&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 18.0pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Explanation&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 18.0pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;The&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;inherit&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;BST&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #39424e; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;below illustrates the sample:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQgk-mPF0D0KRxTq_lWXmekbhMoyKbbZlfmN6eCRkDgNl3tzRK-2QxI1NxpJRNs95zhrbPno8h7QrA3YkLHanfkkZd86PFfe869xx0r_WNTqTo8NBwK__1Tr4boZpQgaQp9stbD3lsSIc/s1600/bst.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;155&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQgk-mPF0D0KRxTq_lWXmekbhMoyKbbZlfmN6eCRkDgNl3tzRK-2QxI1NxpJRNs95zhrbPno8h7QrA3YkLHanfkkZd86PFfe869xx0r_WNTqTo8NBwK__1Tr4boZpQgaQp9stbD3lsSIc/s320/bst.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 18.0pt; margin-bottom: 12.0pt; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;u&gt;Query&lt;/u&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
select&amp;nbsp; N,&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
case&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp; when P is null then
&#39;Root&#39;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp; else &lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; decode((Select
count(1)&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from BST&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Where
N!=b.N&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; connect
by prior N=P&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; start
with N=b.N),0,&#39;Leaf&#39;,&#39;Inner&#39;)&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
end &quot;Leaf V&quot;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
from&amp;nbsp;&amp;nbsp;&amp;nbsp; BST b order by
1;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;field-label&quot; style=&quot;background-color: white; border: 0px; color: #39424e; font-family: &#39;Whitney SSm A&#39;, &#39;Whitney SSm B&#39;, verdana, &#39;Lucida Grande&#39;, sans-serif; font-size: 14px; font-stretch: inherit; font-weight: bold; line-height: 1.5em; margin-bottom: 5px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Your Output (stdout)&lt;/div&gt;
&lt;pre class=&quot;error-output&quot; style=&quot;background: rgb(239, 239, 239); border-radius: 0px; border: 1px solid rgb(204, 204, 204); color: #454c59; font-family: Menlo, Monaco, Consolas, &#39;Courier New&#39;, monospace; font-size: 14px; font-stretch: inherit; line-height: 18px; margin-bottom: 9px; outline: 0px; overflow: auto; padding: 8px; vertical-align: baseline; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;code style=&quot;background: transparent; border-radius: 3px; border: 0px; color: inherit; font-family: Menlo, Monaco, Consolas, &#39;Courier New&#39;, monospace; font-size: 1em; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;1 Leaf 
2 Inner 
3 Leaf 
4 Inner 
5 Leaf 
6 Inner 
7 Leaf 
8 Leaf 
9 Inner 
10 Leaf 
11 Inner 
12 Leaf 
13 Inner 
14 Leaf 
15 Root &lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/3947307852752115394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/3947307852752115394?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/3947307852752115394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/3947307852752115394'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2015/11/sql-binary-search-tree.html' title='SQL - Binary Search Tree'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQgk-mPF0D0KRxTq_lWXmekbhMoyKbbZlfmN6eCRkDgNl3tzRK-2QxI1NxpJRNs95zhrbPno8h7QrA3YkLHanfkkZd86PFfe869xx0r_WNTqTo8NBwK__1Tr4boZpQgaQp9stbD3lsSIc/s72-c/bst.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-2778723120835927777</id><published>2015-10-17T05:24:00.002-07:00</published><updated>2015-10-17T05:24:47.846-07:00</updated><title type='text'>Asian Population</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;msB&quot; style=&quot;background-color: white; border: 0px; color: #39424e; font-family: &#39;Whitney SSm A&#39;, &#39;Whitney SSm B&#39;, verdana, &#39;Lucida Grande&#39;, sans-serif; font-size: 16px; font-stretch: inherit; line-height: 22.4px; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;div style=&quot;border: 0px; font-size: 18px; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;strong style=&quot;border: 0px; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;Problem Statement&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;msB&quot; style=&quot;background-color: white; border: 0px; font-stretch: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; color: #39424e; font-family: &#39;Whitney SSm A&#39;, &#39;Whitney SSm B&#39;, verdana, &#39;Lucida Grande&#39;, sans-serif; font-size: 18px; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
Given two tables,&amp;nbsp;&lt;em style=&quot;border: 0px; font-family: inherit; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;City&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;em style=&quot;border: 0px; font-family: inherit; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;Country&lt;/em&gt;&amp;nbsp;whose descriptions are given below. Find the sum of population of all the Cities that lies in&amp;nbsp;&lt;em style=&quot;border: 0px; font-family: inherit; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;&quot;Asia&quot;&lt;/em&gt;&amp;nbsp;continent.&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; color: #39424e; font-family: &#39;Whitney SSm A&#39;, &#39;Whitney SSm B&#39;, verdana, &#39;Lucida Grande&#39;, sans-serif; font-size: 18px; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;em style=&quot;border: 0px; font-family: inherit; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;City&lt;/em&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border-radius: 3px; border: 1px solid rgb(194, 199, 208); color: #454c59; font-family: Menlo, Monaco, Consolas, &#39;Courier New&#39;, monospace; font-size: 14px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 18px; margin-bottom: 9px; outline: 0px; padding: 20px; vertical-align: baseline; white-space: pre-wrap; word-break: break-word; word-wrap: break-word;&quot;&gt;&lt;code style=&quot;background: transparent; border-radius: 3px; border: 0px; color: inherit; font-family: Menlo, Monaco, Consolas, &#39;Courier New&#39;, monospace; font-size: 1em; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;+-------------+----------+
| Field       | Type     |
+-------------+----------+
| ID          | int(11)  |
| Name        | char(35) |
| CountryCode | char(3)  |
| District    | char(20) |
| Population  | int(11)  |
+-------------+----------+
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; color: #39424e; font-family: &#39;Whitney SSm A&#39;, &#39;Whitney SSm B&#39;, verdana, &#39;Lucida Grande&#39;, sans-serif; font-size: 18px; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;em style=&quot;border: 0px; font-family: inherit; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;Country&lt;/em&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border-radius: 3px; border: 1px solid rgb(194, 199, 208); color: #454c59; font-family: Menlo, Monaco, Consolas, &#39;Courier New&#39;, monospace; font-size: 14px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 18px; margin-bottom: 9px; outline: 0px; padding: 20px; vertical-align: baseline; white-space: pre-wrap; word-break: break-word; word-wrap: break-word;&quot;&gt;&lt;code style=&quot;background: transparent; border-radius: 3px; border: 0px; color: inherit; font-family: Menlo, Monaco, Consolas, &#39;Courier New&#39;, monospace; font-size: 1em; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;+----------------+-------------+
| Field          | Type        |
+----------------+-------------+
| Code           | char(3)     |
| Name           | char(52)    |
| Continent      | char(50)    |
| Region         | char(26)    |
| SurfaceArea    | float(10,2) |
| IndepYear      | smallint(6) |
| Population     | int(11)     |
| LifeExpectancy | float(3,1)  |
| GNP            | float(10,2) |
| GNPOld         | float(10,2) |
| LocalName      | char(45)    |
| GovernmentForm | char(45)    |
| HeadOfState    | char(60)    |
| Capital        | int(11)     |
| Code2          | char(2)     |
+----------------+-------------+
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; color: #39424e; font-family: &#39;Whitney SSm A&#39;, &#39;Whitney SSm B&#39;, verdana, &#39;Lucida Grande&#39;, sans-serif; font-size: 18px; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;em style=&quot;border: 0px; font-family: inherit; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;PS: City.CountryCode&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;em style=&quot;border: 0px; font-family: inherit; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;Country.Code&lt;/em&gt;&amp;nbsp;is same key.&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; color: #39424e; font-family: &#39;Whitney SSm A&#39;, &#39;Whitney SSm B&#39;, verdana, &#39;Lucida Grande&#39;, sans-serif; font-size: 18px; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-stretch: inherit; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: Whitney SSm A, Whitney SSm B, verdana, Lucida Grande, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 18px; line-height: 27px;&quot;&gt;Select &quot;Population&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-stretch: inherit; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: Whitney SSm A, Whitney SSm B, verdana, Lucida Grande, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 18px; line-height: 27px;&quot;&gt;from (Select &amp;nbsp;country.continent &quot;City&quot;,sum(city.population) &quot;Population&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-stretch: inherit; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: Whitney SSm A, Whitney SSm B, verdana, Lucida Grande, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 18px; line-height: 27px;&quot;&gt;from &amp;nbsp; &amp;nbsp;city,country&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-stretch: inherit; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: Whitney SSm A, Whitney SSm B, verdana, Lucida Grande, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 18px; line-height: 27px;&quot;&gt;where countrycode=code&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-stretch: inherit; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: Whitney SSm A, Whitney SSm B, verdana, Lucida Grande, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 18px; line-height: 27px;&quot;&gt;group by country.continent)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-stretch: inherit; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: Whitney SSm A, Whitney SSm B, verdana, Lucida Grande, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 18px; line-height: 27px;&quot;&gt;Where &quot;City&quot; = &#39;Asia&#39;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; font-stretch: inherit; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;&quot;&gt;
&lt;span style=&quot;color: #39424e; font-family: Whitney SSm A, Whitney SSm B, verdana, Lucida Grande, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 18px; line-height: 27px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;row&quot; style=&quot;border: 0px; color: #39424e; font-family: &#39;Whitney SSm A&#39;, &#39;Whitney SSm B&#39;, verdana, &#39;Lucida Grande&#39;, sans-serif; font-size: 16px; font-stretch: inherit; line-height: 22.4px; margin: 0px -7.5px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;span9 small bold&quot; style=&quot;border: 0px; box-sizing: border-box; float: left; font-size: 14.4px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: 600; line-height: 1.5em; outline: 0px; padding: 0px 7.5px; vertical-align: baseline; width: 683.438px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/2778723120835927777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/2778723120835927777?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/2778723120835927777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/2778723120835927777'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2015/10/asian-population.html' title='Asian Population'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-2704286893059644401</id><published>2015-09-28T19:59:00.001-07:00</published><updated>2015-09-28T19:59:08.032-07:00</updated><title type='text'>Minimum / Maximum from the given list</title><content type='html'>&lt;div&gt;File: Execute.java&lt;/div&gt;&lt;div&gt;--------------------------------------------------------------------------------------&lt;/div&gt;&lt;div&gt;package org.developersbrain.Solutions;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;public class Execute {&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;public static int min(int[] arrList){&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int minV1=0;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int minV2=0;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int aLen=arrList.length;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;minV1=arrList[0];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;minV2=arrList[aLen-1];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for(int i=0,j=aLen-1;i&amp;amp;lt;=aLen/2;i++,j--){&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if(minV1 &amp;amp;gt; arrList[i]){&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;minV1=arrList[i];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if(minV2 &amp;amp;gt; arrList[j]){&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;minV2=arrList[j];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if(minV2&amp;amp;lt;=minV1){&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;return minV2;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}else{&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;return minV1;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;public static int max(int[] arrList){&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int minV1=0;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int minV2=0;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int aLen=arrList.length;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;minV1=arrList[0];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;minV2=arrList[aLen-1];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for(int i=0,j=aLen-1;i&amp;amp;lt;=aLen/2;i++,j--){&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if(minV1 &amp;amp;lt; arrList[i]){&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;minV1=arrList[i];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if(minV2 &amp;amp;lt; arrList[j]){&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;minV2=arrList[j];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if(minV2&amp;amp;gt;=minV1){&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;return minV2;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}else{&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;return minV1;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;public static void main(String[] args) {&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int[] a={15,16,1,2,3,9,16,13,22,200,34,56,3,0,999,89,-1,-2,-99};&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for(int l:a) System.out.print(l+&quot; &quot;);&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;System.out.println();&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;System.out.println(&quot;Minimum:&quot;+min(a));&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;System.out.println(&quot;Maximum:&quot;+max(a));&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Output:&lt;/div&gt;&lt;div&gt;-------------------------&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;a dir=&quot;ltr&quot; href=&quot;tel:15%2016%201%202%203%209%2016%2013%2022&quot; x-apple-data-detectors=&quot;true&quot; x-apple-data-detectors-type=&quot;telephone&quot; x-apple-data-detectors-result=&quot;0&quot;&gt;15 16 1 2 3 9 16 13 22&lt;/a&gt; &lt;a dir=&quot;ltr&quot; href=&quot;tel:200%2034%2056%203%200%20999%2089%20-1&quot; x-apple-data-detectors=&quot;true&quot; x-apple-data-detectors-type=&quot;telephone&quot; x-apple-data-detectors-result=&quot;1&quot;&gt;200 34 56 3 0 999 89 -1&lt;/a&gt; -2 -99&amp;nbsp;&lt;/div&gt;&lt;div&gt;Minimum:-99&lt;/div&gt;&lt;div&gt;Maximum:999&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/2704286893059644401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/2704286893059644401?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/2704286893059644401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/2704286893059644401'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2015/09/minimum-maximum-from-given-list.html' title='Minimum / Maximum from the given list'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-811175078736244709</id><published>2015-05-12T20:03:00.001-07:00</published><updated>2015-05-12T20:03:35.859-07:00</updated><title type='text'>Simple SQLPLUS formatting</title><content type='html'>&amp;gt; SQL Prompt&amp;gt;SET SQLPROMPT &amp;quot;My SQL Prompt&amp;gt;&amp;quot;&lt;br&gt;&amp;gt; My SQL Prompt&amp;gt;SET COLSEP &amp;quot;|&amp;quot;&lt;br&gt;&amp;gt; My SQL Prompt&amp;gt;SET UNDERLINE &amp;quot;-&amp;quot;&lt;br&gt;&amp;gt; My SQL Prompt&amp;gt;SET LINESIZE 2000&lt;br&gt;&amp;gt; My SQL Prompt&amp;gt;SET PAGESIZE 1000&lt;br&gt;&amp;gt; My SQL Prompt&amp;gt;Select tbl2.*&lt;br&gt;&amp;gt;  2    From (Select *&lt;br&gt;&amp;gt;  3            From (Select 1 a,&lt;br&gt;&amp;gt;  4                         2 b,&lt;br&gt;&amp;gt;  5                         3 c,&lt;br&gt;&amp;gt;  6                         4 d,&lt;br&gt;&amp;gt;  7                         5 e&lt;br&gt;&amp;gt;  8                    From DUAL) tbl1) tbl2&lt;br&gt;&amp;gt;  9  Where   a=b-1;&lt;br&gt;&amp;gt; &lt;br&gt;&amp;gt;        A|        B|        C|        D|        E&lt;br&gt;&amp;gt; ---------|---------|---------|---------|---------&lt;br&gt;&amp;gt;        1|        2|        3|        4|        5&lt;br&gt;&amp;gt; &lt;br&gt;&amp;gt; 1 row selected.&lt;br&gt;&amp;gt;</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/811175078736244709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/811175078736244709?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/811175078736244709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/811175078736244709'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2015/05/simple-sqlplus-formatting.html' title='Simple SQLPLUS formatting'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-4589978663345201134</id><published>2015-05-11T06:02:00.002-07:00</published><updated>2015-05-11T06:03:00.054-07:00</updated><title type='text'>DUAL Table </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
The DUAL table was created by&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Charles_Weiss&quot; style=&quot;background: none; color: #0b0080; text-decoration: none;&quot; title=&quot;Charles Weiss&quot;&gt;Charles Weiss&lt;/a&gt;&amp;nbsp;of&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Oracle_Corporation&quot; style=&quot;background: none; color: #0b0080; text-decoration: none;&quot; title=&quot;Oracle Corporation&quot;&gt;Oracle Corporation&lt;/a&gt;&amp;nbsp;to provide a table for joining in internal&amp;nbsp;&lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/View_(database)&quot; style=&quot;background: none; color: #0b0080; text-decoration: none;&quot; title=&quot;View (database)&quot;&gt;views&lt;/a&gt;:&lt;/div&gt;
&lt;blockquote style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; overflow: hidden;&quot;&gt;
&lt;div style=&quot;line-height: inherit; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
I created the DUAL table as an underlying object in the Oracle Data Dictionary. It was never meant to be seen itself, but instead used inside a view that was expected to be queried. The idea was that you could do a JOIN to the DUAL table and create two rows in the result for every one row in your table. Then, by using GROUP BY, the resulting join could be summarized to show the amount of storage for the DATA extent and for the INDEX extent(s). The name, DUAL, apt for the process of creating a pair of rows from just one.&lt;sup class=&quot;reference&quot; id=&quot;cite_ref-1&quot; style=&quot;font-size: 11px; line-height: 1; unicode-bidi: -webkit-isolate;&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/DUAL_table#cite_note-1&quot; style=&quot;background: none; color: #0b0080; text-decoration: none; white-space: nowrap;&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
The original DUAL table had two rows in it (hence its name), but subsequently it only had one row.&lt;/div&gt;
&lt;h2 style=&quot;background: none rgb(255, 255, 255); border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; font-family: &#39;Linux Libertine&#39;, Georgia, Times, serif; font-weight: normal; line-height: 1.3; margin: 1em 0px 0.25em; overflow: hidden; padding: 0px;&quot;&gt;
&lt;span class=&quot;mw-headline&quot; id=&quot;Optimization&quot;&gt;Optimization&lt;/span&gt;&lt;/h2&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
Beginning with 10g Release 1 Oracle Database have been&lt;a class=&quot;hvvmvweu&quot; href=&quot;http://en.wikipedia.org/wiki/DUAL_table#&quot; style=&quot;-webkit-transform: none !important; background: 0px 0px !important; border: 0px !important; bottom: auto !important; box-sizing: border-box !important; clear: none !important; clip: auto !important; color: #0b0080; display: inline-block !important; float: none !important; font-weight: 700 !important; height: auto !important; left: auto; margin: 0px 0px 0px 3px !important; max-height: none !important; max-width: none !important; min-height: 0px !important; min-width: 0px !important; opacity: 1; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-transform: uppercase !important; top: auto; transform: none !important; vertical-align: baseline !important; visibility: visible !important; width: auto !important; z-index: auto !important; zoom: 1 !important;&quot; title=&quot;Click to Continue &amp;gt; by Provider&quot;&gt;OPTIMIZED&lt;img src=&quot;http://cdncache-a.akamaihd.net/items/it/img/arrow-10x10.png&quot; style=&quot;-webkit-transform: none !important; background: 0px 0px !important; border: 0px !important; bottom: auto !important; box-sizing: border-box !important; clear: none !important; clip: auto !important; display: inline-block !important; float: none !important; height: 10px !important; left: auto; margin: 0px 3px !important; max-height: none !important; max-width: none !important; min-height: 0px !important; min-width: 0px !important; opacity: 1; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-decoration: none !important; text-transform: none !important; top: auto; transform: none !important; vertical-align: super !important; visibility: visible !important; width: 10px !important; z-index: auto !important; zoom: 1 !important;&quot; /&gt;&lt;/a&gt;&lt;sup class=&quot;reference&quot; id=&quot;cite_ref-2&quot; style=&quot;font-size: 11px; line-height: 1; unicode-bidi: -webkit-isolate;&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/DUAL_table#cite_note-2&quot; style=&quot;background: none; color: #0b0080; text-decoration: none; white-space: nowrap;&quot;&gt;[2]&lt;/a&gt;&lt;/sup&gt;&amp;nbsp;and the database no longer performs physical or logical IO on the DUAL table even though the DUAL table still actually exists.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
DUAL is readily available for all the users in database.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
Courtesy: Wikipedia&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/4589978663345201134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/4589978663345201134?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/4589978663345201134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/4589978663345201134'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2015/05/dual-table.html' title='DUAL Table '/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-5695723338971998711</id><published>2015-04-17T07:55:00.001-07:00</published><updated>2015-04-17T07:55:06.243-07:00</updated><title type='text'>10 Million records manipulation in Oracle DB</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Say you are given a task to manipulate a set of 10 million records from a couple of tables.&lt;br /&gt;
What would you do? Sit and think???!!!!&lt;br /&gt;
&lt;br /&gt;
See if the following helps you..&lt;br /&gt;
&lt;br /&gt;
Replicate the tables data into temporary tables&lt;br /&gt;
Create indexes on the columns you want to manipulate the data&lt;br /&gt;
Write your query..&lt;br /&gt;
&lt;br /&gt;
Dont ask me what language you are talking!!!!&lt;br /&gt;
Look at the examples&lt;br /&gt;
&lt;br /&gt;
Select count(1) from hugeTable1;--7999900 records&lt;br /&gt;
Select count(1) from hugeTable2; --9893990&lt;br /&gt;
&lt;br /&gt;
Create table tmp1&lt;br /&gt;
as&lt;br /&gt;
Select *&lt;br /&gt;
from hugeTable1&lt;br /&gt;
where 1=2;&lt;br /&gt;
&lt;br /&gt;
insert /*+append*/ into tmp1&lt;br /&gt;
select * from hugeTable1;&lt;br /&gt;
&lt;br /&gt;
Create table tmp2&lt;br /&gt;
as&lt;br /&gt;
Select *&lt;br /&gt;
from hugeTable2&lt;br /&gt;
Where 1=2;&lt;br /&gt;
&lt;br /&gt;
insert /*+append*/ into tmp2&lt;br /&gt;
select * from hugeTable2;&lt;br /&gt;
&lt;br /&gt;
create index indTmp1 on tmp1(column1,column2);&lt;br /&gt;
create index indTmp2 on tmp2(column1,column2);&lt;br /&gt;
&lt;br /&gt;
Select *&lt;br /&gt;
from tmp1,tmp2&lt;br /&gt;
where tmp1.column1=tmp2.column1 and&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tmp1.column2=tmp2.column2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
Should you face any issues, please write to me ( susilaarya@gmail.com )&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/5695723338971998711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/5695723338971998711?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/5695723338971998711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/5695723338971998711'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2015/04/10-million-records-manipulation-in.html' title='10 Million records manipulation in Oracle DB'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-4626307671537676211</id><published>2015-04-16T06:42:00.001-07:00</published><updated>2015-04-16T06:42:10.267-07:00</updated><title type='text'>command to list files and its records count</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
wc - command is used to list all files in &amp;nbsp;a directory with its records count&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Prompt&amp;gt;$ wc -l *.txt&lt;/div&gt;
&lt;div&gt;
10 &amp;nbsp;file1.txt&lt;/div&gt;
&lt;div&gt;
93 &amp;nbsp;sampleFile.txt&lt;/div&gt;
&lt;div&gt;
199333 billingData.txt&lt;/div&gt;
&lt;div&gt;
65 &amp;nbsp;loadData.txt&lt;/div&gt;
&lt;div&gt;
Prompt&amp;gt;$&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/4626307671537676211/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/4626307671537676211?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/4626307671537676211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/4626307671537676211'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2015/04/command-to-list-files-and-its-records.html' title='command to list files and its records count'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-982959752661250987</id><published>2015-04-16T06:36:00.001-07:00</published><updated>2015-04-16T06:36:51.558-07:00</updated><title type='text'>database Search possible on Oracle?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This was asked in a meeting of following people and the answers are amazing...&lt;br /&gt;
&lt;br /&gt;
An Analyst replied&lt;br /&gt;
&amp;nbsp;- I need a month time to prepare analysis whether it is possible or the way possible&lt;br /&gt;
&lt;br /&gt;
Technical architect replied&lt;br /&gt;
&amp;nbsp;-It is not impossible but involves lots of work.&lt;br /&gt;
&lt;br /&gt;
Team Lead interrupted&lt;br /&gt;
&amp;nbsp;- Google it , you should be able to find it&lt;br /&gt;
&lt;br /&gt;
One in the team suggested&lt;br /&gt;
- It will cause performance issues&lt;br /&gt;
&lt;br /&gt;
Developer maintained a silence until everyone calmed down and said..&lt;br /&gt;
- Lets make use of data dictionaries&lt;br /&gt;
- Find out Varchar fields and construct a query&lt;br /&gt;
- Lets list objects that has the data searched&lt;br /&gt;
- We will then narrow down our search&lt;br /&gt;
- It is not time-consuming job yet not a quick one&lt;br /&gt;
&lt;br /&gt;
Analyst quickly replied - We know that, but it is not right to do as it will cause unnecessary issues&lt;br /&gt;
Team Lead &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Were you not supposed to complete the other assignment? You concentrate on that!!!&lt;br /&gt;
Technical Architect &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;- Do you know the system issues?&lt;br /&gt;
Developer &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - ??!!!?????!!!!!!!!&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/982959752661250987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/982959752661250987?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/982959752661250987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/982959752661250987'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2015/04/database-search-possible-on-oracle.html' title='database Search possible on Oracle?'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-5756037599791568320</id><published>2015-04-07T07:39:00.003-07:00</published><updated>2015-04-07T07:43:31.646-07:00</updated><title type='text'>unusual LINUX commands</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
1. file &lt;filename&gt;&lt;/filename&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Will list the file encoding details&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Read man page for more details&lt;br /&gt;
&lt;br /&gt;
2. pdftohtml &lt;file .pdf=&quot;&quot;&gt; &lt;file .html=&quot;&quot;&gt;&lt;/file&gt;&lt;/file&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Utility to convert pdf file to html format&lt;br /&gt;
&lt;br /&gt;
3. iconv -f &lt;encoding&gt; -t &lt;encoding&gt; &lt;filename&gt;&lt;/filename&gt;&lt;/encoding&gt;&lt;/encoding&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;- to change the file encoding from one format to another&lt;br /&gt;
&amp;nbsp;Ex:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; iconv -f UTF-16 -t ASCII filename.txt&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;- Read man page for more supported encoding formats&lt;br /&gt;
&lt;br /&gt;
4. &amp;nbsp;ls -R | grep -i *&lt;file&gt;*&lt;filename&gt;&lt;/filename&gt;&lt;/file&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; - List files in subdirectories&lt;br /&gt;
&lt;br /&gt;
5. &amp;nbsp;last&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; - To see the list of users who were connected to the system&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; - It gives you the list with the details logon time, logon ip, user id etc.,&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/5756037599791568320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/5756037599791568320?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/5756037599791568320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/5756037599791568320'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2015/04/unusual-linux-commands.html' title='unusual LINUX commands'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-2535342809111262003</id><published>2013-08-29T07:19:00.000-07:00</published><updated>2013-08-29T07:19:41.995-07:00</updated><title type='text'>Interview point of View - Technical - PLSQL</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
1. Write an SQL statement to delete all duplicate rows in a table.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Give all possible SQL statements that can be used to delete duplicate rows effectively.&lt;br /&gt;
&lt;br /&gt;
2. Consider the following table&lt;br /&gt;
&lt;br /&gt;
ID &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Name&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Role&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ManagerId&lt;br /&gt;
MGR6002&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;RajeshKumar&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Manager&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;MGR1001&lt;br /&gt;
TM1001&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Sridevi&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Associate&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;MGR6002&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
TM1002&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;John&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Sr.Associate&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;MGR6002&lt;br /&gt;
TM1008&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Rexan&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Associate&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;MGR6002&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
MGR6003&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Amruta&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Manager&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;MGR1001&lt;br /&gt;
MGR6004&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Justin&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Manager&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;MGR1001&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
MGR1001&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Ravikumar&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;GPM&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;VCH1001&lt;br /&gt;
TM1003&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Linton&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Associate&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;MGR6004&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
TM1003&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Kavitha&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Sr.Associate&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;MGR6004&lt;br /&gt;
TM1005&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Sailu&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Analyst&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;MGR6002&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
TM1006&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Sami&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Sr.Associate&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;MGR6001&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; Write an SQL to print employee list hierarchically&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Ex output.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Rajeshkumar&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;John&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Rexan&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Sailu&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Amruta&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Justin&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Linton&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Kavitha&lt;br /&gt;
&lt;br /&gt;
3. Write the SQL statement to obtain nth salary of employees.&lt;br /&gt;
4. What are triggers? Breifly explain trigger types.&lt;br /&gt;
5. Do you know about RBO, CBO? What is your understanding on them?&lt;br /&gt;
6. Explain FILE handling in PlSQL. Tell me the commonly used methods for file operations.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;gt; You may be asked to write a program to compare two files using file handling.&lt;br /&gt;
7. What are indexes? Explain its types.&lt;br /&gt;
8. What is your understanding on Oracle memory structure?&lt;br /&gt;
9. What are cursors? Explain its types with examples.&lt;br /&gt;
10. Differentiate Views, Inline views , materailized views.&lt;br /&gt;
11. Differentiate procedure, function, package.&lt;br /&gt;
12. What is the output of the following?&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;a.create table tabletmp(msg varchar(100));&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;b.insert into tabletmp values(&#39;Message 1&#39;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;c.insert into tabletmp values(&#39;Message 1&#39;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;d.insert into tabletmp values(&#39;Message 1&#39;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;e.insert into tabletmp values(&#39;Message 1&#39;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;f.insert into tabletmp values(&#39;Message 1&#39;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;g.create table tabletmp(msg varchar(100));&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;h.rollback;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;i.Select * from tabletmp;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;The execution sequence is : a,b,c,d,e,f,g,h,i&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;What is the output at &#39;g&#39;?&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;What is the output at &#39;i&#39;?&lt;br /&gt;
&lt;br /&gt;
13. What is the maximum number of columns allowed in a table?&lt;br /&gt;
14. Each record has a unique key in oracle, even if the table structure has no primary.What is that?&lt;br /&gt;
15. Distinguish primary key, indexes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/2535342809111262003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/2535342809111262003?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/2535342809111262003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/2535342809111262003'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2013/08/interview-point-of-view-technical-plsql.html' title='Interview point of View - Technical - PLSQL'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-984437921591289086</id><published>2013-07-03T04:47:00.001-07:00</published><updated>2013-07-03T04:47:55.503-07:00</updated><title type='text'>USER related commands in UNIX</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
 
 
 


&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;whoami&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
The command lets
you know the user name of the current shell you are at.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Example:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
root@Microknoppix:/home/knoppix#
whoami 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
root 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
root@Microknoppix:/home/knoppix#
su knoppix 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix@Microknoppix:~$
whoami 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;su&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
       The su
command is used to become another user during a login session.
Invoked without a username, su defaults to becoming the superuser.
The optional argument - may be used to provide an environment similar
to what the user would expect had the user logged in directly.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Example :&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
root@Microknoppix:/home/knoppix#
su knoppix 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
password:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix@Microknoppix:~$
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix@Microknoppix:/root$
su - 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
password:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
root@Microknoppix:~#
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix@Microknoppix:/root$
su&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
password:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
root@Microknoppix:~#
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;finger&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
The finger displays information about
the system users. 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Example:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
root@Microknoppix:~# finger knoppix 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Login: knoppix           Name: Knoppix
User 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Directory: /home/knoppix           
 Shell: /bin/bash 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
On since Sun Jun 30 01:43 (UTC) on
console from :0 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
   2 hours 8 minutes idle 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
     (messages off) 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
On since Sun Jun 30 01:43 (UTC) on :0
(messages off) 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
On since Sun Jun 30 03:31 (UTC) on
pts/0 from :0 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
No mail. 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
No Plan. 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
root@Microknoppix:~# finger root 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Login: root              Name: root 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Directory: /root                   
 Shell: /bin/bash 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Never logged in. 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
No mail. 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
No Plan. 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;who&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Print information about users who are
currently logged in.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;who -a, who --all &lt;/b&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix@Microknoppix:/root$ who -a 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                        2013-06-30
01:43              1858 id=si    term=0 exit=0 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
           system boot  2013-06-30
01:43 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
           run-level 5  2013-06-30
01:43                   last=S 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                        2013-06-30
01:43              2482 id=1 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                        2013-06-30
01:43              2486 id=x1 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                        2013-06-30
01:43              2485 id=4 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                        2013-06-30
01:43              2484 id=3 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                        2013-06-30
01:43              2483 id=2 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix  - console      2013-06-30
01:43  old         2486 (:0) 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix  ? :0           2013-06-30
01:43   ?          2486 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix  + pts/0        2013-06-30
03:31   .         12227 (:0) 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;who -d, who --dead &lt;/b&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
              To print dead processes 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix@Microknoppix:/root$ who -d 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                      2013-06-30 01:43 
            1858 id=si    term=0 exit=0 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;who -p, who --process &lt;/b&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
 To print active processes spawned by
init.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix@Microknoppix:/root$ who -p 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                      2013-06-30 01:43 
     2482 id=1 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                      2013-06-30 01:43 
     2486 id=x1 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                      2013-06-30 01:43 
     2485 id=4 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                      2013-06-30 01:43 
     2484 id=3 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
                      2013-06-30 01:43 
     2483 id=2 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;who -q, who--count &lt;/b&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
              To list all login names
and number of users logged on 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix@Microknoppix:/root$ who -q 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
knoppix susilaarya susil&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
# users=3 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/984437921591289086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/984437921591289086?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/984437921591289086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/984437921591289086'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2013/07/user-related-commands-in-unix.html' title='USER related commands in UNIX'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-1268100432192001283</id><published>2013-06-27T05:14:00.001-07:00</published><updated>2013-06-27T05:14:33.336-07:00</updated><title type='text'>Reader&#39;s message</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Dear readers,&lt;div&gt;
Apologies! I have been away so long since my last post.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Here you go!&lt;/div&gt;
&lt;div&gt;
I will try to continue my blogging at least frequently if not everyday.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Thank you! Enjoy learning!!!&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/1268100432192001283/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/1268100432192001283?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/1268100432192001283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/1268100432192001283'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2013/06/readers-message.html' title='Reader&#39;s message'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-6877087499970515356</id><published>2012-07-29T08:49:00.000-07:00</published><updated>2012-07-29T08:49:04.706-07:00</updated><title type='text'>4 Qs 4 Answers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #bbd3e8; font-family: Tahoma, Helvetica, sans-serif; font-size: 13px;&quot;&gt;1. How can I get recent 10 records out of 100 records?&lt;/span&gt;&lt;br /&gt;
SELECT *&lt;br /&gt;
FROM (Select *&lt;br /&gt;
from employee&lt;br /&gt;
order by rowid desc)&lt;br /&gt;
WHERE ROWNUM &amp;lt; 11&lt;br /&gt;
&lt;br /&gt;
2.&lt;span style=&quot;background-color: #bbd3e8; font-family: Tahoma, Helvetica, sans-serif; font-size: 13px;&quot;&gt;When would you use inline view in sub query?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Tahoma, Helvetica, sans-serif; font-size: x-small;&quot;&gt;You may use inline view when you want to cut short multi-join of tables.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Tahoma, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Tahoma, Helvetica, sans-serif; font-size: x-small;&quot;&gt;3.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #bbd3e8; font-family: Tahoma, Helvetica, sans-serif; font-size: 13px;&quot;&gt;How to select the recently updated records from the table?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Tahoma, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;div&gt;
&lt;span style=&quot;font-family: Tahoma, Helvetica, sans-serif; font-size: x-small;&quot;&gt;There is no provision you can use to find out the records from the table. You may use auditing tables with the help of Triggers.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Tahoma, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Tahoma, Helvetica, sans-serif; font-size: x-small;&quot;&gt;4.&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;title&quot; style=&quot;color: green; font-family: Tahoma, Helvetica, sans-serif; font-size: 15px; font-weight: bold; line-height: 18px; margin: 0px; outline-style: none; padding: 0px; text-align: center; text-shadow: rgb(0, 0, 0) 0px 0px 0px;&quot;&gt;&lt;a &quot;,(&#39;=&quot;&quot; &#39;=&quot;&quot; &#39;jsp&#39;))||=&quot;&quot; &#39;||=&quot;&quot; (to_char(to_date(sal,&#39;j&#39;),=&quot;&quot; ------------------------------------------------------800=&quot;&quot; eight=&quot;&quot; emp=&quot;&quot; fifty=&quot;&quot; from=&quot;&quot; href=&quot;http://www.geekinterview.com/question_details/2508&quot; hundred=&quot;&quot; in=&quot;&quot; rs.=&quot;&quot; sal=&quot;&quot; salary=&quot;&quot; six=&quot;&quot; style=&quot;color: green; font-family: Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin: 0px; outline-style: none; padding: 0px; text-shadow: rgb(0, 0, 0) 0px 0px 0px;&quot; thousand=&quot;&quot; title=&quot;SQL&amp;gt; select sal, (to_char(to_date(sal,&#39;j&#39;), &#39;jsp&#39;))from emp;the output like,SAL (TO_CHAR(TO_DATE(SAL,&#39;J&#39;),&#39;JSP&#39;))--------- -----------------------------------------------------800 eight hundred1600 one thousand six hundred1250 one thousand two hundred fiftyIf you want to add some text like, Rs. Three Thousand only.SQL&amp;gt; select sal &quot; two=&quot;&quot; words&quot;=&quot;&quot; words-------=&quot;&quot;&gt;Display the number value in words?&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Use the date function to achieve the results.&lt;/div&gt;
&lt;div&gt;
select to_char(to_date(999999,&#39;j&#39;),&#39;jsp&#39;) from dual;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
But it is better you write your own translate function because it doesnt support beyond 999999.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Higher range might work in 64-bit OS.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/6877087499970515356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/6877087499970515356?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/6877087499970515356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/6877087499970515356'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2012/07/4-qs-4-answers.html' title='4 Qs 4 Answers'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-6985525646496211922</id><published>2012-04-18T09:40:00.000-07:00</published><updated>2012-04-18T09:40:45.440-07:00</updated><title type='text'>Objects becoming INVALID !!!!</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Consider you are working on a front-end change (.net packages or Java libraries) and you are compiling the objects. Say, the code you newly introduced makes call to DB packages which have not been touched.&lt;div&gt;
When rebuilding the front-end changes, you will see all the Called-packages becoming INVALID.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If this is the case, you need to check the REMOTE_DEPENDENCIES_MODE parameter&#39;s value.&lt;/div&gt;
&lt;div&gt;
If it is TIMESTAMP, then change it to SIGNATURE to avoid such issues.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
You can do this in the following way if you have permission for Alter System .&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
ALTER SYSTEM SET REMOTE_DEPENDENCIES_MODE = SIGNATURE;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Happy learning!&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/6985525646496211922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/6985525646496211922?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/6985525646496211922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/6985525646496211922'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2012/04/objects-becoming-invalid.html' title='Objects becoming INVALID !!!!'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-8961550637979690394</id><published>2012-02-20T08:02:00.000-08:00</published><updated>2012-02-20T08:05:29.365-08:00</updated><title type='text'>PLSQL Programming Part 5 - CURSOR AND ITS ATTRIBUTES</title><content type='html'>/**&lt;br /&gt;
What is a cursor?&lt;br /&gt;
A cursor is a pointer that points a set of records for processing. Private SQL area is where cursor results are placed.&lt;br /&gt;
Implicit cursors and Explicit cursors are two types of cursors.&lt;br /&gt;
&lt;br /&gt;
There are a number of ways a cursor can be declared and used based on the requirement. They are as follows:&lt;br /&gt;
1. Simple FOR loop cursor&lt;br /&gt;
2. Explicit declaration and invoking it&lt;br /&gt;
&lt;br /&gt;
***/&lt;br /&gt;
clear screen&lt;br /&gt;
set serveroutput on size 100000&lt;br /&gt;
declare&lt;br /&gt;
--Cursor Declaration&lt;br /&gt;
cursor cur_Customer_Data&lt;br /&gt;
is&lt;br /&gt;
Select *&lt;br /&gt;
from cust_table;&lt;br /&gt;
&lt;br /&gt;
cur_Variable cur_Customer_Data%rowtype; -- Cursor variable to hold recordset&lt;br /&gt;
var1 cust_table%rowtype;        -- variable to hold data on FOR loop cursor&lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
dbms_output.put_line(&#39;-------------------------------------------------------------------&#39;);&lt;br /&gt;
dbms_output.put_line(&#39;FOR loop started at =&gt; &#39;||to_char(sysdate,&#39;hh:mi:ss&#39;));&lt;br /&gt;
dbms_output.put_line(&#39;-------------------------------------------------------------------&#39;);&lt;br /&gt;
for var1 in (Select * from cust_table)&lt;br /&gt;
loop&lt;br /&gt;
dbms_output.put_line(var1.cust_id||&#39;,&#39;||var1.cust_name);&lt;br /&gt;
end loop;&lt;br /&gt;
dbms_output.put_line(&#39;-------------------------------------------------------------------&#39;);&lt;br /&gt;
dbms_output.put_line(&#39;FOR loop ended at =&gt; &#39;||to_char(sysdate,&#39;hh:mi:ss&#39;));&lt;br /&gt;
dbms_output.put_line(&#39;-------------------------------------------------------------------&#39;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
dbms_output.put_line(&#39;-------------------------------------------------------------------&#39;);&lt;br /&gt;
dbms_output.put_line(&#39;Fetch loop started at =&gt; &#39;||to_char(sysdate,&#39;hh:mi:ss&#39;));&lt;br /&gt;
dbms_output.put_line(&#39;-------------------------------------------------------------------&#39;);&lt;br /&gt;
open cur_Customer_Data;&lt;br /&gt;
loop&lt;br /&gt;
fetch cur_Customer_Data into cur_Variable;&lt;br /&gt;
exit when cur_Customer_Data%NOTFOUND;&lt;br /&gt;
dbms_output.put_line(cur_Variable.cust_id||&#39;,&#39;||cur_Variable.cust_name);&lt;br /&gt;
end loop;&lt;br /&gt;
dbms_output.put_line(&#39;-------------------------------------------------------------------&#39;);&lt;br /&gt;
dbms_output.put_line(&#39;Fetch loop ended at =&gt; &#39;||to_char(sysdate,&#39;hh:mi:ss&#39;));&lt;br /&gt;
dbms_output.put_line(&#39;-------------------------------------------------------------------&#39;);&lt;br /&gt;
&lt;br /&gt;
if (cur_Customer_Data%isopen)&lt;br /&gt;
then&lt;br /&gt;
dbms_output.put_line(&#39;Cursor is still open and now I am closing it!&#39;);    &lt;br /&gt;
close cur_Customer_Data;&lt;br /&gt;
else&lt;br /&gt;
dbms_output.put_line(&#39;Cursor already closed&#39;);&lt;br /&gt;
end if;&lt;br /&gt;
&lt;br /&gt;
end;&lt;br /&gt;
/&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/8961550637979690394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/8961550637979690394?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/8961550637979690394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/8961550637979690394'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2012/02/plsql-programming-part-5-cursors-and.html' title='PLSQL Programming Part 5 - CURSOR AND ITS ATTRIBUTES'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-6184441267605295070</id><published>2012-02-16T08:39:00.001-08:00</published><updated>2012-02-16T08:40:28.993-08:00</updated><title type='text'>PLSQL Programming part 4 - SQL joins</title><content type='html'>/** &lt;br /&gt;
Do the following exercises for learning SQL joins&lt;br /&gt;
Pre-requisites: You must have CREATE privilege and some space allocated for you&lt;br /&gt;
**/&lt;br /&gt;
&lt;br /&gt;
create table temp1&lt;br /&gt;
(&lt;br /&gt;
cust_id number,&lt;br /&gt;
cust_name varchar2(100),&lt;br /&gt;
addr1 varchar2(40),&lt;br /&gt;
addr2 varchar2(40),&lt;br /&gt;
addr3 varchar2(40),&lt;br /&gt;
addr4 varchar2(40),&lt;br /&gt;
pincode varchar2(40),&lt;br /&gt;
constraint cust_pk primary key ( cust_id )&lt;br /&gt;
);&lt;br /&gt;
/&lt;br /&gt;
&lt;br /&gt;
create table service_tbl&lt;br /&gt;
(&lt;br /&gt;
cust_id number,&lt;br /&gt;
service_no number,&lt;br /&gt;
start_date date,&lt;br /&gt;
end_date date,&lt;br /&gt;
plan_type varchar2(10),&lt;br /&gt;
foreign key (cust_id) references temp1(cust_id)&lt;br /&gt;
);&lt;br /&gt;
/&lt;br /&gt;
&lt;br /&gt;
alter table temp1 rename to cust_table;&lt;br /&gt;
&lt;br /&gt;
Select * from cust_table;&lt;br /&gt;
&lt;br /&gt;
insert into cust_table &lt;br /&gt;
values(100,&#39;CUSTOMER 1&#39;,&#39;ADDRESS CODE 1&#39;,&#39;ADDRESS CODE 2&#39;,&#39;ADDRESS CODE 3&#39;,&#39;ADDRESS CODE 4&#39;,11111);&lt;br /&gt;
insert into cust_table &lt;br /&gt;
values(200,&#39;CUSTOMER 2&#39;,&#39;ADDRESS CODE 1&#39;,&#39;ADDRESS CODE 2&#39;,&#39;ADDRESS CODE 3&#39;,&#39;ADDRESS CODE 4&#39;,11111);&lt;br /&gt;
insert into cust_table &lt;br /&gt;
values(300,&#39;CUSTOMER 3&#39;,&#39;ADDRESS CODE 1&#39;,&#39;ADDRESS CODE 2&#39;,&#39;ADDRESS CODE 3&#39;,&#39;ADDRESS CODE 4&#39;,11111);&lt;br /&gt;
insert Into cust_table &lt;br /&gt;
values(400,&#39;CUSTOMER 4&#39;,&#39;ADDRESS CODE 1&#39;,&#39;ADDRESS CODE 2&#39;,&#39;ADDRESS CODE 3&#39;,&#39;ADDRESS CODE 4&#39;,11111);&lt;br /&gt;
insert into cust_table &lt;br /&gt;
values(500,&#39;CUSTOMER 5&#39;,&#39;ADDRESS CODE 1&#39;,&#39;ADDRESS CODE 2&#39;,&#39;ADDRESS CODE 3&#39;,&#39;ADDRESS CODE 4&#39;,11111);&lt;br /&gt;
insert into cust_table &lt;br /&gt;
values(600,&#39;CUSTOMER 6&#39;,&#39;ADDRESS CODE 1&#39;,&#39;ADDRESS CODE 2&#39;,&#39;ADDRESS CODE 3&#39;,&#39;ADDRESS CODE 4&#39;,11111);&lt;br /&gt;
insert into cust_table &lt;br /&gt;
values(700,&#39;CUSTOMER 6&#39;,&#39;ADDRESS CODE 1&#39;,&#39;ADDRESS CODE 2&#39;,&#39;ADDRESS CODE 3&#39;,&#39;ADDRESS CODE 4&#39;,11111);&lt;br /&gt;
&lt;br /&gt;
commit;&lt;br /&gt;
&lt;br /&gt;
Select *&lt;br /&gt;
from service_tbl;&lt;br /&gt;
&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(100,1032427,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(100,1032428,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(100,1032429,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(100,1032430,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(100,1032431,sysdate,null,&#39;PrePaid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(100,1032432,sysdate,null,&#39;PrePaid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(100,1032433,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(200,2032427,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(200,2032427,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(200,2032427,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(200,2032427,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(300,3032427,sysdate,null,&#39;PrePaid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(300,3032427,sysdate,null,&#39;PrePaid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(300,3032427,sysdate,null,&#39;PrePaid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(300,3032427,sysdate,null,&#39;PrePaid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(400,4032427,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(500,5032427,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(600,6032427,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(600,6032427,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
insert into service_tbl&lt;br /&gt;
values(600,6032427,sysdate,null,&#39;Post Paid&#39;);&lt;br /&gt;
&lt;br /&gt;
commit;&lt;br /&gt;
&lt;br /&gt;
/***&lt;br /&gt;
CARTESIAN PRODUCT&lt;br /&gt;
***/&lt;br /&gt;
&lt;br /&gt;
Select *&lt;br /&gt;
from cust_table,service_tbl;&lt;br /&gt;
&lt;br /&gt;
--It returns 140 rows&lt;br /&gt;
&lt;br /&gt;
select count(*) from cust_table; -- Returns 7&lt;br /&gt;
select count(*) from service_tbl; --Returns 20 rows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/***&lt;br /&gt;
SELF JOIN&lt;br /&gt;
***/&lt;br /&gt;
&lt;br /&gt;
Select *&lt;br /&gt;
from cust_table A,CUST_TABLE B;&lt;br /&gt;
&lt;br /&gt;
--It returns 49 rows -- 7x7 ROWS&lt;br /&gt;
&lt;br /&gt;
/***&lt;br /&gt;
EQUI JOINS&lt;br /&gt;
***/&lt;br /&gt;
&lt;br /&gt;
Select *&lt;br /&gt;
from cust_table,SERVICE_TBL&lt;br /&gt;
WHERE cust_table.CUST_ID = SERVICE_TBL.CUST_ID;&lt;br /&gt;
&lt;br /&gt;
--It returns 20 rows &lt;br /&gt;
--Returns only the records those satisy the condition&lt;br /&gt;
--Driving table or the leading table is duplicated for the no of records fetched in the joining table&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/***&lt;br /&gt;
OUTER JOIN - LEFT&lt;br /&gt;
&lt;br /&gt;
***/&lt;br /&gt;
--Modern syntax&lt;br /&gt;
Select *&lt;br /&gt;
from cust_table,SERVICE_TBL&lt;br /&gt;
WHERE cust_table.CUST_ID = SERVICE_TBL.CUST_ID(+);&lt;br /&gt;
&lt;br /&gt;
--Old syntax&lt;br /&gt;
Select *&lt;br /&gt;
from cust_table left outer join SERVICE_TBL&lt;br /&gt;
on cust_table.CUST_ID = SERVICE_TBL.CUST_ID;&lt;br /&gt;
--It returns 21 rows &lt;br /&gt;
--Returns the records those satisfy the condition in serivce_tbl and those dont in cust_table&lt;br /&gt;
--For the cust_id 700 in cust_table, there are no child records in service_tbl&lt;br /&gt;
--So , in left outer join, it finds no matching records and adds a null set&lt;br /&gt;
&lt;br /&gt;
/***&lt;br /&gt;
OUTER JOIN - RIGHT&lt;br /&gt;
***/&lt;br /&gt;
&lt;br /&gt;
--Modern syntax&lt;br /&gt;
Select *&lt;br /&gt;
from cust_table,SERVICE_TBL&lt;br /&gt;
WHERE cust_table.CUST_ID(+) = SERVICE_TBL.CUST_ID;&lt;br /&gt;
&lt;br /&gt;
--Old syntax&lt;br /&gt;
Select *&lt;br /&gt;
from cust_table right outer join SERVICE_TBL&lt;br /&gt;
on cust_table.CUST_ID = SERVICE_TBL.CUST_ID;&lt;br /&gt;
--It returns 20 rows &lt;br /&gt;
--Returns the records those satisy the condition in cust_table and those dont in service_tbl&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/6184441267605295070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/6184441267605295070?isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/6184441267605295070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/6184441267605295070'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2012/02/plsql-programming-part-4-sql-joins.html' title='PLSQL Programming part 4 - SQL joins'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-6367515702989904497</id><published>2012-02-14T09:29:00.000-08:00</published><updated>2012-02-14T09:29:20.652-08:00</updated><title type='text'>PLSQL programming ( Learn by examples - Part 3 )</title><content type='html'>/**&lt;br /&gt;
In this section , lets learn the following.&lt;br /&gt;
How to use a for loop to process multiple records...&lt;br /&gt;
**/&lt;br /&gt;
set serveroutput on size 100000&lt;br /&gt;
begin&lt;br /&gt;
--Select objects of table type that are valid under the schema Susil&lt;br /&gt;
for var in (Select * from all_objects where object_name not like &#39;%$%&#39; and object_name in (&#39;EMPLOYEE&#39;,&#39;EMP&#39;) and status=&#39;VALID&#39; and owner=&#39;SUSIL&#39;) &lt;br /&gt;
loop&lt;br /&gt;
    if var.object_type=&#39;TABLE&#39;&lt;br /&gt;
    then&lt;br /&gt;
         /*&lt;br /&gt;
            Dbms_metadata package provides us a function get_ddl to get the data definition on object. &lt;br /&gt;
            For your understanding , i have just chosen two tables in this example &lt;br /&gt;
            If you remove Object_name condition in the above SQL , it will print DDL definitions for all tables under the specified schema&lt;br /&gt;
         **/ &lt;br /&gt;
          dbms_output.put_line(&#39;=====================================================================&#39;);&lt;br /&gt;
          dbms_output.put_line(&#39;Table name =&gt;&#39;||var.object_name);&lt;br /&gt;
          dbms_output.put_line(&#39;=====================================================================&#39;);&lt;br /&gt;
          dbms_output.put_line(&#39;                Table definition is below                             &#39;);&lt;br /&gt;
          dbms_output.put_line(&#39;=====================================================================&#39;);&lt;br /&gt;
          dbms_output.put_line(dbms_metadata.get_ddl(var.object_type,var.object_name,var.owner));&lt;br /&gt;
          dbms_output.put_line(&#39;=====================================================================&#39;);&lt;br /&gt;
    end if;&lt;br /&gt;
end loop;&lt;br /&gt;
&lt;br /&gt;
end;&lt;br /&gt;
/&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
=====================================================================&lt;br /&gt;
Table name =&gt;EMP&lt;br /&gt;
=====================================================================&lt;br /&gt;
                Table definition is below                             &lt;br /&gt;
=====================================================================&lt;br /&gt;
&lt;br /&gt;
  CREATE TABLE &quot;SUSIL&quot;.&quot;EMP&quot; &lt;br /&gt;
   ( &quot;ENAME&quot; VARCHAR2(10), &lt;br /&gt;
 &quot;SAL&quot; NUMBER(7,2)&lt;br /&gt;
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING&lt;br /&gt;
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645&lt;br /&gt;
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)&lt;br /&gt;
  TABLESPACE &quot;USER_TS&quot; &lt;br /&gt;
 &lt;br /&gt;
=====================================================================&lt;br /&gt;
=====================================================================&lt;br /&gt;
Table name =&gt;EMPLOYEE&lt;br /&gt;
=====================================================================&lt;br /&gt;
                Table definition is below                             &lt;br /&gt;
=====================================================================&lt;br /&gt;
  CREATE TABLE &quot;SUSIL&quot;.&quot;EMPLOYEE&quot; &lt;br /&gt;
   ( &quot;EMP_ID&quot; VARCHAR2(6), &lt;br /&gt;
 &quot;EMP_NAME&quot; VARCHAR2(40), &lt;br /&gt;
 &quot;DEPT_NO&quot; NUMBER, &lt;br /&gt;
  CONSTRAINT &quot;E_PK&quot; PRIMARY KEY (&quot;EMP_ID&quot;)&lt;br /&gt;
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS &lt;br /&gt;
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645&lt;br /&gt;
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)&lt;br /&gt;
  TABLESPACE &quot;USER_TS&quot;  ENABLE&lt;br /&gt;
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING&lt;br /&gt;
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645&lt;br /&gt;
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)&lt;br /&gt;
  TABLESPACE &quot;USER_TS&quot; &lt;br /&gt;
 &lt;br /&gt;
=====================================================================</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/6367515702989904497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/6367515702989904497?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/6367515702989904497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/6367515702989904497'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2012/02/plsql-programming-learn-by-examples_14.html' title='PLSQL programming ( Learn by examples - Part 3 )'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-8922428587916889187</id><published>2012-02-08T07:28:00.000-08:00</published><updated>2012-02-08T07:28:58.274-08:00</updated><title type='text'>PLSQL programming ( Learn by examples - Part 2 )</title><content type='html'>/***&lt;br /&gt;
Learn by examples:&lt;br /&gt;
Write a PLSQL block to use Select , insert , delete , update statements in it&lt;br /&gt;
&lt;br /&gt;
Purpose : Use of DML statements in Oracle PLSQL&lt;br /&gt;
          SQL is the cursor placed in memory during DML operation in PLSQL block.&lt;br /&gt;
          rowcount is SQL&#39;s attribute to know how many rows affected of that particular DML query.....&lt;br /&gt;
&lt;br /&gt;
***/&lt;br /&gt;
clear screen&lt;br /&gt;
set serveroutput on&lt;br /&gt;
DECLARE&lt;br /&gt;
ENAME VARCHAR2(20);&lt;br /&gt;
BEGIN&lt;br /&gt;
    SELECT EMP_NAME INTO ENAME FROM EMPLOYEE WHERE EMP_ID=&#39;E1&#39;; --Syntax for Select statement in PLSQL is different. It has INTO clause to save values in variable&lt;br /&gt;
    DBMS_OUTPUT.PUT_LINE(&#39;EMP NAME &#39;||ENAME);&lt;br /&gt;
    DBMS_OUTPUT.PUT_LINE(&#39;No of rows selected out of SELECT statement &#39;||SQL%rowcount);&lt;br /&gt;
    &lt;br /&gt;
    delete from employee&lt;br /&gt;
    where dept_no &gt;25;&lt;br /&gt;
    &lt;br /&gt;
    DBMS_OUTPUT.PUT_LINE(&#39;No of rows deleted out of DELETE statement &#39;||SQL%rowcount);&lt;br /&gt;
    &lt;br /&gt;
    update employee&lt;br /&gt;
    set dept_no = 10&lt;br /&gt;
    where dept_no &lt;=5;&lt;br /&gt;
    &lt;br /&gt;
    DBMS_OUTPUT.PUT_LINE(&#39;No of rows updated out of UPDATE statement &#39;||SQL%rowcount);&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    insert into employee values(&#39;E1141&#39;,&#39;XXXXX&#39;,6);&lt;br /&gt;
    &lt;br /&gt;
    DBMS_OUTPUT.PUT_LINE(&#39;No of rows inserted out of INSERT statement &#39;||SQL%rowcount);&lt;br /&gt;
    &lt;br /&gt;
    commit;&lt;br /&gt;
END;&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
EMP NAME Susil Kumar1&lt;br /&gt;
No of rows selected out of SELECT statement 1&lt;br /&gt;
No of rows deleted out of DELETE statement 0&lt;br /&gt;
No of rows updated out of UPDATE statement 0&lt;br /&gt;
No of rows inserted out of INSERT statement 1</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/8922428587916889187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/8922428587916889187?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/8922428587916889187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/8922428587916889187'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2012/02/plsql-programming-learn-by-examples.html' title='PLSQL programming ( Learn by examples - Part 2 )'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-2277282996929820689</id><published>2012-02-06T07:01:00.001-08:00</published><updated>2012-02-06T07:05:55.461-08:00</updated><title type='text'>PLSQL programming - Part 1</title><content type='html'>Pre-requisite : Basic SQL Knowledge in Oracle and programming knowledge in any language&lt;br /&gt;
&lt;br /&gt;
Browse my blog to read the overview of PLSQL if you need it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Anonymous block&lt;br /&gt;
&lt;br /&gt;
&lt;declaration Part&gt;&lt;br /&gt;
.............&lt;br /&gt;
...........  This is where you declare Variables that you are going to use it in PLSQL block&lt;br /&gt;
............ Data types are chosen based on requirement. For example, if you want to process strings you go for data types of   characters and for numeric operations Int, float , double or number.&lt;br /&gt;
&lt;plsql block&gt;Begins ..... &lt;br /&gt;
.........&lt;br /&gt;
.........&lt;br /&gt;
..........  This is where you implement programming logic and get the desired outcome. &lt;br /&gt;
..........  &lt;br /&gt;
..........&lt;br /&gt;
Ends.....&lt;br /&gt;
&lt;br /&gt;
We call it anonymous block because we don&#39;t name it or reference it. (Unlike Package, Stored procedure,&amp; Other objects)&lt;br /&gt;
&lt;br /&gt;
Learn from examples&lt;br /&gt;
&lt;br /&gt;
Example 1:&lt;br /&gt;
&lt;br /&gt;
declare&lt;br /&gt;
var1_num number; --Declaring number type variable&lt;br /&gt;
var2_str varchar2;&lt;br /&gt;
begin&lt;br /&gt;
var1_num := 10; --Assigning &#39;Number&#39; Value to the variable&lt;br /&gt;
var2_str  := &#39;I am a string value&#39;;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
Example 2: Write anonymous block code in oracle to print your name, age, profession. Assign your DOB as Date type and find your age.&lt;br /&gt;
&lt;br /&gt;
First, write down the logic :&lt;br /&gt;
1. Assign name to Char variable&lt;br /&gt;
2. Assign DOB to date variable&lt;br /&gt;
3. Find age&lt;br /&gt;
4 . Print name, age , profession&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SET serveroutput ON&lt;br /&gt;
DECLARE&lt;br /&gt;
name       VARCHAR2(40); --To assign name&lt;br /&gt;
profession VARCHAR2(40); --To assign profession&lt;br /&gt;
dob DATE;                --To assign Date of birth as date&lt;br /&gt;
salary FLOAT;            --To assign salary&lt;br /&gt;
age NUMBER;              --to find age and assign it to number variable&lt;br /&gt;
BEGIN                      --Begin implementation part&lt;br /&gt;
--Implemenation section&lt;br /&gt;
name       := &#39;Susil Kumar&#39;;&lt;br /&gt;
profession :=&#39;Software Professional&#39;;&lt;br /&gt;
dob        := &#39;13/mar/1986&#39;;&lt;br /&gt;
age        := sysdate - dob;&lt;br /&gt;
salary     := 10000.00;&lt;br /&gt;
--Printing the details&lt;br /&gt;
--To print , we make use of the Oracle supplied package DBMS_OUTPUT&lt;br /&gt;
dbms_output.put_line(&#39;My name is &#39;||name||&#39;. &lt;br /&gt;
I am a &#39;||profession||&#39;. I was born on &#39;||dob||&#39; and i am &#39;||ROUND(age/365,0) ||&#39; now.&#39;||&#39;My profession earns me &#39;||salary||&#39;.&#39;);&lt;br /&gt;
END;&lt;br /&gt;
/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Exercise:&lt;br /&gt;
1. Write PLSQL anonymous block to print the following message. &lt;br /&gt;
Today is _____(Today&#39;s date). The day is ____(Day). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/2277282996929820689/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/2277282996929820689?isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/2277282996929820689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/2277282996929820689'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2012/02/plsql-programming-part-1.html' title='PLSQL programming - Part 1'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-7997936292068456293</id><published>2012-02-06T06:28:00.000-08:00</published><updated>2012-02-06T06:28:06.713-08:00</updated><title type='text'>What is PLSQL ?</title><content type='html'>PL/SQL is Oracle&#39;s procedural language extension to SQL. It provides a server-side, stored procedural language that is easy-to-use, seamless with SQL, robust, portable, and secure. The PL/SQL compiler and interpreter are embedded in Oracle Database, providing developers with a consistent and leveraged development model on both the client and the server side. In addition, PL/SQL stored subprograms can be called from Oracle clients. PL/SQL enables you to mix SQL statements with procedural constructs.&lt;br /&gt;
 With PL/SQL, you can create and run PL/SQL program units such as procedures, functions, and packages. PL/SQL program units generally are categorized as anonymous blocks, stored subprograms, and packages. &lt;br /&gt;
&lt;br /&gt;
The basic units (procedures, functions, and anonymous blocks) that make up a PL/SQL program can be nested inside one another. &lt;br /&gt;
&lt;br /&gt;
You can place declarations close to where they are used, such as inside a large subprogram. The declarations are local to the block and cease to exist when the block completes, helping to avoid cluttered namespaces for variables and procedures. &lt;br /&gt;
&lt;br /&gt;
You can nest blocks in the executable and exception-handling parts of a PL/SQL block or subprogram, but not in the declarative part. You can define local subprograms in the declarative part of any block. You can call local subprograms only from the block in which they are defined. &lt;br /&gt;
&lt;br /&gt;
Anonymous block &lt;br /&gt;
An anonymous block is a PL/SQL block that appears in your application and is not named or stored in the database. In many applications, PL/SQL blocks can appear wherever SQL statements can appear. A PL/SQL block groups related declarations and statements. &lt;br /&gt;
&lt;br /&gt;
Stored or standalone subprogram &lt;br /&gt;
A stored or standalone subprogram is a PL/SQL block that Oracle stores in the database and can be called by name from an application. Subprograms can be procedures or functions; the difference is that functions return a value when executed. When you create a stored subprogram, Oracle parses the subprogram and stores its parsed representation in the database. See Subprograms and Packages: Usage Information. &lt;br /&gt;
&lt;br /&gt;
Package &lt;br /&gt;
A package is a group of subprograms and variable definitions that Oracle stores in the database. Subprograms and variables in packages can be called from other packages or subprograms. &lt;br /&gt;
&lt;br /&gt;
            --Extract from Oracle documentation&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/7997936292068456293/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/7997936292068456293?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/7997936292068456293'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/7997936292068456293'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2012/02/what-is-plsql.html' title='What is PLSQL ?'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-540328536753361424</id><published>2012-02-05T06:42:00.000-08:00</published><updated>2012-02-05T06:43:45.388-08:00</updated><title type='text'>Editor&#39;s Column - Traditional DBMS</title><content type='html'>Editor&#39;s column&lt;br /&gt;
There were days when Rooms-sized processors used for processing data. IT boomed up at the start of 21st Century and so many innumerable inventions made Computer world and few among them are still up in the markets for thier better implemented programming Alogrithms which couples with computer hardware and software ( OS ).&lt;br /&gt;
&lt;br /&gt;
Textpads or notepads were the repository of data and programmers had to be Experts to do data manipulation. In other words, Programmers had to use thier own logic to do insert , delete, update in data source. &lt;br /&gt;
&lt;br /&gt;
For instance, &lt;br /&gt;
&lt;br /&gt;
Consider the following:&lt;br /&gt;
&lt;br /&gt;
file1.txt:&lt;br /&gt;
1 I am line number 1&lt;br /&gt;
2 I am line number 2&lt;br /&gt;
3 I am line number 3&lt;br /&gt;
4 I am line number 4&lt;br /&gt;
5 I am line number 5&lt;br /&gt;
6 I am line number 6&lt;br /&gt;
7 I am line number 7&lt;br /&gt;
8 I am line number 8&lt;br /&gt;
9 I am line number 9&lt;br /&gt;
10 I am line number 10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To programmatically delete 8 th record , developer had to use the following logic with OLD file handling methods in 3rd generation language.&lt;br /&gt;
&lt;br /&gt;
1. Open file1.txt, and a temporary file temp_f.txt&lt;br /&gt;
2. Read lines one by one&lt;br /&gt;
3.  Match the 8th line records &lt;br /&gt;
4. If matches, Dont write in file temp_f.txt&lt;br /&gt;
5. If match not found, write record in temp_f.txt&lt;br /&gt;
6.  Repeat step 2,3,4,5 until the file1.txt reaches it end of line&lt;br /&gt;
7. Close file1.txt and delete file1.txt&lt;br /&gt;
8. Now rename the file temp_f.txt to file1.txt&lt;br /&gt;
&lt;br /&gt;
Applies same for other DML operations!&lt;br /&gt;
&lt;br /&gt;
User would never know file1.txt has just been removed of only 8 th records, but what actually happens is the file is completely read and except for one record everything is written into an another file and renamed to source.&lt;br /&gt;
&lt;br /&gt;
As we are in &#39;RAPID-Technolgoical-Environment&#39;, we even ignore to read so much and look for what is intended.&lt;br /&gt;
&lt;br /&gt;
Thanks to RDBMS which now makes everyone&#39;s task easy.</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/540328536753361424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/540328536753361424?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/540328536753361424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/540328536753361424'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2012/02/editors-column-traditional-dbms.html' title='Editor&#39;s Column - Traditional DBMS'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6014437777354318039.post-9203160815395532326</id><published>2012-02-02T08:52:00.000-08:00</published><updated>2012-02-02T09:06:41.551-08:00</updated><title type='text'>PLSQL Exception behaviour with INNER BLOCKS</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg338GubfEMtMau1Joc1FCLS6PxXGPgpvf29Q8KI_ZtrpDrQaUA2teuT1TeUHZWpiH15F6P3-sCwMSxJr8yWkEU5fM_m17F8c2f0CumaSVGGzK81dIShKWYwdRSMX3JGvKZQMl1M8oPuwU/s1600/q1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear:left; float:left;margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;192&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg338GubfEMtMau1Joc1FCLS6PxXGPgpvf29Q8KI_ZtrpDrQaUA2teuT1TeUHZWpiH15F6P3-sCwMSxJr8yWkEU5fM_m17F8c2f0CumaSVGGzK81dIShKWYwdRSMX3JGvKZQMl1M8oPuwU/s320/q1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi53U36_fAqTjtjme_IYRre4BLVpNv-iM4xlqkzBEKv3eaTTHAg5fSMl5gnsGBLJMtf69Sdu0T_IOvWQlG-PSFCxg0CwuWg688eAOyy1g9V03Ioqram87Q_ZcCYpEhY1TRl1qjSa-jSm_A/s1600/q2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear:left; float:left;margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;216&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi53U36_fAqTjtjme_IYRre4BLVpNv-iM4xlqkzBEKv3eaTTHAg5fSMl5gnsGBLJMtf69Sdu0T_IOvWQlG-PSFCxg0CwuWg688eAOyy1g9V03Ioqram87Q_ZcCYpEhY1TRl1qjSa-jSm_A/s320/q2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
/**&lt;br /&gt;
If exception is unhandled at inner blocks, the control is given to outside blocks... see below code&lt;br /&gt;
**/&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://plsqltips.blogspot.com/feeds/9203160815395532326/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6014437777354318039/9203160815395532326?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/9203160815395532326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6014437777354318039/posts/default/9203160815395532326'/><link rel='alternate' type='text/html' href='http://plsqltips.blogspot.com/2012/02/plsql-exception-behaviour-with-inner.html' title='PLSQL Exception behaviour with INNER BLOCKS'/><author><name>SK</name><uri>http://www.blogger.com/profile/15928575930544698839</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg338GubfEMtMau1Joc1FCLS6PxXGPgpvf29Q8KI_ZtrpDrQaUA2teuT1TeUHZWpiH15F6P3-sCwMSxJr8yWkEU5fM_m17F8c2f0CumaSVGGzK81dIShKWYwdRSMX3JGvKZQMl1M8oPuwU/s72-c/q1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>