Need a column based off a PL/SQL cursor, how to do this?
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Real Application Testing option
JServer Release 9.2.0.8.0 - Production
Report Builder 10.1.2.2.0
ORACLE Server Release 10.1.0.5.0
Oracle Procedure Builder 10.1.2.2.0
Oracle ORACLE PL/SQL V10.1.0.5.0 - Production
Oracle CORE 10.1.0.5.0 Production
Hi,
I am trying to create a fairly basic report but in the initial data model query, I have one column that is built based off of a PL/SQL cursor. How do I add this into my report? I have tried to create a function under Program Units and reference the function in my select statement for the data model however it keeps saying it is an invalid identifier, and I assume its looking in our database and not the function I created inside the report.
This is what it looks like:
SELECT a.id,
b.name,
F_GET_GENERIC_NAME(b.code) "Generic Name",
c.strength...and the function i want it to use in my report:
FUNCTION F_GET_GENERIC_NAME (in_code varchar2) RETURN VARCHAR2 IS
BEGIN
DECLARE
generic_name table.column%TYPE;
CURSOR cs_get_generic_name IS
SELECT /*+ USE_HASH (AR) */ desc
FROM a_ref AR, ai_ic AC
WHERE AC.code = in_code
AND AC.code = AR.code
ORDER BY sort_nbr;
BEGIN
generic_name := '';
FOR v_get_generic_name IN cs_get_generic_name
LOOP
generic_name := generic_name || RTRIM(v_get_generic_name.desc)
|| '/' || ' ';
END LOOP;
generic_name := SUBSTR(generic_name, 1,(NVL(LENGTH(generic_name), 0) - 2));
RETURN generic_name;
END;
END;
Any suggestions? Should I just create the function in the database?
I am trying to do it through a formula column but am encountering the following problem.
I've created a formula column in my data model where I want the column to be (inside the group).
Inside the PL/SQL for the column I reference the function that I had previously created with the following:
function CF_Generic_nameFormula return Char is
begin
F_GET_GENERIC_NAME(:code);
end;However it won't let me compile, giving the error that "F_GET_GENERIC_NAME is not a procedure or is undefined." Is there something else that I am missing?
EDIT: Nevermind, i missed something simple like putting a return in front of the function call.
Edited by: a small rabbit on Nov 3, 2009 10:43 AM
Edited by: a small rabbit on Nov 3, 2009 10:44 AM
Similar Messages
-
Populate multiple rows and columns based off of a single cell
Does anyone know a way to populate multiple rows and columns based off of the input of a single cell. I'm trying to create a workout tracker that auto populates from a master list of workouts. Example, in A2 the user selects the workout from a drop down menu (St1, St2, St3, etc) and the workout is pulled from the master list and is populated into B2:C5.
I'm using =LOOKUP(A2,Master :: A2:A32,Master :: C2:C32) right now, but it's only drawing the top column. I'm looking for an edit for the formula (or completely new formula) that will place the info from the 1st column of the Master table into the 1st column of the Auto Tracker 1 table and then on down until the 4th column.
Here is a screen shot of what I have now:
And an example of what I'd like to accomplish:
Any and all help is appreciated, and please let me know if there is any more info that I can give that'd help out.Hi Mike,
Your screenshots show that you have merged some cells in Column A of both tables. That may be the reason why the LOOKUP function is having trouble working out which range of cells to examine.
Hope this helps.
Regards,
Ian. -
my i pod classic shows a sad face on the screen and wont turn on at all > will i need to sent it off to get repaired or how can i fix it thanks shiv
i have this same issue! have you figured out what to do?
-
I followed the instructions given to turn my automatic download icon in my iphone 3 and still goes back to off position. Any idea how to fix this issue without getting a new one?
Something may have gone amiss on your iPhone.
To attempt to correct this follow these steps:
Backup your iPhone using iTunes or iCloud.
Use iTunes to completely restore your iPhone as Factory new.
Monitor battery usage to see if it is normal. If not, you may have a hardware problem - if so, contact Apple support.
Restore your iPhone from your backup above.
Check battery usage to confirm that it is still normal. -
my iphone is suddendly got switch off while playing game . now how to resolve this problem
please iphone guide me how shall i restart my phone
-
I submitted my podcast and I got an email saying error, I checked with the feed validator and got this message: This feed does not validate. line 40, column 6: Undefined item element: itunes:order, how do sort this out, someone help me please.
Ignore it. 'itunes:order' is a recent addition which FeedValidator doesn't know about. If your podcast is rejected that is unlikely to be the reason. Of course as you haven't posted the feed URL nor the text of the error message I can't make any further comment.
-
Turn off email alert?? How to do this?
I just got my phone set up for eMail. Now it is driving me crazy because I don't know how to turn off the alert sound that says when I have eMail. Please advise if you know how to do this.
Thanks very much.
The Price of Freedom is Eternal Vigilance
Solved!
Go to Solution.If you just have personal (using BIS), you can setup messages filters on your carrier's BIS website.
If you're on a BES you'll have the choice on the device to filter your corporate emails (under Messages | Options | Email Filters). Personal emails will still be done from your carrier's website.
If someone has been helpful please consider giving them kudos by clicking the star to the left of their post.
Remember to resolve your thread by clicking Accepted Solution. -
Help needed with condition based joins in pl\sql
Hi,
I need to get data from 6 tables,
Scenario 1 : I need to join 4 tables and join this result set to 5th table
Scenario2: resultset of join of 4 tables to 6th table
In this case how do i save the intermediate result set of 4 tables to use it in further joins.Welcome to the forum.
Your question is broad.
http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html
A more detailed example would help.
Mention your database version as well and see the FAQ http://forums.oracle.com/forums/help.jspa when it comes to posting formatted examples using the {noformat}{noformat} tag
However, i think using the WITH clause or a subquery ( a.k.a. inline view) is what you're looking for.
Do some searches on http://asktom.oracle.com to find many examples.
Also see:
http://www.oracle-base.com/articles/misc/WithClause.php
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries007.htm#sthref3193 -
Need 3 column based on excel formulas, for Average cost of sales.
hii,,
i am using Oracle 10g...
select
pdate,
pcode,
pno,
pqty,
pprice,
trade_amt
, qty_on_hand
, total_cost
, case when pqty < 0
then
lag (avg_price) over (order by pdate)
else
avg_price
end avg_price
, case when pqty < 0
then
lag (avg_price) over (order by pdate)*-pqty
else
avg_price*pqty
end bal_cost
from (
select
pdate,
pcode,
pno,
pqty,
pprice,
pqty*pprice trade_amt,
sum (pqty) over (order by pdate) qty_on_hand,
sum (pqty*pprice) over (order by pdate) total_cost,
sum (pqty*pprice) over (order by pdate) /
sum (pqty) over (order by pdate) avg_price
from
select to_date('12/01/2011','dd/mm/yyyy') pdate, 'PUR' pcode, 1 pno, 10 pqty, 37.425 pprice from dual union all
select to_date('13/01/2011','dd/mm/yyyy'), 'INV', 1, -5, 48.169 from dual union all
select to_date('14/01/2011','dd/mm/yyyy'), 'PUR', 3, 15, 21.628 from dual union all
select to_date('15/01/2011','dd/mm/yyyy'), 'INV', 4, -10, 32.6 from dual union all
select to_date('16/01/2011','dd/mm/yyyy'), 'PUR', 4, 20, 22.33 from dual union all
select to_date('16/01/2011','dd/mm/yyyy'), 'PUR', 5, 35, 19.55 from dual union all
select to_date('18/01/2011','dd/mm/yyyy'), 'INV', 5, -8, 28 from dual union all
select to_date('22/01/2011','dd/mm/yyyy'), 'INV', 6, -12, 32.6 from dual
order BY 1,2,3
this is what the above query returns....( total_cost and avg.price are wrong...so as the bal_cost)
PDATE PCO PNO PQTY PPRICE TRADE_AMT QTY_ON_HAND TOTAL_COST AVG_PRICE BAL_COST
12-JAN-11 PUR 1.000 10.000 37.425 374.250 10.000 374.250 37.425 374.25
13-JAN-11 INV 1.000 -5.000 48.169 -240.845 5.000 133.405 37.425 187.125
14-JAN-11 PUR 3.000 15.000 21.628 324.420 20.000 457.825 22.891 343.373
15-JAN-11 INV 4.000 -10.000 32.600 -326.000 10.000 131.825 22.891 228.915
16-JAN-11 PUR 4.000 20.000 22.330 446.600 65.000 1262.675 19.426 388.517
16-JAN-11 PUR 5.000 35.000 19.550 684.250 65.000 1262.675 19.426 679.905
18-JAN-11 INV 5.000 -8.000 28.000 -224.000 57.000 1038.675 19.426 155.407
22-JAN-11 INV 6.000 -12.000 32.600 -391.200 45.000 647.475 18.222 218.669
8 rows selected.
i expect the result to be like this...
PDATE PCO PNO PQTY PPRICE TRADE_AMT QTY_ON_HAND TOTAL_COST AVG_PRICE BAL_COST
12-JAN-11 PUR 1.000 10.000 37.425 374.250 10.000 374.250 37.425 374.25
13-JAN-11 INV 1.000 -5.000 48.169 -240.845 5.000 133.405 37.425 187.125
14-JAN-11 PUR 3.000 15.000 21.628 324.420 20.000 457.825 25.577 511.545
15-JAN-11 INV 4.000 -10.000 32.600 -326.000 10.000 131.825 25.577 255.773
16-JAN-11 PUR 4.000 20.000 22.330 446.600 65.000 1262.675 23.412 702.373
16-JAN-11 PUR 5.000 35.000 19.550 684.250 65.000 1262.675 21.333 1386.623
18-JAN-11 INV 5.000 -8.000 28.000 -224.000 57.000 1038.675 21.333 1215.961
22-JAN-11 INV 6.000 -12.000 32.600 -391.200 45.000 647.475 21.333 959.969
8 rows selected.to arrive at bal_cost and avg.price, i need 1 more calculation for 'cost_of_sal' which is where i am stuck how to create it first and make use of that..
1) qty_on_hand running balance is OK..
2) cost_of_sale = when qty is -nve (i.e. pcode = 'INV') then take (1 row)previous value of Avg.Price and multiply by sold qty of current row.
3) bal_cost = when qty is +ve (i.e. pcode = 'PUR') then take (1 row)previous value bal_cost and add the trade_amt of current_row OR
when qty is -nve (i.e. pcode='INV') then take (1 row)previous vaue bal_cost and add the cost_of_sale of current_row
finally
4) avg.price = bal_cost / qty_on_hand
just a link showing excel forumlas...http://www.flickr.com/photos/58335021@N07/5356642176/
thank you..hii Etbin..thanks for your effort..but still the result is not as i want, above...
select pdate,pcode,pno,pqty,pprice,trade_amt,qty_on_hand,total_cost,avg_price,bal_cost,
case when pqty < 0
then lag(avg_price) over (order by pdate) * (- pqty)
end cost_of_sale, /* shown as an intermediate result - included in next case */
case when pqty < 0
then lag(bal_cost) over (order by pdate) + lag(avg_price) over (order by pdate) * (- pqty)
else lag(bal_cost) over (order by pdate) + trade_amt
end bal_cost_new, /* shown as an intermediate result - used in next case */
case when pqty < 0
then lag(bal_cost) over (order by pdate) + lag(avg_price) over (order by pdate) * (- pqty)
else lag(bal_cost) over (order by pdate) + trade_amt
end / qty_on_hand avg_price_new
from (select pdate,pcode,pno,pqty,pprice,trade_amt,qty_on_hand,total_cost,
case when pqty < 0
then lag(avg_price) over (order by pdate)
else avg_price
end avg_price,
case when pqty < 0
then lag(avg_price) over (order by pdate) * (- pqty)
else avg_price * pqty
end bal_cost
from (select pdate,pcode,pno,pqty,pprice,
pqty * pprice trade_amt,
sum(pqty) over (order by pdate) qty_on_hand,
sum(pqty * pprice) over (order by pdate) total_cost,
sum (pqty * pprice) over (order by pdate) / sum(pqty) over (order by pdate) avg_price
from
select to_date('12/01/2011','dd/mm/yyyy') pdate, 'PUR' pcode, 1 pno, 10 pqty, 37.425 pprice from dual union all
select to_date('13/01/2011','dd/mm/yyyy'), 'INV', 1, -5, 48.169 from dual union all
select to_date('14/01/2011','dd/mm/yyyy'), 'PUR', 3, 15, 21.628 from dual union all
select to_date('15/01/2011','dd/mm/yyyy'), 'INV', 4, -10, 32.6 from dual union all
select to_date('16/01/2011','dd/mm/yyyy'), 'PUR', 4, 20, 22.33 from dual union all
select to_date('16/01/2011','dd/mm/yyyy'), 'PUR', 5, 35, 19.55 from dual union all
select to_date('18/01/2011','dd/mm/yyyy'), 'INV', 5, -8, 28 from dual union all
select to_date('22/01/2011','dd/mm/yyyy'), 'INV', 6, -12, 32.6 from dual
order by 1,2,3
PDATE PCO PNO PQTY PPRICE TRADE_AMT QTY_ON_HAND TOTAL_COST AVG_PRICE BAL_COST COST_OF_SALE BAL_COST_NEW AVG_PRICE_NEW
12/01/2011 PUR 1.000 10.000 37.425 374.250 10.000 374.250 37.425 374.250
13/01/2011 INV 1.000 -5.000 48.169 -240.845 5.000 133.405 37.425 187.125 187.125 561.375 112.275
14/01/2011 PUR 3.000 15.000 21.628 324.420 20.000 457.825 22.891 343.369 511.545 25.577
15/01/2011 INV 4.000 -10.000 32.600 -326.000 10.000 131.825 22.891 228.913 228.913 572.281 57.228
16/01/2011 PUR 4.000 20.000 22.330 446.600 65.000 1262.675 19.426 388.515 675.513 10.393
16/01/2011 PUR 5.000 35.000 19.550 684.250 65.000 1262.675 19.426 679.902 1072.765 16.504
18/01/2011 INV 5.000 -8.000 28.000 -224.000 57.000 1038.675 19.426 155.406 155.406 835.308 14.655
22/01/2011 INV 6.000 -12.000 32.600 -391.200 45.000 647.475 18.222 218.668 233.109 388.515 8.634
8 rows selected.any other thought..
TY -
My computer crashed and I got a new hardrive. I need to get my music off my Ipod Touch 4th gen onto my new computer...is it even possible anymore?
For iTunes purchases:
iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
For other music you need a third-pary program like one of those discussed here:
Copy music from Ipod to new computer...: Apple Support Communities -
I linked husbands iPhone to my apple account. Now his number shows up on my iPad and mine is no longer on there. How do I get his off and mine back
Read this for more information.
iOS and OS X: Link your phone number and Apple ID for use
After you add your phone number you can deselect your husband's number in the settings. -
My iphone 3gs says I need to restore my phone with itunes. when i connect the phone it says i need to unlock the phone which i cannont due because of the caution on the phone. How do i fix this?
Hold down the power button and home button at the same time until the phone powers on, shuts back off, powers on again and continue to hold it until it shows the itunes logo to plug in to itunes. This should allow you to restore without unlocking it.
-
Sql question how to write this query
This is my query:
SELECT msi.segment1 item, bsd.operation_code, bd.department_code,
bsd.operation_description
FROM mtl_system_items msi,
bom_operational_routings bort,
bom_operation_sequences bos,
bom_departments bd,
bom_operation_resources br,
bom_resources bor,
bom_standard_operations bsd
WHERE msi.inventory_item_id = bort.assembly_item_id
AND msi.organization_id = bort.organization_id
AND bort.routing_sequence_id = bos.routing_sequence_id
AND bos.department_id = bd.department_id
AND bd.department_id = bsd.department_id
AND bos.standard_operation_id = bsd.standard_operation_id
AND bos.operation_sequence_id = br.operation_sequence_id
AND bor.resource_id = br.resource_id
AND bos.reference_flag = 1
AND msi.organization_id = '82'
AND bos.disable_date IS NULL
GROUP BY msi.segment1,
bsd.operation_code,
bd.department_code,
bos.operation_description,
bsd.operation_description,
bor.resource_code
Which essentially produces this output:
Item Op code Dept Description
123 10 Warehouse Move parts
123 20 Assembly Finish Parts
123 30 Inspection Complete
I need to capture when the part goes into Inspection and from where it came, so in this case, From Assembly to Inspection.
I don't even know where to start
Thanks for any directionNot sure I've got the columns names right from your example, but does this get you started at all?
It sounds like you might need an analytic function like LAG or LEAD.
with t as
(select 123 item, 10 op, 'Warehouse' code, 'Move' dept, 'parts' description
from dual
union
select 123, 20, 'Assembly', 'Finish', 'Parts'
from dual
union
select 123, 30, 'Inspection', 'Complete',null
from dual)
select *
from (
select item, op, code, dept, description, lag(code) over (partition by item order by op) previous_code
from t
where code = 'Inspection';
ITEM OP CODE DEPT DESCR PREVIOUS_C
123 30 Inspection Complete AssemblyMessage was edited by:
dombrooks -
How do I switch from the uk store to the Canada store? On my iPhone it won't let me download apps or update without switching. Any ideas? Thank you!
Contact iTunes. You need a valid payment method and the messages says you do not have that.
Apple - Support - iTunes - Contact Us -
I recently got a new computer and transferred programs over to it (it's a Mac Pro). But now my Adobe Acrobat 8 Professional application no longer works so I need to reinstall. (Acrobat 8 originally was bundled with CS3 Design Premium.) I no longer have the disks for these programs, so I downloaded the CS3 Design Premium from Adobe's website. Upon opening up the .dmg file and starting the install process, I'm prompted with an "Install Error" telling me: "Please insert Adobe Photoshop CS4 to continue installation." I do not have a disk for PS CS4. How do I continue the install??
Thank you,
-KristineTransferring files between machines doesn't work for Adobe applications. You should uninstall anything you transferred over and use the cleaner tool for it. Then download and install the CS3 suite as a whole.
Adobe Creative Suite Cleaner Tool
helps resolve installation problems for CS3 thru CS6 and for Creative Cloud
http://www.adobe.com/support/contact/cscleanertool.html
Maybe you are looking for
-
How do I make a custom brush image in a gradient color scheme in Photoshop Elements 12?
I want to make a custom brush image in a gradient color scheme. I know how to change the hue jitter, but I want to "paint" the image with a gradient between two colors. For example, I have an image of an octopus that I have used to create a custom
-
i am trying to solve an organizational problem where i have pdfs of published pages or work that are either one or two pages. this pdf format is very convenient for posting to the web in something like Scribd so that others can see it but it is very
-
Problem with transferring purchases in iTunes...
So here's the deal. I've had my iPhone 3g since it was released and had it sync'ing up to my work computer for awhile but for the past 8-9 months or so I've been using the phone the whole time without sync'ing or updating. I just bought all apps thro
-
Computer won't start from CD!
I tried booting from a CD by holding the "c" down when I start up the computer. I'm trying to run TechTool Deluxe... Anyway, I've tried holding down "c" numerous times, and it just boots up like normal. Then, I also tried something listed, which I fo
-
Had the speakers for about 6 months with no problems. Now the left front speaker has no sound. Specifically, it appears the left front speaker jack isn't working. No matter which speaker I hook up to it, there's no sound. All 3 other speakers/jacks a