Pass multiple values as single input parameter into pipelined function
Hi all,
My need is to pass multiple values as single input parameter into pipelined function.
For example - "2" and "3" are values of input parameter "t":
with data as (
select 1 as t from dual union all
select 2 as t from dual union all
select 3 as t from dual union all
select 4 as t from dual union all
select 5 as t from dual
select * from data where t in (2,3)Is it possible at all?
Not exactly sure, but usually 'multiple values'+'pipelined function' = some IN-LIST related approach?
See:
SQL> create table data as
2 select 1 as t from dual union all
3 select 2 as t from dual union all
4 select 3 as t from dual union all
5 select 4 as t from dual union all
6 select 5 as t from dual;
Table created.
SQL> --
SQL> CREATE OR REPLACE FUNCTION in_list (p_in_list IN VARCHAR2)
2 RETURN sys.odcivarchar2list PIPELINED
3 AS
4 l_text VARCHAR2(32767) := p_in_list || ',';
5 l_idx NUMBER;
6 BEGIN
7 LOOP
8 l_idx := INSTR(l_text, ',');
9 EXIT WHEN NVL(l_idx, 0) = 0;
10 PIPE ROW (TRIM(SUBSTR(l_text, 1, l_idx - 1)));
11 l_text := SUBSTR(l_text, l_idx + 1);
12 END LOOP;
13
14 RETURN;
15 END;
16 /
Function created.
SQL> --
SQL> select *
2 from data
3 where t in ( select *
4 from table(in_list('1,2'))
5 );
T
1
2
2 rows selected.http://www.oracle-base.com/articles/misc/dynamic-in-lists.php
or
http://tkyte.blogspot.nl/2006/06/varying-in-lists.html
Similar Messages
-
Passing Multiple Values from a worksheet to PL/SQL function.
Hi All,
Is there any way to pass multiple values selected in a worksheet to a PL/SQL function ?
I will try to explain the scenario:
We have a crosstab report that showing all the customer details, deposit sum of a customer in each date in a date range selected. With the customer details we are showing the Rank of a customer based on the deposit in the latest date selected. Filtering is based on the rank, ie Top50 or Top60 etc.( As I said rank is calculating based on the deposit in the latest date).This is working fine.
Now the new requirement is to : For example, in Top50 report, list all the customers, who were in the Top50 list, in any of the dates selected. We are able to display the daywise rank, but when giving a condition like daywiserank <= 50, the result becomes uncertain. Some blank lines, wrong amounts etc..
As a work around we tried to find out the rank in a PL/SQL function. But the issue there is : we have some multiple value parameters used in the worksheet.
Is there any way to pass multiple values selected in a worksheet to a PL/SQL function ?
Or any other work arounds for the scenario explained?
Reagrds,
JeneeshHi Russ,
Thanks for the response.
Russ Proudman wrote:
1. I thought there was an analytical function similar to rank - or maybe an option of rank - that if there are duplicate records to have them all considered the same rank. So if you had 3 records all the same as rank=2 then a condition saying where rank=2 would return the 3 records. You could check into this.
We are already using DENSE_RANK. But the issue is the output contains incorrect null values nd repeated rows.
We got it solved as I explained in the previous post. But will that AGGREGATION MODE setting ( Which discoverer says - not recommended) have any issue? I mean side effects?
Russ Proudman wrote:
2. Another thought is that you can create a PL/SQL routine - that's called from a SQL function registered in Discoverer - where a table is created that does the first part of your query. Then a worksheet is created to use the data from that table. So, in essence, the table would have your top50 ranked customers. Then you can write any kind of worksheet against that table. However, DBAs are loath to allow tables - that they didn't create! - many times in a PROD environment.
Here also the same problem will occur: as the top 50 will depend upon the parameters. I cannot pass those parameters to PL/SQL Function.And storing the top50 ( itmay be top100 or to 150 also) for all combinations of the parameters is impossible
Russ Proudman wrote:
3. Finally, are you sure you're rank function is correct in that if you're getting blank lines, maybe the 'over' part is not considering all columns needed to determine the rank?
Yes the query we are using is correct. The output QUERY of discoverer gives correct results in Sqlplus.
Regards,
Jeneesh -
Pass Multiple values of single field to ITS url
Hi ,
I have one transaction code(YW37P),
I that have one field(Order No) in the selection screen, which has capable to accept multiple values (i.e multiple single values) and excute the t code.
Now my question is how to pass this multiple values of one single field to the ITS url and by pass the selection screen.
I have gone through the blogs which explains about how to pass only one single value of single field to ITS url and by pass the selection screen
please provide some solution for this
Regards
SrinivasHello Srinivas,
How do you enter multiple order numbers in the field usually? Is there a space or comma separating the numbers? If so you will probably need to encode the space or comma, ie if a comma %2C. The easiest way to figure it out is to use a tool like HTTPwatch and capture the POST data to see the value that is normally sent by the transaction.
Edgar -
Passing multiple values in a parameter through IN operator
hello everyone,
i want to know wheather it is possible to pass multiple values to a report parameter and use the parameter in the query with the IN operator.
I feel this should be possible but dont know the way.
Pls helpi have also suffered from this problem. you can solve it by creating a table like
create table abc
id number,
value number;
then follow the steps.
1) insert all the values in this table by incrementing id and values
2) then pass lowest id and larget id to the report
3) now in report use the select statement like
SELECT * FROM AAA WHERE ABC IN (SELECT VALUE FROM ABC WHERE ID BETWEEN V_MAX AND V_MIN)
4) IN THE REPORT'S AFTER TRIGGER, YOU HAVE TO DELETE
THESE TEMPORARILY CREATED ROWS
LIKE
DELETE ABC
WHERE ID BETWEEN V_MAX AND V_MIN;
SO THIS WILL SOLVE YOUR PROBLEM. -
How to pass multiple values from workbook to planning function ?
Hi,
I have created Planning function in Modeler and it has one parameter(Variable represents = Multiple single values).
When executing the planning function by create planning seq. in the web template : I see value of variable store data like ...
A.) input one value -> V1
B.) input three values -> V1;V2;V3
This function execute completely in web.
However, I want to use the planning function in workbook(Excel).
The value of variable can't input V1;V2;V3... I don't know how to pass multiple values from workbook to parameter(Multiple single values type) in planning function ?
thank you.Hi,
Please see the attached how to document (page no 16).
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0881371-78a1-2910-f0b8-af3e184929be">how to</a>
Hope this was helpful
thanks -
Passing multiple values to a single input parameter
Hi folks,
I have a Microstrategy query successfully passing input parameter to a calculation view. For example I can pass a movement type to a material movements calculation view input parameter. However if I try to pick more than one movement type the query then fails;
Generated SQL that works looks like this;
select
sum(a11.TOTALQUANTITY) WJXBFS1
from
"_SYS_BIC"."MyPackage/CA_TEST_PASS_PARAMETER"
('PLACEHOLDER' = ('$$MoveType$$', '101')
a11
When choosing more than one value in Microstrategy the SQL now fails and looks like this;
select
sum(a11.TOTALQUANTITY) WJXBFS1
from
"_SYS_BIC"."MyPackage/CA_TEST_PASS_PARAMETER"
('PLACEHOLDER' = ('$$MoveType$$', '101'),
'PLACEHOLDER' = ('$$MoveType$$', '103'))
a11
If I cut and paste the SQL and run directly in HANA studio the error is;
Could not execute 'select sum(a11.TOTALQUANTITY) WJXBFS1 from "_SYS_BIC"."MyPackage/CA_TEST_PASS_PARAMETER" ...' in 66 ms 361 µs .
SAP DBTech JDBC: [2048]: column store error: search parameter error: [2018] A received argument has an invalid value;TABLE/VIEW parameter: ( 'PLACEHOLDER'='$$MoveType$$, 103') not supported
Is it possible to pass multiple values in a single parameter? I'm using SP67 for this test.
Thanks,
-PatrickRavi, also to answer one of your questions about how this will work in Microstrategy; I just heard back from my Microstrategy developer and he is trying MSTR Freeform SQL query with syntax like this;
select (sumPAR_TEST.TOTALQUANTITY TOTALQUANTITY
from "_SYS_BIC"."MyPackage/CA_TEST_PASS_PARAMETER"
('PLACEHOLDER' =('$$MoveType$$', '[Movement Type]')) PAR_TEST
In this example [Movement Type] is the microstrategy prompt. Unfortunately though it translates like this which is missing extra single quotes around each value;
select sum(PAR_TEST.TOTALQUANTITY) TOTALQUANTITY
from "_SYS_BIC"."development.pr1959/CA_TEST_PASS_PARAMETER"
('PLACEHOLDER' = ('$$MoveType$$', ''101', '102'')) PAR_TEST
instead of what we need which is;
('PLACEHOLDER' = ('$$MoveType$$', '''101'', ''102''')) PAR_TEST
So at this point we are not sure if this will be possible or not.
-Patrick -
Any way to pass Multiple Values for a single Label in the Parameter?
I have a Report that Contains 2 Parameters, @Customer & @Area. When trying to set up the Available Values for @Area, I'm having issues using multiple values for one Label, i.e. = "4006" Or "4610"
One of the Filters in the Report is an Operation number, which is the [OPERATION] field, which is setup as a filter on the Tablix referencing the @Area parameter.
PROBLEM: I cannot retrieve any data when trying to use the ‘Or’ Operator here. If I simply put “4006” or “4610” I retrieve data, but when trying to combine it returns no data.
Example, I need to allow a user to select ‘Chassis Incoming’, which would include data from Operations 4006 & 4610.
QUESTION:
Any way to pass Multiple Values for a single Label in the Parameter?
I realize the typical solution may be to use ‘Multi-Value’ selection, but in this case we want the User to select the Area and the multiple values for Filtering will be automatically determined for them. Otherwise, they are subject to not getting
it correct.
I have tried several different ways, such as =”4006” Or “4610”, =(“4006”, “4610”), = In(“4006”, “4610”), etc….
Note: We are using Report Builder 3.0Based on my experience, there's no way to 'intercept' the query that gets passed back to SQL Server, so a Split wouldn't work.
Try creating either a function or stored procedure using the code below (compliments to
http://www.dotnetspider.com/resources/4680-Parse-comma-separated-string-SQL.aspx) to parse the string:
CREATE FUNCTION dbo.Parse(@Array VARCHAR(1000), @Separator VARCHAR(10))
RETURNS @ResultTable TABLE (ParseValue VARCHAR(100))AS
BEGIN
DECLARE @SeparatorPosition INT
DECLARE @ArrayValue VARCHAR(1000)
SET @Array = @Array + @Separator
WHILE PATINDEX('%' + @Separator + '%' , @Array) <> 0
BEGIN
SELECT @SeparatorPosition = PATINDEX('%' + @Separator + '%', @Array)
SELECT @ArrayValue = LEFT(@Array, @SeparatorPosition - 1)
INSERT @ResultTable VALUES (CAST(@ArrayValue AS VARCHAR))
SELECT @Array = STUFF(@Array, 1, @SeparatorPosition, '')
END
RETURN
END
Once created you can do things like this:
SELECT * FROM Parse('John,Bill,David,Thomas', ',')
SELECT * FROM (SELECT 'John' AS TestName union select 'David' AS TestName) AS Main
WHERE TestName IN (SELECT ParseValue FROM dbo.Parse('John,Bill,David,Thomas', ','))
This is what your SQL query would probably look like:
SELECT OperationID, OperationName FROM dbo.Operations
WHERE AreaID IN (SELECT ParseValue FROM dbo.Parse(@Area, ','))
You may need to fiddle around with the Separator depending on whether SQL Server inserts a space between the comma and next value. -
Passing multiple values for a single field in URL to call sap Transaction
Hi All,
I need to pass multiple values for a single field to SAP transaction .
means if i have say a field "Date" which can contain more than one value, <b>but its not a range which has two fields</b> . How is it possible.
Let me know pls.
Regards,
Sirisha.R.S.Hi Satyajit,
I need to call a transaction with multiple values which gives me the report based on those values.
So I need to pass multiple values for a single parameter.
I hope u got it.
Regards,
Sirisha.R.S. -
Passing multiple values to the QUERY BDOC parameter?
hi All,
Below is my Query BDOC Anchor Before Query Execute even handler... I'm trying to pass multiple values to the bq.Z_PartnerFunction query parameter... i.e.
PARTNER_FCT in( '00000012','ZDIVMGR','ZAREADR')
is it possible without creating new Query Bdoc ?
====================================
Private Sub aempchoicewinTCWSearchTAnchor_beforeQueryExecute(ByRef bq As BusinessQuery, ByRef cancel As Boolean)
If Not bq Is Nothing Then
If sWcDummy = "Yes" Then
bq.WcDummy = sWcDummy
End If
bq.Z_PartnerFunction = "00000012"
If ctrlZ_Territory.Value <> "" Then
bq.PRNB_TerrID = "*" & ctrlZ_Territory.Value
End If
End If
End Sub
================================
Thanks in advance
HetalHi,
it looks that you already enhanced the query BDoc because you have a new query parameter bq.Z_PartnerFunction, right?
To which BDoc parameter is this BQ parameter mapped? And how looks the related where clause?
For a single filter normally a "=" operator is used. Therefore your example with "in" won't work.
If these three partner functions are fixed then you might hardcoded them directly in the where clause (supposed the BDoc is not used somewhere else where you don't want to have this filter).
Or you might add 3 new BDoc parameters, add 3 new where clauses using a disjunction for them (and using an embracing bracket). In this case always all these 3 BQ parameters need to be filled (or all stay empty) to avoid a SQL syntax error.
Regards,
Wolfhard -
How to pass input value to the IN parameter in a function
Hi ,
I'm new to pl/sql programming.
The below function is used inside a package and the package is invoked in visual studio.
The function uses 2 input parameters.
Out of which 'in_report_parameter_id' value comes thru job processor service 's job request.
The second IN paramter values are hard coded in the function.
I'm not able to understand this.
If the values are hard coded , how to make sure that only the hard coded values are the right ones?
Please anyone could explain to me?
I really dont have good idea about how to pass INPUT parameter to the functions or procedure
Is there any nice document which could give me good understanding about what are the ways or types we could pass values to the input parameter in subprograms?
thanks in advance.
CREATE OR REPLACE FUNCTION get_class_text_str
in_report_parameter_id IN NUMBER,
in_which IN VARCHAR2 DEFAULT 'SELECT'
RETURN VARCHAR2
IS
end_text VARCHAR2 (50) := '';
my_class_text_str VARCHAR2(10000) := '';
my_class_value_str VARCHAR2(10000) := '';
CURSOR class_text(c_1_text VARCHAR2, c_2_text VARCHAR2) IS
SELECT c_1_text || report_parameters.report_parameter_value
|| c_2_text
|| report_parameters.report_parameter_value
|| '" '
FROM report_parameters
WHERE report_parameters.report_parameter_id = 3690
AND report_parameters.report_parameter_group = 'CLASS'
AND report_parameters.report_parameter_name = 'CLASS'
GROUP BY report_parameters.report_parameter_value
ORDER BY CAST(report_parameters.report_parameter_value AS NUMBER);
BEGIN
IF (in_which = 'SUM') THEN
OPEN class_text ( 'SUM(NVL("Class ', '", 0)) "Class ' );
ELSIF (in_which = 'PERC')THEN
OPEN class_text ( 'ROUND((("Class ', '" / "Total") * 100), 2) "Class ' );
end_text := ', DECODE("Total", -1, 0, 100) "Total" ';
ELSE
OPEN class_text ( 'SUM(DECODE(bin_id, ', ', bin_value, 0)) "Class ' );
END IF;
LOOP
FETCH class_text INTO my_class_value_str;
EXIT WHEN class_text%NOTFOUND;
my_class_text_str := my_class_text_str || ', ' || my_class_value_str;
END LOOP;
CLOSE class_text;
my_class_text_str := my_class_text_str || end_text;
RETURN my_class_text_str;
END get_class_text_str;
/Edited by: user10641405 on Nov 19, 2009 8:16 AM
Edited by: user10641405 on Nov 19, 2009 8:30 AMThis is not a design I would use, but should work if coded properly. I would probably build a reference cursor query as text and use one open fetch and close.
You have 2 input parameters, in_report_parameter_id and in_which. I could not find where in_report_parameter_id was used in the program, but the value passed in for in_which is being used in IF logic to decide how to open the cursor. After the cursor is open rows are being fetched and eventually the cursor is closed.
The values in_which are compared to are hard-coded. It is the programmer's job to make sure the values listed are the right values and the actions taken are also correct. Your program is assuming that if the first 2 values are not encountered the third one listed is the one you want.
To pass input values to a procedure you merely provide the values as a literal or variable in the call, something like
whatever := get_class_text_str(1,'SELECT'); -
About passing multiple values in parameter for oracle report
https://docs.google.com/file/d/0B0dx7wf68mD0QzdpbWU4UGNURTQ/edit
Hi all,
i want to pass multiple value using , to separate them 1,2,3....
here is my query
SELECT DISTINCT
oh.header_id
,oh.org_id
,to_char(oh.ordered_date,'DD-MON-YYYY') d_date
,to_char(oh.ordered_date+31,'DD-MON-YYYY') d_validity
,oh.ship_to_org_id
,oh.invoice_to_org_id
,oh.cust_po_number d_po_num
,rcust.customer_id AS customer_id
,oh.order_number d_salesorder_no
,oh.cust_po_number d_project
,oh.attribute1 second_addr
,oh.attribute2 remark1
,oh.attribute3 remark2
,substr(oh.transactional_curr_code,1,3) as currency
,tyl.name ordertype
,oh.salesrep_id
,rat.name as d_payment_term
,rat.description d_payment_desc
,rsa.name
,rsa.email_address as sales_phone
,rcust.customer_name||' - #'||rcust.customer_number d_to_custname
,rcust.customer_name d_cust_sign
,rcust.attribute1
,rcust.customer_number
-- ,raddr.ship_to_flag
,oh.sold_to_contact_id AS attn_id
,rcust.party_id
,tyl.name AS SO_type
-- ,net_org.ORG_LOGO
FROM
oe_order_headers_all oh
,ra_customers rcust
,ra_addresses_all raddr
,ra_site_uses_all rsite --double_line
,ra_terms rat
,hz_party_sites hps
,hz_contact_points hcp
,ra_salesreps_all rsa
,oe_transaction_types_tl tyl
-- ,apps.ar_contacts_v acv
-- ,net_org
WHERE oh.sold_to_org_id = rcust.customer_id
AND oh.payment_term_id = rat.term_id(+)
--AND rcust.customer_id = acv.customer_id(+)
AND oh.salesrep_id = rsa.salesrep_id
AND oh.order_type_id = tyl.transaction_type_id
AND rcust.party_id = raddr.party_id
AND raddr.address_id = rsite.address_id
AND rcust.party_id = hps.party_id
AND hps.party_site_id = hcp.owner_table_id(+)
AND hcp.owner_table_name(+) = 'HZ_PARTY'
--AND hcp.contact_point_type (+)='PHONE'
AND tyl.LANGUAGE = userenv('LANG')
--AND raddr.ship_to_flag IS NULL
AND upper(tyl.name) in ('SW SALES CONTRACT','SW-NSC SALES CONTRACT','TILES SALES CONTRACT','VBP SAMPLE ORDER', 'VBP INTERNAL ORDER')
AND oh.order_number =:P_CONTRACT_NO
and oh.org_id = :P_ORG_ID
--and net_org.org_id = :P_ORG_ID
&CP_Param
and after para form
function AfterPForm return boolean is
begin
:CP_Param := 'where oh.order_number in ('||:P_CONTRACT_NO||')';
return (TRUE);
end;
it said ora-00933 but my query can run i dont need the multiple values para, can anyone help me how to modify the report so it can pass multipel values thanksHI I tried changing the parameter width to a larger value, it can output , and the field where I show the order_number i used source P_CONTRACT_NO,
it will display as 102005000,102005001 and I also tried using the column from the query directly, it will be separated , it has some other problem
I have the header part and main part,
and also there are page numbering, with the order number field set as order_number it will output single number , but the page order is wrong
102005000,102005001 will be like header page: 102005000 1/4 102005001 2/4, main page 102005000 3/4, 102005001 3/4
DO you have any idea how I can set the page numbering setting so it will output as header page:102005000 1/2 102005000 2/2
header page:102005001 1/2 102005001 2/2
?? thanks -
How can i pass multiple values by a single variable to EXECUTE IMMEDIATE
Hi All,
I want to pass multiple values for where condition for execute immediate. Something Like this:-
bold
Declare
v_cond varchar(1000);
Begin
v_cond := '''INR','USD'''; --(OPTION 1)
v_cond := 'INR,USD'; --(OPTION 2)
EXECUTE IMMEDIATE 'Delete from table where colm in (:v_cond)' using v_cond;
END;
bold
I am using this into a procedure
Now option 1 gives an error ie a syntax error (; expected or something like that)(I am sorry, i can't tell the exact error here as i am not in the office right now)
and option 2 makes the procedure execute but obviously doesn't delete the records, as it takes the whole as one.
Please Help
Regards
Neeraj BansalSee the links containing examples under
*7. List of values in an IN clause?*
SQL and PL/SQL FAQ
from the SQL and PL/SQL FAQ. -
How to passing multiple values for a parameter of discoverer(url parameters
Hi All,
I am trying to pass multiple values for a parameter of disco report. I am trying to include my url for discoverer viewer report. the values has the following
'jeff,mark'
'sfophiee,angela'
Thanks and Regards
VenkatHello Venkat,
I know there are some problems with 10.1.2.0.2, maybe if you haven't done yet you can try with 10.1.2.2, assuming this version should be working for multiple parameter values :
OracleAS Discoverer 10.1.2.2 is installed with the following patch :
Patch 4960210 PLACEHOLDER BUG FOR AS/DS 10G R2 PATCH SET 2 10.1.2.2
So, once installed you can try adding your parameter as param_<parameter_name>='sfophiee,angela'
Hope this helps, otherwise feel free to log a Service Request to Support.
Best Regards,
Gianluca -
Passing Multiple Values from Multi Select
Hi,
My requirement is simple. I have created a simple Multi Select Option in parameter form and i want to send multiple selected values from the multi select option (in parameter form) to reports.
eg:
I want to send multiple countries code as input .........'US', 'CA', 'IND', 'UK'
Can i do it in Oracle 6i reports, Thanks in Advance.
Regards,
AsgarHi Thanks Again,
For such a nice response. I got the Lexical Where condition properly running but still getting problems in catching the multiple values to be passed from form. just i will give u an insight of wat i have done:
SQL:
SELECT ALL FROM EMPLOYEES &cond_1* -- Working FIne
in my Html Parameter Form i have an Multi Select component (the Problem is here) it is not passing more than i value from the form once i am accessing it from web or running it in paper report. In paper report layout it is not allowing me to select more than one value. but in HTML it is allowing to select multiple values but at the server end (After Parameter Form Trigger) it is giving a single value not multiple values.
In PL/SQL when i checking the length of country_id i m getting it as one.
Here is my SQL code
srw.message(10, LENGTH(:country_id_1));
:cond_1 := 'where country_id = '''|| :country_id_1 ||'''';
This is passing the condition properly to SQL but only with single value but i want to pass multiple values
I am struck in this+_
WHERE CONTRY_COLUMN IN ('USA','UAE') -- This variable you have to pass from you form...
Here as you said you gave multiple selection in your parameter form to generate report. So before generation report just prepare variable like this as it is bold above.
and pass parameter through your runtime form to the report as you pass the normal parameter...liket this i gave you example...
ADD_PARAMETER(PARAMETER_LIST_NAME,'P_CONT_PARAM',TEXT_PARAMETER,vString);
Sorry for troubling you for a small thing but please help me to solve this issue.
Thanks Again............
Asgar. -
How can I pass Recordsets as input parameter to a Function ?
Hi Gurus,
I want to create a function that receive recordsets as input parameter also returns recordsets as output.
I have a requirement to do stock taking for all order items of one Order number in one single query execution (to avoid row by row basis).
From the post in the forum I know that a function can return recordsets / query result using REF CURSOR or pipelined table function.
My question is : how to pass the recordsets as input parameter to that function ?
(because I could have 75 rows item in one order number)
Below is the DDL and the query :
create table stocks (Product char(4), Warehouse char(5), expireddate date, qty_available number)
insert into stocks values('P001', 'WH001', '01-dec-2006', 30)
insert into stocks values('P001', 'WH002', '01-dec-2006', 50)
insert into stocks values('P001', 'WH002', '01-jan-2007', 50 )
insert into stocks values('P001', 'WH001', '01-Mar-2007', 150)
insert into stocks values('P002', 'WH003', '01-dec-2006', 25)
insert into stocks values('P002', 'WH003', '15-Jan-2007', 50)
insert into stocks values('P002', 'WH003', '01-Mar-2007', 75)
insert into stocks values('P003', 'WH001', '01-dec-2006', 30)
insert into stocks values('P003', 'WH002', '15-Jan-2007', 40)
insert into stocks values('P003', 'WH003', '01-Mar-2007', 50)
CREATE TABLE Order_Detail (PRODUCT_ORD CHAR(4), QTY_ORD number, Priority_WH CHAR(5) )
INSERT INTO Order_Detail VALUES ('P001', 75, 'WH003') // previously 'WH002'
INSERT INTO Order_Detail VALUES ('P002', 45, 'WH002')
INSERT INTO Order_Detail VALUES ('P003', 55, NULL)
The query for stock taking :
select product,warehouse,expireddate, least(qty_available-(sm - qty_ord),qty_available) qty
from ( select product,warehouse,expireddate,qty_available,qty_ord, sum(qty_available) over(partition by product order by s.product,expireddate,decode(warehouse,priority_wh,0,1),warehouse ) sm
from stocks s,order_detail o
where s.product = o.product_ord order by s.product,expireddate,decode(warehouse,priority_wh,0,1) )
where (sm - qty_ord) < qty_availableHi,
This my requirement :
I have (simplified)Order_Detail as below :
CREATE TABLE Order_Detail (PRODUCT_ORD CHAR(4), QTY_ORD number, Priority_WH CHAR(5) )
INSERT INTO Order_Detail VALUES ('P001', 75, 'WH003') // previously 'WH002'
INSERT INTO Order_Detail VALUES ('P002', 45, 'WH002')
INSERT INTO Order_Detail VALUES ('P003', 55, NULL)
Then I want to do stock taking from my STOCK table (described on my first post on this thread)
create table stocks (Product char(4), Warehouse char(5), expireddate date, qty_available number)
The rule is : The stok taking is on First In First Out basis, on expireddate.
And I want to do it in single query.
I want to make this a Function / Stored Procedure so that other transaction can also make use of this query.
That is why I need to pass the 3 rows oy mr Order_Detail above, do the query, and return the result.
Then INSERT the result into ORDER_DETAIL_PER_EXPIRED_DATE table.
I hope this clear my requirement, is this possible ?
Thank you,
xtanto
Maybe you are looking for
-
PC to Mac: Transferring music NOT WORKING!!!!!!
hello! perhaps i've been staring at this new wonderful new mac for too long, but i CANNOT seem to transfer my iTunes library from my PC to my new Mac. i followed ALL the instructions from the apple website (http://support.apple.com/kb/HT1329). on my
-
PO vendor partner role through ALE/IDOCs
We have ALE/IDOC interface with vendor. The requirement is PO will be sent to the ordering vendor and invoice should be received with PI vendor. We are using stardard message types for purchase order (outbound) and INVOIC (inbound). Could you please
-
Hi, Please can any one explain the advantages between Adobe Forms vs flex. I've to implement website and forced to use any one of the above mentioned technologies to represent UI. Appreciate your quick reply. Regards Boss Listen
-
In the capacity section of the iTunes application as it related to content on the iPhone. Can anyone tell me what information is stored in the "OTHER" catagory and how can I see what this information is. It says that I have 6gb of other information i
-
IMac 27 "screen out of control, I am experiencing the transition to sleep mode.
The following general specifications of the devices have experienced periodic shortages is this. 27-inch, Late 2009 CPU 2,66 GHz Intel Core i5 RAM 8 GB 1067 MHz DDR3 Graphic Card ATI Radeon HD 4850 512 MB Serial Number xxxxxxxxxxx OS X 10.8.5 (12