Need SQL for this simple logic..
Hi,
I have a select statement
select msi.segment1,micv.CATEGORY_SET_NAME from
MTL_system_ITEMs msi, MTL_ITEM_CATEGORIES_V micv where msi.INVENTORY_ITEM_ID = micv.INVENTORY_ITEM_ID
and msi.ORGANIZATION_ID = 853 and msi.ORGANIZATION_ID = micv.ORGANIZATION_ID and
msi.segment1 = 'C0005'
which gives me output
segment1 CATEGORY_SET_NAME
C0005 Country Of Origin
C0005 HS COMMODITY
C0005 Inventory
C0005 MFG PLANT
C0005 Order Management Categories
C0005 Purchasing Categories
C0005 Sales and Marketing
I have another select statement
which gives me output
segment1 CATEGORY_SET_NAME
C2601ZE Inventory
C2601ZE Sales and Marketing
C2601ZE Purchasing Categories
C2601ZE Order Management Categories
C2601ZE MFG PLANT
Where there are 2 rows missing for part C2601ZE from 2nd select
I want output like below for 2 missed rows which are from 2nd select
segment1 CATEGORY_SET_NAME
C2601ZE Country Of Origin
C2601ZE HS COMMODITY
MINUS is working but its working only for segment1 not for set_name
Thanks in Advance
Devender
select msi.segment1,micv.CATEGORY_SET_NAME
from MTL_system_ITEMs msi, MTL_ITEM_CATEGORIES_V micv
where msi.INVENTORY_ITEM_ID = micv.INVENTORY_ITEM_ID
and msi.ORGANIZATION_ID = 853
and msi.ORGANIZATION_ID = micv.ORGANIZATION_ID
and msi.segment1 = 'C2601ZE'
and micv.CATEGORY_SET_NAME not in (
select micv.CATEGORY_SET_NAME
from MTL_system_ITEMs msi, MTL_ITEM_CATEGORIES_V micv
where msi.INVENTORY_ITEM_ID = micv.INVENTORY_ITEM_ID
and msi.ORGANIZATION_ID = 853
and msi.ORGANIZATION_ID = micv.ORGANIZATION_ID
and msi.segment1 = 'C0005');
(Not Tested)
Similar Messages
-
Need pl/sql stmnts. for this simple logic
Hi,
I need PL/SQL program for this simple logic i am doing mistake somewhere unbale to trace
out ..
select * from GSR03_PO_DTL;
PO_NUM
L53177000 -- > no changes reqd (only one entry with new format)
L00041677 --> to be updated to L41677000(only one entry with OLD format)
L43677000 -- > no change reqd (exists one row with new format and old format like below)
L00043677 -- > to be deleted this is old format (and new format like above already exists)
EX:
L00012345 --- old format
L12345000 --- new format
Hope question is clear. I written the following program.
update is working fine but delete is not working.
Please help.
Thanks in Advance
Devender
declare
Cursor c_test is
(select po_num from GSR03_PO_DTL);
BEGIN
FOR r_test in c_Test
LOOP
dbms_output.put_line (r_test.po_num);
IF ('L'||substr(r_test.po_num,5,5)) = ('L'||substr(r_test.po_num,2,5)) then
dbms_output.put_line ('delete stmnt');
END IF;
EXIT WHEN c_test%NOTFOUND;
END LOOP;
FOR r_test in c_Test
LOOP
IF r_test.po_num like 'L000%' then
IF ('L'||substr(r_test.po_num,5,5)) is not NULL then
update GSR03_PO_DTL set PO_NUM = 'L'||substr(po_num,5,5)||'000'
where po_num like 'L000%' ;
dbms_output.put_line ('update stmnt');
END IF;
END IF;
END LOOP;
END;
*********************No need for PL/SQL, man.
SQL> SELECT po_no FROM po1
2 /
PO_NO
L53177000
L00041677
L43677000
L00043677
SQL> UPDATE po1 y
2 SET y.po_no = 'L'||substr(y.po_no,5,5)||'000'
3 WHERE y.po_no LIKE 'L000%'
4 AND NOT EXISTS ( SELECT null FROM po1 x
5 WHERE x.po_no = 'L'||substr(y.po_no,5,5)||'000')
6 /
1 row updated.
SQL> DELETE FROM po1 y
2 WHERE y.po_no LIKE 'L000%'
3 AND EXISTS ( SELECT null FROM po1 x
4 WHERE x.po_no = 'L'||substr(y.po_no,5,5)||'000')
5 /
1 row deleted.
SQL> SELECT po_no FROM po1
2 /
PO_NO
L53177000
L41677000
L43677000
SQL> Cheers, APC -
pls i need help for this simple problem of my palm os zire 72. pls share your ideas with me.... i tried to connect my palm os zire72 in my desktop computer using my usb cable but i can't see it in my computer.. my palm has no problem and it works well. the only problem is that, my desktop computer can't find my palm when i tried to connect it using usb cable. is thier any certain driver or installer needed for it so that i can view my files in my palm using the computer. where i can download its driver? is there somebody can help me for this problem? just email me pls at [email protected] i really accept any suggestions for this problem. thanks for your help...
If you are using Windows Vista go to All Programs/Palm and click on the folder and select Hot Sync Manager and then try to sync with the USB cable. If you are using the Windows XP go to Start/Programs/Palm/Hot Sync Manager and then try to sync. If you don’t have the palm folder at all on your PC you have to install it. Here is the link http://kb.palm.com/wps/portal/kb/common/article/33219_en.html that version 4.2.1 will be working for your device Zire 72.
-
Hi,
Below is my table with columns like a,b,c
a b c
1 null null
null 2 null
null null 3
I need output like a b c
1 2 3Hi,
Here's one way
SELECT MIN (a) AS a
, MIN (b) AS b
, MIN (c) AS c
FROM my_table;
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Point out where the query above is giving the wrong results, and explain, using specific examples, how you get the correct results from the given data in those places. If you changed the query at all, post your code.Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Hi Gurus
I have below situtation which need to be sorted out by SQL (10g version)
Below is the sample data.
Date Amt1 Amt2 Amt3 Totl
201009 10 10 10 30
201010 20 20 20 90
201011 30 20 10 150
Totl is the calculation field and remaining data is available in DB table say tab1. If you see logic of identifying Totl --> addition of Amt1,Amt2,Amt3 with Totl of prev month. For 201010 it is 20+20+20 =60 and this 60 will need to added to 201009 totl 30 and hence final sum is 90.
Please provide to resolve this.You need to do cumulative sum.
with t
as
select 201009 dt, 10 a1, 10 a2, 10 a3 from dual union all
select 201010, 20, 20, 20 from dual union all
select 201011, 30, 20, 10 from dual
select dt, a1, a2, a3, sum(a1+a2+a3) over(order by dt) tot
from t -
Internal Error - Unable to generate SQL for this Scheduled Workbook
I am encountering the following error when loading the results of a Scheduled Workbook;
Internal Error - Unable to generate SQL for this Scheduled Workbook (If you scheduled this workbook using a previous version of Discoverer, please reschedule and re-open)
This only happens for one of the scheduled workbooks and I am struggling to find an explanation to the problem. There are no reference to database links in the workbook so I can rule that out as a cause.
Does anyone have any suggestions to what might be causing the problem?
Many thanks
StewartHi,
The version is OracleBI Discoverer Plus Version 10.1.2.48.18. Do you think this has anything to do with it?If you are on this version, then you have the recommended patches applied.
Did you try to reschedule the workbook and see if this helps in resolving the issue?
I would suggest you enable server logging as this may help in collecting more details about the error.
Note: 403689.1 - How To Generate Discoverer 10g (10.1.2) Session Server Logs In Text Format
https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=403689.1
Regards,
Hussein -
Hi
I need a procedure 4 this logic,
Need to get 32+ inputs in procedure of same type varchar2,
If comp_id !=360
insert 32 inputs in table column-> value using custom-id
Note:
Column : brand-code,value,custom_name using custom_id
brand-code gets from comp-id from another table
i/p- from procedure comp_id and 32 inputs
This 32 inputs should use varray cocept
end if;
ex:
table 1
brand_code custom-id value editble
table 2
custom-id custom-name
Could you please share ur suggestionsCreate or replace procedure cdm_cl_proc is
v_sqnum number(3);
cursor c1 is
select dcn, pp_code from d_cl_ext;
Cursor c2 is
Select t_code, s_date, area_chrg, rc_pct from d_c_p_ext;
Begin
for v1 in c1
Loop
update d_cl set pp_code = v1.pp_code
where dcn=v1.dcn;
select d_sqnum into v_sqnum from d_cl
where dcn=v1.dcn;
For v2 in c2
Loop
Update d_c_p set area_chrg= v2.area_chrg, rc_pct=v2.rc_pct
Where t_code= v2.t_code and s_date = v2.s_date
and d_sqnum = v_sqnum;
if mod(c2%rowcount,1000)=0 then
commit;
end if;
End loop;
if mod(c1%rowcount,1000)=0 then
commit;
end if;
End loop;
Commit;
End;
I amable to load the data when dcn is matched but, if the dcn is not matched no data found error is coming. can u suggest error handling for this. -
Hi,
I need sequence for autogenerate of code
Table 1
id code
We need to autogenerate code for every new entity of id
ex:
id code
sbi sbi001
hsb hsb002
xyz xyz003
And
ex:
id code
sbi s001
hsb h002
xyz x003You can use a Sequence and Trigger in combination like this
create table t
id varchar2(10)
, code varchar2(25)
create sequence t_seq;
create or replace trigger t_trig before insert on t for each row
declare
l_seq integer;
begin
select t_seq.nextval into l_seq from dual;
:new.code := :new.id || to_char(l_seq, 'fm099');
end;
insert into t (id) values ('sbi');
insert into t (id) values ('hsb');
insert into t (id) values ('xyz');
select * from t; -
What is a efficient SQL for this query ?
Hi,
I am using 9.2 database. Suppose I am having following 2 tables
Table p having only one column i.e. 'a'. Values in this column are
a1
b1
c1
d1
Table Q having three columns a, b, c
a1, 1, 100
a1, 2, 50
b1, 1, 30
b1, 2, 40
d1, 2, 90
Table Q can be joined only using column a.
Table Q can have multiple or no records for column a in table p. Based on above sample data, I want following output
a1, 100, 50
b1, 30, 40
c1
d1, 90
Kindly tell be how can I achive this in most efiicient way !!!
thanks & regards
PJPI only have you two tracks about how do it.
If you want all the columns from p with or wihout q you have to do:
11:35:58 SQL> l
1 select p.*, q.*
2 from p,q
3* where p.a = q.a (+)
11:37:27 SQL> /
For change the order of the colums for rows you can see the url, the are more examples like that only need to search "columns for rows" in this forums.
Anyway:
with rt as
select 'a1' a, 1 b, 100 c from dual union
select 'a1', 2, 50 from dual union
select 'b1', 1, 30 from dual union
select 'b1', 2, 40 from dual union
select 'd1', 2, 90 from dual)
--select * from rt
select a, decode('1','0','0',rtrim(xmlagg(xmlelement(b, b || ',')).extract('//text()'),',')) b
, decode('1','0','0',rtrim(xmlagg(xmlelement(c, c || ',')).extract('//text()'),','))
from rt
group by a
Message was edited by:
cth
Other way:
select a, ltrim(b,',') as b, ltrim(c,',') as c
from (
select row_number() over (partition by a order by length(b) desc) as rn, a, b,c
from (select a, sys_connect_by_path(b, ',') as b,
sys_connect_by_path(c, ',') as c
from (
select row_number() over (partition by a order by b) as rn, a, b,c
from rt) y
connect by rn = prior rn + 1 and prior a = a
start with rn = 1
where rn = 1
Message was edited by:
cth -
How to create workflow for this simple scienerio
HI Gurus,
I have to create a simple workflow. But I have a problem what the object type I have to choose.
Scenerio of the workflow is ..
This workflow gets pernr and benefit plan information from portal.
this workflow is a one step approval mail
In the workflow three steps are there.
In the first step i have to derive basic hourly salary of the person by using infotype --- 008 and company code for the pernr from the 0001 and benefit plan he enrolled
Second step ---
there are two company codes, I have to use condition step,
if one company code I have to send to one hr department mail for approval
and the other for another hr department step.
in the workitem i have to pass salary information, pernr information.
third step, after approval I have to update the respective infotype.
My question is for the above scenerio, what object type I have to use.
For the first step is there any method I have to create which calls function module.
if so for which object type i have to add method.
third how do I create the workflow container for this.
I am new to workflow. I know scenerio is simple but I dont know how to do it.
Please help me friends.
Ravithink you should create your own Business Object or you can refer to Business Object EMPSALPACK.
Now Company Code should be an Attribute that you should do the Coding For.
Use this attribute in the Condition Step of Workflow Template.
Workflow Container will contain the Business Object that you will be creating. The Business object should have Key Field Pernr and may be anything relevant that you will do for Coding. I think you might have to trigger the Event of the Business Object through code.
Check the Code below.
<b>Reward Appropriate Point if useful</b>
INCLUDE <cntn01> .
DATA:i_emp_details TYPE STANDARD TABLE OF p0001, "Employee Details
wa_request TYPE p0001, "Workarea for Employee details
v_country_grp TYPE molga, "Country SubGrouping
v_object_key TYPE sweinstcou-objkey. "Key for the buisness object ZWOBUSTRIP
CONSTANTS: c_bo_trip TYPE swo_objtyp VALUE 'ZWOBUSTRIP',
c_event_trip TYPE swo_event VALUE 'TripCreate',
c_infy_type_1 TYPE infty VALUE '0001'.
Event Container declaration
swc_container i_event_cont.
swc_create_container i_event_cont.
Reading the INFO TYPE 0001 to obtain the
Employee details
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = i_emp_number
infty = c_infy_type_1
begda = sy-datum
endda = sy-datum
TABLES
infty_tab = i_emp_details
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
SY-SUBRC check is not required as the error
handelling will be done by WorkFlow rule
resolution.
CLEAR wa_request.
READ TABLE i_emp_details INTO wa_request INDEX 1.
IF sy-subrc = 0.
Retrieving the Country SubGrouping for the employee
SELECT SINGLE molga
FROM t001p
INTO v_country_grp
WHERE werks = wa_request-werks
AND btrtl = wa_request-persk.
ENDIF.
Sending the relevant data to event container
swc_set_element i_event_cont 'EmpId' i_emp_number.
IF sy-subrc <> 0.
No Processing needed.
ENDIF.
swc_set_element i_event_cont 'PersonnelArea' wa_request-werks.
IF sy-subrc <> 0.
No Processing needed.
ENDIF.
swc_set_element i_event_cont 'CountryGrouping' v_country_grp.
IF sy-subrc <> 0.
No Processing needed.
ENDIF.
swc_set_element i_event_cont 'EmpSubGrp' wa_request-persk.
IF sy-subrc <> 0.
No Processing needed.
ENDIF.
swc_set_element i_event_cont 'EmpTripId' i_emp_trip.
IF sy-subrc <> 0.
No Processing needed.
ENDIF.
Raising the event to trigger the workflow
v_object_key = i_emp_number.
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = c_bo_trip
objkey = v_object_key
event = c_event_trip
TABLES
event_container = i_event_cont
EXCEPTIONS
objtype_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
No Processing needed.
ENDIF.
COMMIT WORK.
ENDFUNCTION.
Thanks
Arghadip -
Need SQL for below scenerio .
Hi Experts,
Consider an Order Table with the following table structure with some Sample Data:
ORDER_DAY
ORDER_ID
PRODUCT_ID
QUANTITY
PRICE
01-JUL-11
O1
P1
5
5
01-JUL-11
O2
P2
2
10
01-JUL-11
O3
P3
10
25
01-JUL-11
O4
P1
20
5
02-JUL-11
O5
P3
5
25
02-JUL-11
O6
P4
6
20
02-JUL-11
O7
P1
2
5
02-JUL-11
O8
P5
1
50
02-JUL-11
O9
P6
2
50
02-JUL-11
O10
P2
4
10
Need SQL to get all products that got sold both the days and the number of times the product is sold.
Desired output :
PRODUCT_ID
COUNT
P1
3
P2
2
P3
2
Thanks and Regards,
Sumanth KulkarniHi,
SumanthKulkarni wrote:
Hi
I tried below approach , but i didnt get desired output for P1
select count(s) a,product_id from
(select count(product_id) s,order_day ,product_id from orders group by order_day,product_id
order by product_id asc) t
group by product_id
having count(s) >1
Thanks and Regards
Sumanth Kulkarni
Run the sub-query by itself, and look at the results. You should see something like this:
S ORDER_DAY PRODUCT_ID
2 01-JUN-2011 P1
1 02-JUN-2011 P1
1 01-JUN-2011 P2
When you're computing the column a for the final output, do you want to count how many rows of this result set have product_id='P1'? That's what COUNT does, but I don't think that's what you want.
Do you want to add up the numbers in the S column? Then use SUM (s), not COUNT (s).
You could also do the whole job without a sub-query, like this:
SELECT COUNT (*) AS a
, product_id
FROM orders
GROUP BY product_id
HAVING COUNT (DISTINCT order_day) > 1 -
Need Sql for terda data database
Can any one help send me the sql for teradata database. for creating the variables. I need to create variables for Last month begin date and last month end date.
I am trying this tera data Sql this is for curent month date.
select cast(current_date as date) - (extract (day from cast(current_date as date)) - 1) + interval '1' month - 1
I need tera data sql for Last month begin date and last month end date. I searched various forums but could not get the answer. Any suggesstions please. -
Is there a way to create a schema for this simple XML?
Hi! A simple question. Suppose we have a XML that looks like that (simplified)
<documents>
<total>2</total>
<doc_1>
<name>My document</name>
<code>1234</code>
</doc_1>
<doc_2>
<name>Another document</name>
<code>5678</code>
</doc_2>
</documents>In this simple example, if the tag <total> had a numer of three, there would be a <doc_3> tag.
Is it posible to create a XSD to this XML? And is it posible for JAXB to process that XSD?
Thank you in advanceThere are some tools around to generate XML Schemas from instance documents, but I don't know if they are too smart. For example, XMLSPY created the following Schema from your sample:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="code">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="1234"/>
<xs:enumeration value="5678"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="doc_1">
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="code"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="doc_2">
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="code"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="documents">
<xs:complexType>
<xs:sequence>
<xs:element ref="total"/>
<xs:element ref="doc_1"/>
<xs:element ref="doc_2"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Another document"/>
<xs:enumeration value="My document"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="total">
<xs:simpleType>
<xs:restriction base="xs:byte">
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>XMLSPY has done its best but this Schema could certainly be cleaned up and made more efficient. If your instance documents aren't going to be too complex, it's probably best to have a tool like XMLSPY start you off, then you can go in by hand.
But, once you have the Schema in hand, you're ready to get started with JAXB. -
Need code for this Small validation on when-validate-item
Hi All,
I have a text item(date datatype) in forms 4.5 I need to do a small validation want to write on when-validate-item. When I enter a date in that text item (Ex 10-JUN-2005) it has to check
1) It Cannot be "blank"
2) It cannot be "Not older than today"
can you please put me code for this small validation. I am new to Forms.
Thanks in Advance,
ReddyI always put code in the when-validate-RECORD trigger to ensure fields are entered, rather than setting the property. That way, the user can enter other fields within the record, and then gets a message that the field is required only when leaving the record.
...of course, if the date item is the only field in the block, then the when-validate triggers will not run unless the user at least types a space in the date. In that case, you need to check in the key-commit trigger. -
How to write complex sql for this
Hi ALL,
I have a requirement like this
I have 5 tables which i have to join to get the result
but there no join column to 2 other table.
I want to get all the applications using cobal,running on UNIX.
How to write the query for this
1.APP
APP_i DESC
1 Accounts
2 Payments
3 order transfer
4 Order processing
2.Techgy
techid techdesc
1 cobal
2 Java
3.APP_Techgy
APP_I Techid
1 1
2 1
3 1
4 2
4.Pltfrm
pltfmid pltfrmdesc
1 Windows NT
2 UNIX
5.APP_Pltfrm
APP_I pltfrmid
1 1
2 1
3 2
4 2
ouput must be
APP_i Desc techDESC pltfrmdesc
3 ordertranfer Cobal UNIX
Thanks in advanceThis ('descr' in place of 'desc')?
SQL> select a.app_i, a.descr, t.techdesc, p.pltfrmdesc
from app_techgy atc,
app a,
techgy t,
app_pltfrm ap,
pltfrm p
where atc.techid = t.techid
and atc.app_i = a.app_i
and atc.app_i = ap.app_i
and ap.pltfrmid = p.pltfmid
order by a.app_i
APP_I DESCR TECHDESC PLTFRMDESC
1 accounts cobal windows nt
2 payments cobal windows nt
3 order transfer cobal unix
4 order processing java unix
4 rows selected.
Maybe you are looking for
-
Use the value of a field as column-name of a dynamic table
Hi All I have the following situation: a) Internal table TB_ORDER_CONDITION ==> data: tb_order_condition type standard table of bapicond. sample of the internal table TB_ORDER_CONDITION: CONT_TYPE # CONDVALUE# CONDBASEVAL ZR00 #
-
I'm trying to configure my HDTV (CRT 720p/1080i) as a second display, mostly for use with Front Row and XBMC for OSX. I'm using a DVI-to-HDMI cable as a connector and upon the first use, Leopard decided upon the appropriate resolution for the TV (192
-
Utilising Migration assistant as part of SOE deployment
Just wondering if anyone has used MA in this way ? I have 90 machines to take to 10.4 and CS2 and a bunch of other apps but need to retain as many existing settings and files as possible to make the deployment easy ( not a nightmare ! )... Initial id
-
Hi, i've recorded some videos on my nano, but i can't see them when i connect to itunes.... any ideas?
-
OMS Config Assistant fails with OUI-25031
Hello, I am trying to install OEM 10.2.0.1 GC on a Solaris 5.10 (Solaris 5.9 too) box, using an existing DB which is a 10.1.0.4 on HPUX Itanium 11.23. It keeps failing with OUI-25031 at the OMS Config. Assistant. I have tried all the suggestions: - S