Hi,
i want 2 and 3 rd max salary in a table .i want a single query.
please help..
Arun
Apr 23 '07
70 5815
A function called from SQL statements must obey certain rules meant to control side effects.
To check for violations of the rules, you can use the pragma RESTRICT_REFERENCES.
The pragma asserts that a function does not read or write database tables or package variables.
Try this sample code---try on scott schema -
create or replace procedure insdept(num number)
-
is
-
begin
-
insert into dept(deptno) values (num);
-
commit;
-
exception
-
when dup_val_on_index then
-
raise_application_error(-20001,'duplicate entry...!');
-
end;
-
-
-
Hope that helps you
To successfully execute the code and raise the exception in the previous example
1. DEPTNO field in DEPT table should be an UNIQUE/PRIMARY KEY field.
2.User trying to insert deplicate value which already exists in the table.
Hey arun... There r a lot of oracle apps... for example financials, CRM, SCM etc... U need to have some basic knowledge about banking industry if u r planning to study financials... its better u goto oracle's website and see all the apps and their desc... so tht u may get some idea....
http://www.oracle.com/applications/home.html
Execute immediate is used to call SQL from within PL/SQL.
Where the main purpose is to dynamically execute some SQL at run-time
But cursor may or may not be opened or closed, must be declared at design time only.
Hey... seeing ur sample code there is error for sure... u cant have a DDL(create,update,truncate etc) statement inside a proc... u need to use dynamic sql(exec immediate)... if there r more errors use SHOW ERR in sqlplus environment to see all of them,....
Good suggestion
But dear Arun
its like u r asking which girl to marry without having any knowledge of gals or marriage.
Its always better totakeothers advice.
But Don't follow others blindly.
At times use your own brain also.
hey arun... there r a lot of ways to tune ur SQL query...
for example
1. u can use indexes,
2. check whether all the system parameters r set properly,
3. u can run ur query in parallel,
4. u can cache some tables so that fetching of data from tht table becomes very
fast
5. reduce the number of joins etc etc
the most important feature in oracle is... there is a package called DBMS_SQLTUNE... using this package u can give ur sql query to oracle and it will give u suggestions on how to tune the same...
Dear friends,
Thanks a lot..
Arun.
Dear debas,
i wrote a program :This is correct or not . i execute this pgm got some errors .
please rectify...
code:
type c_alltype is refcursor return emp%rowtype;
create or replace procedure arun( c in number,
c1 inout c_alltype)
is
var varchar2(30);
begin
var:=select name,number,dept from emp where deptno'=c1;
execute immediate var;
open c1 for var;
commit;
end;
/
var kumar refcursor;
execute arun(23,:kumar);
print kumar;
o/p:
var:=select name,number,dept from emp where deptno'=c1;
substitute
var:='select name,number,dept from emp where deptno'=c;
SELECT name,salary
FROM (SELECT name,
salary,
rank() over (order by salary desc) rank
FROM employee)
WHERE rank in (2,3);
Dear debas,
I have an doubt .Is ths possible ref cursor inside execute immediate.
i occured an error:
CREATE OR REPLACE PROCEDURE GetEmployeeDtl (p_deptno IN
emp.deptno%TYPE,
p_emp OUT SYS_REFCURSOR) AS
v_var varchar2(4000);
BEGIN
v_var:='OPEN p_emp FOR';
v_var:= ' SELECT ename,';
v_var:= v_var || ' empno,';
v_var:= v_var || ' deptno';
v_var:= v_var || ' FROM emp';
v_var:= v_var || ' WHERE deptno = ' ||p_deptno;
v_var:= v_var || ' ORDER BY ename';
execute immediate v_var ;
END GetEmployeeDtl;
/
Procedure created.
It geting compiled sucessfully.
When I am executing it gets executed too, but when printing cursor value its giving error as:
SQL> var x refcursor;
SQL> exec GetEmployeeDtl (20,:x);
PL/SQL procedure successfully completed.
SQL> print x;
ERROR:
ORA-24338: statement handle not executed
SP2-0625: Error printing variable "x"
pls rectify . what's error ..
Arun..
Since your procedure contains an OUT parameter ,it can't be executed at SQL> prompt.
Call the procedure from within an Anonymous block.
It will work .
Can't understand debas,
pls update my error ( correct coding..)
Arun..
Hi,
First and foremost is statistics for tables and indexes should be gathered using dbms_stats. So, please try to understand what is this pkg. how best we can manipulate its parameters and its outcome. once you masted this pks, you are half way thru.
Thanks
VK
All the theoretical questions posted by kiss07 have now been merged into this thread.
For more information on the topics discussed here, you can check the User guide and reference
Dear Debas,
Almost my posting all are improving...
oracle version:9i
what is difference between for loop and forall loop in plsql.
any relationship from Bulk insert and forall .please explain clear..
Expecting Replies..
Arunkumar..
Dear Friends,
Now i atttend Oracle interviews.I want to learn queries in left outer join
and right outer joins ,full outer joins in oracle 9i.Any body Help to me..any notes or send any links ..please help..
Expecting Your Replies..
Arun..
Dear friends,
In oracle version 9i.What is the use of Bind variables and Host variables?
expecting ypur replies..
Arun..
I have again merged your basic questions into this thread. As you were warned the experts are here to help but not to supply definitions and examples for every term you come accross in the textbook.
As you have ignored repeated warnings about cluttering up the forum with these kind of posts your account will now be banned for a period of 1 week.
After this period if this behavior continues your account will be permanently banned.
ADMIN
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Materialised |
last post by:
I have been given the task, of developing a program to sit next to a cgi
based c program (I know this is offtopic but my question does only refer...
|
by: softwareengineer2006 |
last post by:
All Interview Questions And Answers
10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP)
I have listed over 10000 interview...
|
by: connectrajesh |
last post by:
INTERVIEWINFO.NET
http://www.interviewinfo.net
FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES
NO ADVERTISEMENT
|
by: freepdfforjobs |
last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions
http://www.questpond.com/SampleInterviewQuestionBook.zip
Download the...
|
by: Drew |
last post by:
I posted this to the asp.db group, but it doesn't look like there is much
activity on there, also I noticed that there are a bunch of posts on here...
|
by: sqlservernewbie |
last post by:
Hi Everyone,
Here is a theoretical, and definition question for you.
In databases, we have:
Relation
|
by: Krypto |
last post by:
Hi,
I have used Python for a couple of projects last year and I found it
extremely useful. I could write two middle size projects in 2-3 months...
|
by: Joseph Ferris |
last post by:
Good afternoon,
I understand the basic theories of capacity planning as it relates to
profiling an existing web site, such as in the examples...
|
by: ramu |
last post by:
C# Interview Questions and Answers8
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html
C# Interview Questions...
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: tammygombez |
last post by:
Hey everyone!
I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
| |