Function to get the rate of a loan
hi;
iam trying to develop a function to return te rate of a loan knowing the original ammount, monthly payment, term.
basically what i need is the same as rate function in excel but i cant find the matematical function to calculate the rate
thanks
orestes
You're in the wrong forum (this one is for issues with the SQL Developer tool). You'll get more answers in the SQL And PL/SQL forum.
Have fun,
K.
Similar Messages
-
Function to get the interest rate
hi;
iam trying to develop a function to return te rate of a loan knowing the original ammount, monthly payment, term.
basically what i need is the same as rate function in excel but i cant find the matematical function to calculate the rate
thanks
orestesI found this formula on http://www.fonerbooks.com/solving.htm
the guy borrowed 100,000 for the mortgage and is making monthly payments of $830.33 for 15 years
looks like to solve for the interest they take the equation
P / M = [ i(1 + i)^n ] / [ (1 + i)^n - 1]
and make a guess at the interest rate and keep incrementing until the two sides match (or are close)
anyway I did in sql starting with and interated .01% interest rate and and incrementing by .01% for
10000 iterations and I ordered by the smallest difference between the two sides of the equation
and came up with 5.75% which I believe is correct
WITH variables AS ( SELECT 100000 M,
830.33 P,
180 n,
LEVEL * .0001 i
FROM DUAL
CONNECT BY LEVEL <= 10000)
SELECT i * 100 || '%' interest_rate,
P / M,
( (i / 12) * POWER ( (1 + (i / 12)), n))
/ (POWER ( (1 + (i / 12)), n) - 1)
FROM variables
ORDER BY ABS (
(P / M)
- ( ( (i / 12) * POWER ( (1 + (i / 12)), n))
/ (POWER ( (1 + (i / 12)), n) - 1)))
INTEREST_RATE P/M ((I/12)*POWER((1+(I/12)),N))/(POWER((1+(I/12)),N)-1)
5.75% 0.0083033 0.00830410087019666
5.74% 0.0083033 0.00829874710327995
5.76% 0.0083033 0.00830945655888689
5.73% 0.0083033 0.00829339525864719
5.77% 0.0083033 0.00831481416883952
5.72% 0.0083033 0.00828804533680813
5.78% 0.0083033 0.00832017369954276
5.71% 0.0083033 0.00828269733827184
5.79% 0.0083033 0.00832553515048413you could probably make this better so it doesn't have to do all the iterations if you use a recursive with or the model clause
and stop when the difference between the two sides of the equation is less then some number.
Edited by: pollywog on Feb 18, 2011 3:11 PM -
Is there a function to get the IP of this remote system
Hello EveryBody
Currently I have an application that runs on our network. When someone logs on to the network it checks there system and gets the pc name. I would like to also get the IP address of that system. As well I may later like to ping that computer.
1) Is there a function to get the IP of this remote system?
2) IS the a function to ping a remote system and receive back the response?
Thanks a lot.
RHello EveryBody
Currently I have an application that runs on our
network. When someone logs on to the network it
checks there system and gets the pc name. I would
like to also get the IP address of that system. As
well I may later like to ping that computer.
1) Is there a function to get the IP of this remote system?
2) IS the a function to ping a remote system and
receive back the response?Is this lan only?
Because if wan or internet then the remote computer would have to have an address that is reachable from your computer. For the internet this would mean it would have to be public. And for a wan the IP would have to be unique across the wan. -
Use SQL function to get the original order number using the invoice number
Hi All,
wondering is someone can help me with this challenge I am having? Often I need to return the original order numbers that created the resulting invoce. This is a relatively simple seriese of joins in a query but I am wanting to simplify it using a SQL function that can be referenced each time easily from with in the SELECT statement. the code i currently have is:
Use SQL function to get the original order number using the invoice number
CREATE FUNCTION dbo.fnOrdersThatMakeInvoice(@InvNum int)
RETURNS nvarchar(200)
AS
BEGIN
DECLARE @OrderList nvarchar(200)
SET @OrderList = ''
SELECT @OrderList = @OrderList + (cast(T6.DocNum AS nvarchar(10)) + ' ')
FROM OINV AS T1 INNER JOIN
INV1 AS T2 ON T1.DocEntry = T2.DocEntry INNER JOIN
DLN1 AS T4 ON T2.BaseEntry = T4.DocEntry AND T2.BaseLine = T4.LineNum INNER JOIN
RDR1 AS T5 ON T4.BaseEntry = T5.DocEntry AND T4.BaseLine = T5.LineNum INNER JOIN
ORDR AS T6 ON T5.DocEntry = T6.DocEntry
WHERE T1.DocNum = @InvNum
RETURN @OrderList
END
it is run by the following query:
Select T1.DocNum, dbo.fnOrdersThatMakeInvoice(T1.DocNum)
From OINV T1
Where T1.DocNum = 'your invoice number here'
The issue is that this returns the order number for all of the lines in the invoice. Only want to see the summary of the order numbers. ie if 3 orders were used to make a 20 line inovice I only want to see the 3 order numbers retuned in the field.
If this was a simple reporting SELECT query I would use SELECT DISTINCT. But I can't do that.
Any ideas?
Thanks,
MikeThanks Gordon,
I am trying to get away from the massive table access list everytime I write a query where I need to access the original order number of the invoice. However, I have managed to solve my own problem with a GROUP BY statement!
Others may be interested so, the code is this:
CREATE FUNCTION dbo.fnOrdersThatMakeInvoice(@InvNum int)
RETURNS nvarchar(200)
AS
BEGIN
DECLARE @OrderList nvarchar(200)
SET @OrderList = ''
SELECT @OrderList = @OrderList + (cast(T6.DocNum AS nvarchar(10)) + ' ')
FROM OINV AS T1 INNER JOIN
INV1 AS T2 ON T1.DocEntry = T2.DocEntry INNER JOIN
DLN1 AS T4 ON T2.BaseEntry = T4.DocEntry AND T2.BaseLine = T4.LineNum INNER JOIN
RDR1 AS T5 ON T4.BaseEntry = T5.DocEntry AND T4.BaseLine = T5.LineNum INNER JOIN
ORDR AS T6 ON T5.DocEntry = T6.DocEntry
WHERE T1.DocNum = @InvNum
GROUP BY T6.DocNum
RETURN @OrderList
END
and to call it use this:
Select T1.DocNum, dbo.fnOrdersThatMakeInvoice(T1.DocNum)
From OINV T1
Where T1.DocNum = 'your invoice number' -
Function to get the last day of the current month
Hi friends
Now I need to know a function to get the last day of a month. I had between my notes that function but I do not find it and I think you can give the answer faster.
Thanks
Joel Pérez
DBA OracleI know emoticons are a bit naff but in the absence of a UBB markup to indicate humourous intent they do serve to indicate a joke. This is useful in a purely verbal domain like these forums, especially given that many participants don't have English as their first lanaguage and so often miss the wordplay.
Cheers, APC -
Is there any function module getting the cpu type?
Is there any function module getting the cpu type?
I guess the database server...
I would like to get the SAP system cpu type as done in transaction st06 under system information.
Thanks. -
I have the original AIR recently it has really slowed down. Every function usually gets the pinwheel. It is up to date and has 10g of free disk space. Any suggestions as to the cause?
Often a failed disk or power supply. See:
https://encrypted.google.com/search?q=%22time+capsule%22+%22orange+light%22&as_q dr=all&newwindow=1&num=100 -
How to create a function to get the 16th of the current month and the 15th of the next month
I need to create a function to get the 16th of the current month and 15th of the next month to use it in the fast formula to calculate the sick leave.
Example:
If an employee takes a sick leave from 16 feb 2015 to 17 feb 2015 , I want it to affect march's payroll not February.
Please help and thanks in advance.Below statement gives you the result. Use the concept and write your PL/SQL function.
select TO_DATE('16-'||TO_CHAR(SYSDATE, 'MON-RRRR')), TO_DATE('15-'||TO_CHAR(add_months(SYSDATE, 1), 'MON-RRRR')) from dual;
Or you can use same construct directly in the fast formula by changing syntax accordingly.
Regards,
Peddi. -
Is there any function to get the name of the days?
Hi,
I'm using oracle 10.2.0.1.0
Is there any function to get the days of the week?
like i need to get sunday,monday,tuesday.....saturday.
I know i can use union and select the name from dual one by one.
But just want to know whether there is any other way.
I need to show the 7 days in a poplist in my form, thats the requirement
ThanksDavid_Aldridge wrote:
BluShadow wrote:
Note: you may want to include "fm" in the format mask, otherwise the name of the day is padded with spaces:
SQL> ed
Wrote file afiedt.buf
1 select replace(to_char(dt,'Day'),' ','*') as fmt1
2 ,length(to_char(dt,'Day')) as length_fmt1
3 ,replace(to_char(dt,'fmDay'),' ','*') as fmt2
4 ,length(to_char(dt,'fmDay')) as length_fmt2
5 from (select TRUNC(SYSDATE ,'DAY')+Level-1 dt
6 from dual
7 connect by Level<8
8* )
SQL> /
FMT1 LENGTH_FMT1 FMT2 LENGTH_FMT2
Monday*** 9 Monday 6
Tuesday** 9 Tuesday 7
Wednesday 9 Wednesday 9
Thursday* 9 Thursday 8
Friday*** 9 Friday 6
Saturday* 9 Saturday 8
Sunday*** 9 Sunday 6
7 rows selected.
SQL>
I think you should use a pl/sql function for this.
Nah ... just joking.
I'd be tempted to just use a union all statement to return the seven literals. People will look at it and know exactly what it does.Yeah, agreed, I was just demonstrating that the format mask of a to_char(..., 'Day') pads with spaces, which seems to have been missed in the above answers. ;) -
This past Thursday, a Webinar was conducted by Promax which involved speeches and information by two Adobe executives, Kurt Snyder and Trip Goteli.
One of the discussions was about Adobe's rates for CC, and, in answer to people who objected to the fact that CC could be re-priced at any time, (I BELIEVE) Kurt Snyder said that Adobe was going to offer a rate of $39.95 for renewals to CC and a two-year guarantee against rate increases above that level.
Unfortunately, they have not yet posted the Webinar so I can go back and listen, and confirm EXACTLY who was speaking.
I spoke to Promax and they indicated that they can offer a similar rate to that (I then note that several Adobe resellers also offer the rate, $480 per year, but there's no 2-year guarantee noted; also you have to pay the year upfront).
I'm hoping to attract the attention of Adobe people in a position to determine where this rate came from, and how it's possible, if it's possible, to get it honored.
Thanks for any help with this.
JayIt's possible...but I think I listen better than that! Also, note that Adobe resellers are able to offer a similar rate to renewing individuals...but through them one must purchase the full year at once, as opposed to monthly payments.
The Teams offer seems to be more open-ended than the Individual promotion that I had the advantage of from August 2012 and that just expired for me. The wording is very subtle. The (still available to new CC converts) first year says: Promotional pricing for existing Adobe Creative Suite® customers applies to the first year of membership. (Underline emphasis added) The team offer says: Purchase by August 31, 2013 and lock in this special price for up to two years. The main difference is that it doesn't absolutely indicate that it's for first-time customers; all that's required is ownership of CS3 or later serial number.
Beverly, if you're reading this answer (or if another Adobe staff member happens across this) could you reach out to Kurt Snyder by internal communication and ask him directly what he was talking about? I can't do that as a customer, but I'm betting that as staff you can. It would be most helpful if I could get access to the rebroadcast webinar but so far it hasn't been offered on ProMax's site.
It does seem like a reasonable offer...and would somewhat quiet people's concerns, including MINE, about the future of Adobe's CC rates. Again, the two-year lockin would be more important to me than the $10 per month savings. -
Using analytic function to get the right output.
Dear all;
I have the following sample date below
create table temp_one
id number(30),
placeid varchar2(400),
issuedate date,
person varchar2(400),
failures number(30),
primary key(id)
insert into temp_one values (1, 'NY', to_date('03/04/2011', 'MM/DD/YYYY'), 'John', 3);
insert into temp_one values (2, 'NY', to_date('03/03/2011', 'MM/DD/YYYY'), 'Adam', 7);
insert into temp_one values (3, 'Mexico', to_date('03/04/2011', 'MM/DD/YYYY'), 'Wendy', 3);
insert into temp_one values (4, 'Mexico', to_date('03/14/2011', 'MM/DD/YYYY'), 'Gerry', 3);
insert into temp_one values (5, 'Mexico', to_date('03/15/2011', 'MM/DD/YYYY'), 'Zick', 9);
insert into temp_one values (6, 'London', to_date('03/16/2011', 'MM/DD/YYYY'), 'Mike', 8);this is output I desire
placeid issueperiod failures
NY 02/28/2011 - 03/06/2011 10
Mexico 02/28/2011 - 03/06/2011 3
Mexico 03/14/2011 - 03/20/2011 12
London 03/14/2011 - 03/20/2011 8All help is appreciated. I will post my query as soon as I am able to think of a good logic for this...hI,
user13328581 wrote:
... Kindly note, I am still learning how to use analytic functions.That doesn't matter; analytic functions won't help in this problem. The aggregate SUM function is all you need.
But what do you need to GROUP BY? What is each row of the result set going to represent? A placeid? Yes, each row will represent only one placedid, but it's going to be divided further. You want a separate row of output for every placeid and week, so you'll want to GROUP BY placeid and week. You don't want to GROUP BY the raw issuedate; that would put March 3 and March 4 into separate groups. And you don't want to GROUP BY failures; that would mean a row with 3 failures could never be in the same group as a row with 9 failures.
This gets the output you posted from the sample data you posted:
SELECT placeid
, TO_CHAR ( TRUNC (issuedate, 'IW')
, 'MM/DD/YYYY'
) || ' - '|| TO_CHAR ( TRUNC (issuedate, 'IW') + 6
, 'MM/DD/YYY'
) AS issueperiod
, SUM (failures) AS sumfailures
FROM temp_one
GROUP BY placeid
, TRUNC (issuedate, 'IW')
;You could use a sub-query to compute TRUNC (issuedate, 'IW') once. The code would be about as complicated, efficiency probably won't improve noticeably, and the the results would be the same. -
Function to get the path using a parent-child relationship
Hello,
I have a table which uses parent-child relationship to store the options available. I need a function to give me the full path given the id of a particular option.
I have two different functions. One of them uses the Oracle built in function and the other uses simple queries with a loop.The code of the functions are given below.
Now, the problem is with their "performance". The difference in their performance is significant. The function using the Oracle function takes more than 2 hours to run a query whereas the other function takes less than 2 minutes.
I am having trouble trusting the other function. No matter how many tests I perform on the output of both the functions, it always comes out to be the same.
Any thoughts to help me understand this ??
Function 1
=====================
FUNCTION Gettree (opt_id IN NUMBER,i_app_id IN NUMBER)
RETURN VARCHAR2
IS
path VARCHAR2(32767);
application_no NUMBER;
BEGIN
SELECT ABC.APP_OPT_ID INTO application_no FROM ABC
WHERE ABC.APP_ID = i_app_id AND ABC.PARENT_ID IS NULL;
SELECT LPAD(' ', 2*LEVEL-1)||SYS_CONNECT_BY_PATH(app_opt_name, '=>') "Path" INTO path
FROM ABC
WHERE app_opt_id = opt_id
START WITH parent_id =application_no
CONNECT BY PRIOR app_opt_id =parent_id;
path := SUBSTR(path,INSTR(path,'>')+1,LENGTH(path));
RETURN path;
END Gettree ;
Function 2
======================
FUNCTION GetOptPath(opt_id NUMBER,app_id NUMBER)
RETURN VARCHAR2
IS
string VARCHAR2(900);
opt VARCHAR2(100);
pid NUMBER(38);
BEGIN
SELECT ABC.parent_id,ABC.app_opt_name INTO pid,string FROM ABC WHERE ABC.app_opt_id = opt_id;
IF pid IS NULL
THEN
RETURN 'root';
ELSIF pid IS NOT NULL
THEN
LOOP
SELECT ABC.app_opt_name,ABC.parent_id INTO opt, pid FROM ABC WHERE ABC.app_opt_id = pid;
EXIT WHEN pid IS NULL;
string := opt || '=>'|| string;
END LOOP;
RETURN string;
END IF;
END;Hi,
user8653480 wrote:
Hello Frank,
The parameters taken by gettree & getoptpath are app_opt_id and app_id and both the functions return only one string i.e. the path of that particular option (app_opt_id) starting from its root and not all the descendants of that option/root node of that option.
So, does that mean that gettree first fetches all the descendants of the root node of the given option and then returns the required one ??Yes. It's a little like the situation where you need to meet with your co-worker Amy, so you send an e-mail to everyone in the department telling them to come to your office, and then, when they arrive, tell everyone except Amy that they can leave.
>
And if that is the case, then won't it be better to use the bottom-up approach to fetch the required path just for that particular option ?? 'coz my requirement is that only.. given an option_id get the full path starting from the root.Exactly!
I have used explain plan also for both the functions.. but since I did not know how to anlayze the output from plan_table so I just compared the value in the fields and they were exactly the same for both the queries.If you'd like help analyzing the plans, post them, as Centinul said.
I am attaching a sample data with the outputs of both the functions for the reference.
(tried attaching the file but could not find the option, so pasting the data here)
App_opt_ID App_ID Parent_ID App_opt_name "gettree(app_opt_id,app_id)" "getoptpath(app_opt_id,app_id)"
1 1 NULL application NULL root
2 1 1 module1 module1 module1
3 1 1 module2 module2 module2
4 1 2 submod1 module1=>submod1 module1=>submod1
5 1 3 submod1 module2=>submod1 module2=>submod1
6 1 5 opt1 module2=>submod1=>opt1 module2=>submod1=>opt1
7 2 NULL app2 NULL root
8 2 7 scr1 scr1 scr1
9 2 8 opt1 scr1=>opt1 scr1=>opt1
10 2 7 scr2 scr2 scr2Please help.The best solution is to do a bottom-up query, and write a function like reverse_path (described in my first message) to manipulate the string returned by SYS_CONNECT_BY_PATH. You seem to have all the PL/SQL skills needed for this.
Another approach is a revised form of gettree, like I posted earlier. Does it do what you want or not?
If you'd help, then post a little sample data in a form people can actually use, such as CREATE TABLE and INSERT statements. Post a few sets of parameters, and the results you need from each set, given the sample data posted. -
Function to get the standard sales price
Dear all,
is there a bapi/function I can call to get the standard sales price of an article?
Kind regards
RomanHi~ Roman
There is a fuction for it.
CALL FUNCTION 'PRICING'
EXPORTING
COMM_HEAD_I = TKOMK
COMM_ITEM_I = TKOMP
CALCULATION_TYPE = PREISFINDUNGSART
IMPORTING
COMM_HEAD_E = TKOMK
COMM_ITEM_E = TKOMP
TABLES
TKOMV = XKOMV
SVBAP = UVBAP.
this fuction is standard function. you can find it when you debug T-code 'VA01'.
it returns like this.
table tkomv
100 000010 011 01 V <b>ZU01</b> 2005.10.16 C 10.00 11.80 KRW 1.00000 1 EA 1 1 X A 30 0021410014 01
100 000010 100 01 V <b>NETW</b> 2005.10.16 G 10.00 0.00 KRW 1.00000 1 EA 0 0 L A 00 00
100 000010 915 01 V <b>MWST</b> 2005.10.16 A 11.80 100.00 0 0 0 D A X 10 0000006903 01
100 000010 940 01 V <b>VPRS</b> 2005.10.16 C 10.00 9,900.00 KRW 1.00000 1,000 EA 1 1 G X A 00 00
as you can see condition type zu01, netw, mwst, vprs has it's own prices.
Try to debug it.
<b>With program : SAPFV45P
include : FV45PF0P_PREISFINDUNG
fuction : PRICING</b>
and look at parameters.
I wish I could help you.
good luck
Regards
Kyung Woo. -
Function to get the employee number from the username
Hi,
Does anyone know the standard function in CRM to get the employee number (related to the user) giving the username?
Thanks,
TPTHello TPT,
BP_CENTRALPERSON_GET is the FM you need.
Provide the username and you'll get the person_id (of the organizational mgmt), business partner guid and the employee ID.
Hope this helps,
Regards,
Joost -
Function to get the availability of a material by Valuation area
Hi, I need a Function ABAP to get the availability of a material by Valuation area, the bapi BAPI_MATERIAL_AVAILABILITY shows no the availability of a material by Valuation area
Hi, I need to get the availability of a material by Valuation area BEFORE save a order sales.
The configuration of MM is by Valuation area. In te tables MBEW and EBEW don't appears the avaibality, appears the stock and
the avaibality and the stock dont' is the same.
Example
MANDT MATNR BWKEY BWTAR
200 000000000002000060 5000
200 000000000002000060 5000 PRODUCIDO
200 000000000002000060 5000 REVENTA
The sales order STANDAR verify the availability by Valuation area, I DONT UNDERSTAND "a valuation area is not relevant for availability check ".
Maybe you are looking for
-
COST GL account when goods issue - enhancement or user exist
Hello SAP exports, There is a requirement from F&A department for different COGS GL account based on Customer Account Assignment Group value when goods issues (GI) (goods movement). Customer Account Assignment Group field name is KNVV-KTGRD. The s
-
How to use jcifs to access SMB share via webdynpro app ?
Hello All, I am trying to access a protected intranet share via my webdynpro application. I have uses jcifs api to access the jcifs functions. However, I am stuck with running the application on webAS as it gives a runtime exception java.lang.NoClas
-
Material list not showing after saving the sales document
Hi any body can give the answer for this question : AFTER SAVING THE SALES ORDER MATERIAL LIST IS NOT SHOWING . Thanks in advance
-
Deinterlacing QT files converted to H.264
I recently tried converting a DV file to H.264 to save on space, however, the video seems to be 'interlaced'--i.e. lines of the video seem to be slightly skewed from each other, namely on the moving image part of the video. Am I missing a setting? (I
-
Workbench Request for changing the Analysis Authorizations Switch in SPRO
Hi Gurus, While changing the Analysis Authorizations Switch in DEV(SPRO), its asking to create a work bench request. so it means after creating a work bench request should we transport that particular work bench request to QA. Please help with some s