Advertisement

05.11.2008 at 09:54PM PDT, ID: 23393684
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

pl_sql functiion questions

Asked by sam15 in PL / SQL, Oracle 9.x

Tags: , , ,

I have a function to process numbers in Table X and return a decimal between 0 and 1.

FUNCTION CALC_FACTOR
  ( p_company    IN    VARCHAR2,
    p_media      IN    VARCHAR2,
    p_order_Date    IN    DATE )
 
RETURN  NUMBER
IS

FR  NUMBER(5,3);

BEGIN

FR = (A-B-C) / (E-F-G)

END;

1.  I want FR to return the result if it falls between 0 and 1.

If FR is negative I want to set FR = 1.
If (E-F-G) is 0 (divisor is 0) I want to set FR =1.

For negative number i do this
IF (FR < 0)  THEN
  FR = 0;
END IF:

For divisor of 0 i raise an exception
EXCEPTION
WHEN ZERO DIVIDE
  FR := 1;
 
is this correct and efficient?

2. How can i get the function to return 0.123 instead of .123.

3. Should "p_order_date" parameter be same as table column type or you assign it to VARCHAR2 and convert it to DATE.


4.
procedure P1
begin
 For x in (select * from orders)
LOOP
UPDATE  orders
  SET order_qty = MAX(FLOOR(order_qty*FR(x.company,x.media,v_order_Date),1)
END LOOP;
end;

I am getting an error on the MAX

                                *
ERROR at line 1:
ORA-00934: group function is not allowed here

Is there a way around this?


5. The FR function does a select on same table  "orders" to determine some factor. I get this error:

when i have

Procedure P1
begin
update orders
   set order_qty=order_Qty*FR(x.company,x.media,v_order_date)
end
   
Error -4091: ORA-04091: table ORDERS is mutating, trigger/function
may not see it

If i do this it works.


procedure P1
begin
SELECT FR(x.comany,x.media,v_order_Date) into V_FR from dual;
Upate orders
   set order_Qty = order_qty*v_fr;
end;  
   
any idea why.


My procedure P1 which calls the function does select records from same table.
what it does is that it select a group of records by company,media and then call the function which also does compute the factor and then P1 updates the QTY of the records by the factor.

Start Free Trial
[+][-]05.12.2008 at 02:08AM PDT, ID: 21545435

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 09:02AM PDT, ID: 21548112

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 01:59AM PDT, ID: 21553238

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 06:58AM PDT, ID: 21555053

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 08:16AM PDT, ID: 21555886

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 01:56PM PDT, ID: 21559210

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 01:40AM PDT, ID: 21562127

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 07:43AM PDT, ID: 21564742

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 08:25AM PDT, ID: 21565241

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PL / SQL, Oracle 9.x
Tags: oracle, pl/sql, 9i, pl/sql
Sign Up Now!
Solution Provided By: Arne78
Participating Experts: 1
Solution Grade: B
 
 
[+][-]05.15.2008 at 09:46AM PDT, ID: 21575656

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 11:50AM PDT, ID: 21576858

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628