Help in FOr cursor -
hi all,
The follwoing is my req - Below the written proc - can anyone check it is correct .
1. Write a procedure to compute the following using FOR cursor. Procedure should take 3 parameters. Empno - IN parameter, Empno IN parameter and this can be a default parameter. The OUT parameter should return the total cost to the company.
DA = 15% of sal
HRA = 20% of sal
TA = 8% of sal
Special Allowance will be decided based on the service in the company
< 1 year Nil
1 year and < 2 years 10% of salSrividhya Maha... >2 years and < 4 years 15% of sal
5 years 20% of salcreate or replace procedure testing(p_empno in number default 10,v_cost out number)
as
v_salary number;
v_months number;
cursor mycur is
SELECT salary from emp where empno = p_empno;
begin
for emp_rec in mycur
LOOP
SELECT round(months_between(sysdate,hire_date))into v_months from emp
WHERE empno= p_empno;
IF v_months < 12 then
v_salary := salary *12;
elsif
v_months >12 and v_months <24
v_salary := salary *12;
dbms_output.put_line('employee salary'||15/100*salary+20/100*salary+
8/100*salary +v_salary);
end if;
end loop;
end;
[\pre]
cheers
1) consider using FUNCTION to return the cost result, rather than an out parameter; that would allow you to call it in SQL (for example in an UPDATE)
2) Your requirement says THREE parameters - but one of them is EMPNO (twice)
3) Why allow default of EMPNO to 10?
4) You have used ROUND - that means 11.6 months is treated as 1 year. You should use FLOOR instead (or jus compare real numbers)
5) Your requriement leaves out 4-5 years service entirely - was that intentional?
6) The whole section is incorrect:
- refer to cursor variables using the record name, eg:
v_salary := emp_rec.salary * 12;
- You have assigned to local variable v_salary, but not to OUT variable v_cost.
- your DBMS_OUTPUT.PUT_LINE gives you salary * (0.15+0.2+0.08) = 0.43*salary - why?
7) You could put the whole thing into a single piece of SQL
SELECT case
when months_between(sysdate,hire_date) < 12.0 then null
when months_between(sysdate,hire_date) < 24.0 then 0.10
when months_between(sysdate,hire_date) < 48.0 then 0.15
when months_between(sysdate,hire_date) >= 60.0 then 0.20
else null
end * salary "Allowance"
from emp
where {your where clause}
/(multiply by 12 if salary is monthly and you need annual allowance).
HTH
Regards Nigel
Similar Messages
-
Help Text for Field Name.....
Hi Experts,
In ALV Report there is Feild names like Order No., Qty, etc.
When the user moves the cursor to the Feild Name i.e. Qty, it should show help text "This Qty is for A-B...".
How to bring help text for Feild name when the cursor move to feild name ?
Pl. guide.
YusufHi Shiva,
There is no field TOLLTIP in SLIS_FIELDCAT_ALV.
My sintex is :
w_fcat-col_pos = 9.
w_fcat-fieldname = 'FACTOR'.
w_fcat-seltext_l = 'Stock Value (55 %)'.
w_fcat-outputlen = 18.
w_fcat-do_sum = 'X'.
APPEND w_fcat.
CLEAR w_fcat.
Is there any other way becaz there is no field like tooltip?
Yusuf -
How to display help text for Region in a page having more than one region
Hi all,
I want to display help text for each region in my page. I have 5 regions in my page.
I have a big help text for each of my region so can any easy way is there to put the help text for each region more than 10 lines .I tried lot by searching forums but not able to implement. any document is there then please let me know.
Thanks in advance,
Amiti mean either if we click the region title name it should display some help text of near about 10 lines in a popup window.
Or on moseover whenever we will put the cursor into the region title then it should displat the help text message of line 10.
Hope you will get my qustion well.
Thanks,
Amit -
Nested table updation in FOR Cursor loop
Hello,
I have nested table as follows:
SQL> desc fp
Name Null? Type
ORDER_NUM NOT NULL VARCHAR2(10)
ORDER_TIE_NUM NOT NULL VARCHAR2(10)
FACILITY NOT NULL VARCHAR2(10)
ON_SHORTS NUMBER(2)
ACTIVE_SHORTS NUMBER(2)
PARTS DPM_TRANSFORM_CODE.FP_SLC_SHORT
FIRST_SHORT DATE
LAST_SHORT DATE
SQL> desc DPM_TRANSFORM_CODE.FP_SLC_SHort
DPM_TRANSFORM_CODE.FP_SLC_SHort TABLE OF DPM_TRANSFORM_CODE.FP_SHORT_INFO
Name Null? Type
PART_NUM VARCHAR2(7)
AREA VARCHAR2(7)
PART_QTY NUMBER(3)
ON_SHORT_CNT NUMBER(4)
OFF_SHORT_CNT NUMBER(4)
FIRST_DATE DATE
LAST_DATE DATE
UPDATE TABLE(SELECT PARTS FROM DPM_REPORTING.FP WHERE ORDER_NUM = P.ORDER_NUM AND ORDER_TIE_NUM = P.ORDER_TIE_NUM) PARTS
SET PARTS.OFF_SHORT_CNT = PARTS.OFF_SHORT_CNT + 1
WHERE PARTS.last_date < SYSDATE - 2/24;
This Update Statement is in FOR Cursor Loop
where select statement for the cursor is
"SELECT ORDER_NUM,ORDER_TIE_NUM,PARTS FROM DPM_REPORTING.FP WHERE FACILITY = 'PN1'"
This select statement generates 20000 records & due to which the Update statement gets executed that many times inside FOR loop.The Procedure has become quite slow due to this.
Please help.
Thanks,
RekhaYou could do it all in one sql update statement, without any pl/sql or cursor or looping:
UPDATE fp t1
SET t1.parts =
CAST (MULTISET (SELECT part_num, area, part_qty, on_short_cnt,
CASE WHEN last_date < SYSDATE - 2/24
THEN off_short_cnt + 1
ELSE off_short_cnt
END,
first_date, last_date
FROM TABLE (SELECT parts
FROM fp
WHERE facility = 'PN1'
AND order_num = t1.order_num
AND order_tie_num = t1.order_tie_num))
AS fp_slc_short)
WHERE t1.facility = 'PN1'
/ -
Is IN OUT for Cursor variable mandatory?
Hi all:
I have a stored procedure which will just return a boolean value after the task is done. And i'm using more than 1 cursor variables in that stored procedure. What my question is
"Is IN OUT for Cursor variable mandatory from the PROCEDURE i have written?".
Because in the manual they mentioned that IN OUT should be there for a cursor variable. My PROCEDURE declaration is as below:
TYPE emp_det IS REF CURSOR;
PROCEDURE <proc_name>(startdate VARCHAR2, enddate VARCHAR2, ids VARCHAR2, taskdone OUT BOOLEAN,emp IN OUT emp_det);
Is there any modification in the above declaration if i'm using one cursor and NOT returning that cursor back to the called program. I don't to get returned.
Hope i made it clear.
Thanks,
- VenuVenu:
As far as I know you don't need In Out unless
you are using that variable to pass values between the two procedures.
It is so easy to try it , so I suggest you write two small procedures to check this.It should only take a couple of minutes.
Hope this helps. -
Query help needed for querybuilder to use with lcm cli
Hi,
I had set up several queries to run with the lcm cli in order to back up personal folders, inboxes, etc. to lcmbiar files to use as backups. I have seen a few posts that are similar, but I have a specific question/concern.
I just recently had to reference one of these back ups only to find it was incomplete. Does the query used by the lcm cli also only pull the first 1000 rows? Is there a way to change this limit somwhere?
Also, since when importing this lcmbiar file for something 'generic' like 'all personal folders', pulls in WAY too much stuff, is there a better way to limit this? I am open to suggestions, but it would almost be better if I could create individual lcmbiar output files on a per user basis. This way, when/if I need to restore someone's personal folder contents, for example, I could find them by username and import just that lcmbiar file, as opposed to all 3000 of our users. I am not quite sure how to accomplish this...
Currently, with my limited windows scripting knowledge, I have set up a bat script to run each morning, that creates a 'runtime' properties file from a template, such that the lcmbiar file gets named uniquely for that day and its content. Then I call the lcm_cli using the proper command. The query within the properties file is currently very straightforward - select * from CI_INFOOBJECTS WHERE SI_ANCESTOR = 18.
To do what I want to do...
1) I'd first need a current list of usernames in a text file, that could be read (?) in and parsed to single out each user (remember we are talking about 3000) - not sure the best way to get this.
2) Then instead of just updating the the lcmbiar file name with a unique name as I do currently, I would also update the query (which would be different altogether): SELECT * from CI_INFOOBJECTS where SI_OWNER = '<username>' AND SI_ANCESTOR = 18.
In theory, that would grab everything owned by that user in their personal folder - right? and write it to its own lcmbiar file to a location I specify.
I just think chunking something like this is more effective and BO has no built in back up capability that already does this. We are on BO 4.0 SP7 right now, move to 4.1 SP4 over the summer.
Any thoughts on this would be much appreciated.
thanks,
MissyJust wanted to pass along that SAP Support pointed me to KBA 1969259 which had some good example queries in it (they were helping me with a concern I had over the lcmbiar file output, not with query design). I was able to tweak one of the sample queries in this KBA to give me more of what I was after...
SELECT TOP 10000 static, relationships, SI_PARENT_FOLDER_CUID, SI_OWNER, SI_PATH FROM CI_INFOOBJECTS,CI_APPOBJECTS,CI_SYSTEMOBJECTS WHERE (DESCENDENTS ("si_name='Folder Hierarchy'","si_name='<username>'"))
This exports inboxes, personal folders, categories, and roles, which is more than I was after, but still necessary to back up.. so in a way, it is actually better because I have one lcmbiar file per user - contains all their 'personal' objects.
So between narrowing down my set of users to only those who actually have saved things to their personal folder and now having a query that actually returns what I expect it to return, along with the help below for a job to clean up these excessive amounts of promotion jobs I am now creating... I am all set!
Hopefully this can help someone else too!
Thanks,
missy -
help needed for writing query
i have the following tables(with data) as mentioned below
FK*-foregin key (SUBJECTS)
FK**-foregin key (COMBINATION)
1)SUBJECTS(table name)
SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
2 02 Computer Science
3 03 Physics
4 04 Chemistry
5 05 Mathematics
7 07 Commerce
8 08 Computer Applications
9 09 Biology
2)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
383 S1 9 4 2 3
384 S2 4 2 5 3
---------I actually designed the ABOVE table also like this
3) a)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
383 S1
384 S2
b)COMBINATION_DET
COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
1 383 9
2 383 4
3 383 2
4 383 3
5 384 4
6 384 2
7 384 5
8 384 3
Business rule: a combination consists of a maximum of 4 subjects (must contain)
and the user is less relevant to a COMB_NAME(name of combinations) but user need
the subjects contained in combinations
i need the following output
COMB_ID COMB_NAME SUBJECT1 SUBJECT2 SUBJECT3 SUBJECT4
383 S1 Biology Chemistry Computer Science Physics
384 S2 Chemistry Computer Science Mathematics Physics
or even this is enough(what i actually needed)
COMB_ID subjects
383 Biology,Chemistry,Computer Science,Physics
384 Chemistry,Computer Science,Mathematics,Physics
you can use any of the COMBINATION table(either (2) or (3))
and i want to know
1)which design is good in this case
(i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
good method to link with same table but if 4 subjects only(and must) comes
detail table is not neccessary )
now i am achieving the result by program-coding in C# after getting the rows from oracle
i am using oracle 9i (also ODP.NET)
i want to know how can i get the result in the stored procedure itsef.
2)how it could be designed in any other way.
any help/suggestion is welcome
thanks for your time --PradeeshWell I forgot the table-alias, here now with:
SELECT C.COMB_ID
, C.COMB_NAME
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
FROM COMBINATION C;
As you need exactly 4 subjects, the columns-solution is just fine I would say. -
I installed windows 7 to my macbook pro, but my mousepad does not work in windows 7 and also i can not connect my windows 7 to projector, but i can use my macbook's mouse pad and i can connect my mac to projector,so please help me for windows 7 problem
i try to download now, do you think when i download and install the windows support software, can i fix the problem?
-
HT5429 direction is not coming in IOS 6 in india. can someone help me for the same?
direction is not coming in IOS 6 in india. can someone help me for the same? i'm using iphone 4
Hi Civilclerk1,
In order to achieve your requirement, we can try to use the following expression to instead the last_name column and first_name field:
last_name: =iif(Fields! staff_role.Value="Lead Atty" or Fields! staff_role.Value="BK Mgr" or Fields! staff_role.Value="Partner" ,Fields! last_name.Value,nothing)
first_name: =iif(Fields! staff_role.Value="Lead Atty" or Fields! staff_role.Value="BK Mgr" or Fields! staff_role.Value="Partner" ,Fields! first_name.Value,nothing)
Besides, if we don’t want see the blank row in the tablix, we can add a filter as below in the tablix:
Expression:=iif(Fields! staff_role.Value="Lead Atty" or Fields! staff_role.Value="BK Mgr" or Fields! staff_role.Value="Partner" ,1,0)
Operator:=
Value:=1
If there are any misunderstanding, please elaborate the issue for further investigation.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Search help (PREM) for personal no. is not coming in ALV grid table control
hi experts,
Search help (PREM) for personal no. is not coming in ALV grid table control.
i have assigned the srch help (prem) to my 'ZFIEXP_PROJALLOC' table for the emp_id.
but in output it is now showing the help.
ls_fcat-fieldname = 'EMPLOYEE CODE'.
ls_fcat-ref_table = 'ZFIEXP_PROJALLOC'.
ls_fcat-ref_field = 'EMP_ID'.
ls_fcat-outputlen = '10'.
ls_fcat-key = 'X'.
ls_fcat-edit = 'X'.
ls_fcat-coltext = 'EMPLOYEE CODE'.
ls_fcat-seltext = 'EMPLOYEE CODE'.
append ls_fcat to pt_fieldcat.
clear ls_fcat.
Then i tried to solve it using the PA0002 . ie.,
ls_fcat-fieldname = 'EMPLOYEE CODE'.
ls_fcat-ref_table = 'PA0002'.
ls_fcat-ref_field = 'PERNR'.
ls_fcat-outputlen = '10'.
ls_fcat-key = 'X'.
ls_fcat-edit = 'X'.
ls_fcat-coltext = 'EMPLOYEE CODE'.
ls_fcat-seltext = 'EMPLOYEE CODE'.
append ls_fcat to pt_fieldcat.
clear ls_fcat.
with this it is showing the help in employee code, but, when i click on an empl number, it is not added to my table control and allowing me to add the number by typing them.
plz help me.
thanks.Hi
In the layout give layout-sel_mode = 'A'. and
pass 'A' to i_save exporting parameter to method set_table_for_first_display.
The same thing if you are working with function module
reuse_alv_grid_display.
Reward points for useful answer.
Venkat -
Hi, can you help me for my payment account? It's always show " Your payment method was declined..." How can I fix it? There's only 3 to choose fpr Visa, Master Card and Amex.. But doesn't have "None".. I can't download any apps from app store
http://support.apple.com/kb/ht1918
-
Use of FOR Cursor and BULK COLLECT INTO
Dear all,
in which case we prefer to use FOR cursor and cursor with BULK COLLECT INTO? The following contains two block that query identically where one is using FOR cursor, the other is using BULK COLLECT INTO . Which one that performs better given in the existing task? How do we measure performance between these two?
I'm using sample HR schema:
declare
l_start number;
BEGIN
l_start:= DBMS_UTILITY.get_time;
dbms_lock.sleep(1);
FOR employee IN (SELECT e.last_name, j.job_title FROM employees e,jobs j
where e.job_id=j.job_id and e.job_id LIKE '%CLERK%' AND e.manager_id > 120 ORDER BY e.last_name)
LOOP
DBMS_OUTPUT.PUT_LINE ('Name = ' || employee.last_name || ', Job = ' || employee.job_title);
END LOOP;
DBMS_OUTPUT.put_line('total time: ' || to_char(DBMS_UTILITY.get_time - l_start) || ' hsecs');
END;
declare
l_start number;
type rec_type is table of varchar2(20);
name_rec rec_type;
job_rec rec_type;
begin
l_start:= DBMS_UTILITY.get_time;
dbms_lock.sleep(1);
SELECT e.last_name, j.job_title bulk collect into name_rec,job_rec FROM employees e,jobs j
where e.job_id=j.job_id and e.job_id LIKE '%CLERK%' AND e.manager_id > 120 ORDER BY e.last_name;
for j in name_rec.first..name_rec.last loop
DBMS_OUTPUT.PUT_LINE ('Name = ' || name_rec(j) || ', Job = ' || job_rec(j));
END LOOP;
DBMS_OUTPUT.put_line('total time: ' || to_char(DBMS_UTILITY.get_time - l_start) || ' hsecs');
end;
/In this code, I put timestamp in each block, but they are useless since they both run virtually instantaneous...
Best regards,
ValIf you want to get 100% benifit of bulk collect then it must be implemented as below
declare
Cursor cur_emp
is
SELECT e.last_name, j.job_title
FROM employees e,jobs j
where e.job_id=j.job_id
and e.job_id LIKE '%CLERK%'
AND e.manager_id > 120
ORDER BY e.last_name;
l_start number;
type rec_type is table of varchar2(20);
name_rec rec_type;
job_rec rec_type;
begin
l_start:= DBMS_UTILITY.get_time;
dbms_lock.sleep(1);
/*SELECT e.last_name, j.job_title bulk collect into name_rec,job_rec FROM employees e,jobs j
where e.job_id=j.job_id and e.job_id LIKE '%CLERK%' AND e.manager_id > 120 ORDER BY e.last_name;
OPEN cur_emp;
LOOP
FETCH cur_emp BULK COLLECT INTO name_rec LIMIT 100;
EXIT WHEN name_rec.COUNT=0;
FOR j in 1..name_rec.COUNT
LOOP
DBMS_OUTPUT.PUT_LINE ('Name = ' || name_rec(j) || ', Job = ' || job_rec(j));
END LOOP;
EXIT WHEN cur_emp%NOTFOUND;
END LOOP;
CLOSE cur_emp;
DBMS_OUTPUT.put_line('total time: ' || to_char(DBMS_UTILITY.get_time - l_start) || ' hsecs');
end;
/ -
Turn Passcode Off is disabled in my iPod touch 5. Could you please help me for the same ?
What do yoo mean?
-
My mail forms created by muse 2014.0.1.30 do not work. PHP 5.4 is enabled by my hoster, so they should work. Can anyone help me, for these forms are crucial for my business. The forms confirm delivery, but the mails are not recieved. No spam filters enabled.
Meanwhile, I was able to narrow the problem down: PHP seems not to accept a re-directed mail address as sender of the mail in some cases. So, it has nothing to do with the mail form itself.Hi Ingo,
Please refer to this document, Troubleshooting Muse Form Widgets Used on Third-Party Servers
Last section, "I've uploaded my new Muse form, and tried submitting it in the browser, but I never receive an email with the form data. What's wrong?"
- Abhishek Maurya -
How to create a help view for a customized error message
Hi all,
Can you guide me how to create a help view for a customized error message, we need to put some suggestions in it so that user can can resolve this issue with this guide. ( the short text is too short to describe all situations via TC:SE91)
Thanks very much!
Bruce, WenHi Bruce,
Could you brief your concerns again.
Why don't you maintain long text in message class for long description.
Regards,
Ranjith N
Maybe you are looking for
-
Hi, I am using JDev 11.1.2.2.0 I made a standard line graph which I populate with data through a backing bean. I read a post on how to put points to the graph: ArrayList <Object[]> data; Object[0] -> x axis data, here I have dates Object[1] -> name o
-
Ok, this is one more of those basic skills that I've never mastered. What is the best way to add the drivers to the instr. lib? After extracting the files from the zip file I've got a set of drivers in .llb and the .mnu files in a directory (see the
-
What is Apple using to hide Lion Recovery, how can I duplicate it?
After installing Lion, it includes a recovery partition (Recovery HD). This partition is visible in the startup disk screen in the EFI (booting using option), however, it doesn't show up in finder, nor does it show up in Disk Utility (unless you have
-
Machine Certificate Autoenroll
Hello All, I was using an Apple Script to Auto-enroll OS X 10.6 in our Microsoft PKI certificate infrastructure (Machines certificate). The script created all the needed cert request parameters automatically, submitted it via the web based certifica
-
Suggestions for FS review to prepare TS document
Hello Gurus Good day to you. Now i have a requirement for reviewing the functional specification. I have few FS documents and i want to review them and let my manager know whether those FS documents are having the required information to start up to