Copying data from excel(more than one row) and pasting into table control
I have a requirement to copy data from excel and have it pasted it into the corresponding fields table control when the user clicks on an icon.For the first part I used a class to copy it from the clip board.By the previous process,I get the data inside an internal table, but even after trying to split the data using 'split at cl_abap_char_utilities=>horizontal_tab into table itab.' it's not working.The table and the excel file are of the same structure.
Does anyone know any cause as to why it might not work?Is there any other way to achieve my objective?
Bon
Hi,
try to get data into internal table as below
TYPES : BEGIN OF ty_data ,
zbukr TYPE payr-zbukr ,
hbkid TYPE payr-hbkid ,
hktid TYPE payr-hktid ,
rzawe TYPE payr-rzawe ,
chect TYPE payr-chect ,
laufd TYPE reguh-laufd ,
laufi TYPE reguh-laufi ,
lifnr TYPE reguh-lifnr ,
vblnr TYPE reguh-vblnr ,
rwbtr TYPE reguh-rwbtr , "uncommented
unique_no TYPE char13 , " Added SAP Doc. No. and current year concate in NEFT,RTGS and Fund Transfer cases
END OF ty_data .
DATA : wa_file LIKE LINE OF it_file ,
wa_data TYPE ty_data .
DATA: it_data1 TYPE kcde_intern WITH HEADER LINE,
wa_data1 LIKE LINE OF it_data1.
start-of-selection.
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = lv_file1
i_begin_col = '1'
i_begin_row = '4'
i_end_col = '11'
i_end_row = '60000'
TABLES
intern = it_data1
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc = 0.
PERFORM format_data.
ENDIF.
FORM format_data.
DATA : ld_index TYPE i.
FIELD-SYMBOLS : <fs>.
DATA it_tab LIKE wa_data OCCURS 0 WITH HEADER LINE.
LOOP AT it_data1.
MOVE it_data1-col TO ld_index.
ASSIGN COMPONENT ld_index OF STRUCTURE
it_tab TO <fs>.
MOVE : it_data1-value TO <fs>.
MOVE it_data1-value TO p_table.
AT END OF row.
APPEND it_tab.
CLEAR it_tab.
ENDAT.
ENDLOOP.
it_data[] = it_tab[] .
ENDIF.
endform. "format_data
Similar Messages
-
How to insert more than one row in an Oracle table in one go
Hi All,
I am working on a file-XI(BPM)-Oracle scenario.
I am sending an xml file to XI via a file adapter. On the receiver end i am using a jdbc adapter to insert the row in the database. There is a transformation step within the BPM which is converting the file to a format understood by the JDBC adapter.
The problem i am facing is that, even if my input xml file contains more than one recordset, only one row is created in the database with the first recordset.
How can i insert all the other recordsets in the database at the same time.
Pls guide
Thanks in advance.
Regards
NeetuHi,
As asked by Bhavesh, i set the occurence of the STATEMENT tab 1 to UB. But still only one row is getting updated in the database at a time.
As asked by Udo, i even tried the same by changing the occrence of ACCESS tab 1 to UB. But still same thing happened.
Can there be some other problem.
The transformation is being dane in the BPM.
As seen in SXMB_MONI, the input xml to the BPM has two RECORDSET tags but the output generated xml in the format understood by jdbc adapter has a single STATEMENT tag.
The two formats are given below
<b>Input:</b>
<?xml version="1.0" encoding="utf-8"?>
<ns:MT_Test_File xmlns:ns="http://namespace-EmpNumberGen">
<EmpGenRecord>
<APPLICANT_NO>20</APPLICANT_NO>
<FIRST_NAME>abc</FIRST_NAME>
<LAST_NAME>xyz</LAST_NAME>
<FUNCTION>ADMIN</FUNCTION>
<DESIGNATION>ZA</DESIGNATION>
<RESPONSIBILITY_LEVEL>dd</RESPONSIBILITY_LEVEL>
<RECRUITMENT_TYPE>dd</RECRUITMENT_TYPE>
<EMPLOYEE_TYPE>p</EMPLOYEE_TYPE>
<STATUS>A</STATUS>
<***>M</***>
</EmpGenRecord>
<EmpGenRecord>
<APPLICANT_NO>14</APPLICANT_NO>
<FIRST_NAME>abc</FIRST_NAME>
<LAST_NAME>xyz</LAST_NAME>
<FUNCTION>ADMIN</FUNCTION>
<DESIGNATION>ZA</DESIGNATION>
<RESPONSIBILITY_LEVEL>dd</RESPONSIBILITY_LEVEL>
<RECRUITMENT_TYPE>dd</RECRUITMENT_TYPE>
<EMPLOYEE_TYPE>p</EMPLOYEE_TYPE>
<STATUS>A</STATUS>
<***>M</***>
</EmpGenRecord>
</ns:MT_Test_File>
<b>Output</b>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Emp_No_Generation xmlns:ns0="http://namespace-EmpNumberGen">
<Statement>
<SAP_EMPGEN action="INSERT">
<access>
<APPLICANT_NO>20</APPLICANT_NO>
<FIRST_NAME>abc</FIRST_NAME>
<LAST_NAME>xyz</LAST_NAME>
<FUNCTION>ADMIN</FUNCTION>
<DESIGNATION>ZA</DESIGNATION>
<RESPONSIBILITY_LEVEL>dd</RESPONSIBILITY_LEVEL>
<RECRUITMENT_TYPE>dd</RECRUITMENT_TYPE>
<EMPLOYEE_TYPE>p</EMPLOYEE_TYPE>
<STATUS>A</STATUS>
<***>M</***>
</access>
</SAP_EMPGEN>
</Statement>
</ns0:MT_Emp_No_Generation>
This is a bit urgent.
Pls help
Regards
Neetu -
MacBook Pro Community,
I need help. After a recent systems update this week, I can not longer copy and paste text from the internet. I have never had this problem before. I have searched through systems preference and google'ed it. Please help!!
Thank you!A book is a lot of work and in the end needs to not only be openable, printable, but also be laid out with facing pages amongst other numerous desirable features.
None of which suggest Pages 5 to me.
If you want to persist in Pages 5.5 you will have to laboriously cut and paste the content into one file and hope that will still be usable when you are finished.
Or you could export to Pages '09 or pdf format and assemble it there.
Peter -
Using a ommand to generate more than one row of data in utl file
Hi Guys
This might be a pretty long one. But I require help with regards to using outer and inner loops within my code.
Here is the task:
Each account involved with the DCA Allocation has an entry in the DCAACCOUNTALLOCATION table to track its progress. The STATUS value of the entry shows the position of the account in the DCA Allocation process.
The status entry being tested is 3.
Below is the code:
create or replace
PROCEDURE DCA_BMW_OUT
IS
-- Declare all variables as reference
v_out_file UTL_FILE.FILE_TYPE;
v_row_Count NUMBER;
r_bmw NUMBER;
v_out_directory all_directories.directory_path%type;
v_out_filehandle UTL_FILE.FILE_TYPE := NULL;
v_out_buffer varchar2 (32767);
v_records NUMBER;
body_output varchar2(32759 BYTE);
dictionary_guarantorsexist varchar2 (1 Char);
-- Text required within this part of the procedure
v_body varchar2(32767 BYTE);
v_header VARCHAR2(32759 BYTE);
BEGIN
FOR r_bmw IN
( SELECT *
FROM dcaadditionaldata
WHERE directory_name IS NOT NULL
) LOOP
BEGIN
-- Output file to be added into the directory specified
v_out_file := utl_file.fopen (r_bmw.directory_name, 'DCAExport_1_' || TRIM(TO_CHAR(SYSDATE,'DDMMYYYY_HH24MISS')) || '.txt', 'W');
-- The Header data which will be outputted to the file
v_header := 'KennzeichenBrgschaftsforderungGesamtforderung|Währung|Übergabedatum|DifferenzierungAnwalts-oderInkassofall|MainMarktpartnernummer|
MainAnrede|MainTitel|MainName|MainVorname|MainStraße|MainHausnummer|MainPLZ|MainOrt|MainLand|MainGeburtsdatum|MainTelefonnr.Schuldner|G1Marktpartnernummer
G1Anrede G1Titel G1Name G1Vorname G1Straße G1Hausnummer G1PLZ G1Ort G1Land G1Geburtsdatum G1Telefonnr.Schuldner G2Marktpartnernummer G2Anrede G2Titel
G2Name|G2Vorname|G2Straße|G2Hausnummer|G2PLZ|G2Ort|G2Land|G2Geburtsdatum|G2Telefonnr.Schuldner|G3Marktpartnernummer|G3Anrede|G3Titel|G3Name|G3Vorname|
G3Straße|G3Hausnummer|G3PLZ|G3Ort|G3Land|G3Geburtsdatum|G3Telefonnr.Schuldner|G4Marktpartnernummer|G4Anrede|G4Titel|G4Name|G4Vorname|G4Straße|G4Hausnummer|
G4PLZ|G4Ort|G4Land|G4Geburtsdatum|G4Telefonnr Schuldner|G5Marktpartnernummer|G5Anrede|G5Titel|G5Name|G5Vorname|G5Straße|G5Hausnummer|G5PLZ|G5Ort|G5Land|
G5Geburtsdatum|G5Telefonnr.Schuldner|Kundennr.|Bestandsnr.|Finanzierungsnr.|KennzeichenFinanzierung/Leasing|Kennzeichenprivat/gewerblich|
reguläresVertragsende|Laufzeit|Vertragsdatum|Vertragsstatus|Ratenbetrag|Filiale/Gebiet|Finanzierungstyp|BankverbindungKonto|BankverbindungBLZ|
RSVKennzeichen|Kündigungsdatum|Modell|Fahrgestellnummer|KFZKennzeichen|KFZZulassungsdatum|CoD1Marktpartnernummer|CoD1Anrede|CoD1Titel|CoD1Name|
CoD1Vorname|CoD1Straße|CoD1Hausnummer|CoD1PLZ|CoD1Ort|CoD1Land|CoD1Geburtsdatum|CoD1Telefonnr.Schuldner|CoD2Marktpartnernummer|CoD2Anrede|CoD2Titel|
CoD2Name|CoD2Vorname|CoD2Straße|CoD2Hausnummer|CoD2PLZ|CoD2Ort|CoD2Land|CoD2Geburtsdatum|CoD2Telefonnr.Schuldner|CoD3Marktpartnernummer|CoD3Anrede|
CoD3Titel|CoD3Name|CoD3Vorname|CoD3Straße|CoD3Hausnummer|CoD3PLZ|CoD3Ort|CoD3Land|CoD3Geburtsdatum|CoD3Telefonnr.Schuldner|CoD4Marktpartnernummer|
CoD4Anrede|CoD4Titel|CoD4Name|CoD4Vorname|CoD4Straße|CoD4Hausnummer|CoD4PLZ|CoD4Ort|CoD4Land|CoD4Geburtsdatum|CoD4Telefonnr.Schuldner|
CoD5Marktpartnernummer|CoD5Anrede|CoD5Titel|CoD5Name|CoD5Vorname|CoD5Straße|CoD5Hausnummer|CoD5PLZ|CoD5Ort|CoD5Land|CoD5Geburtsdatum|
CoD5Telefonnr.Schuldner Y|Y|5830,99|EUR|20/08/2009|DCA|4|123456|Herr||Mueller|Rainer|Messigasse|33|84432|Filz|Deutschland|01/07/1957|08912345|234567|Frau|Dr|Mueller|Rita|Messigasse|33|84432|Filz|Deutschland|13/12/1955|08912345|||||||||||||||||||||||||||||||||||||||||||||||||76543|5000234567||Lease|Privat|12/12/2013|60|12/12/2008||250,50|US|Rate|1234567890|32343450|N||BMW 320 i|W34567890PA34567|M-H-3456|09/12/2008||||||||||||||||||||||||
N|450,80|EUR|20/08/2009|DCA|4|987654|Frau||Meier|Heide|Beinstr.|44|86353|Laus|Deutschland|03/06/1949|08987654|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||87654||8765675585|Loan|Gewerblich|14/03/2012|72|14/03/2006||500,01|DF|Select|976579657|32343450|N||BMW 500 sl|W94567890PA34568|M-H-3457|10/03/2006|34343434|Herr|Dipl|Meier|Rudolf|Heislestr.|69|85433|Maus|Deutschland|28/05/1945|08934567|234567|Frau|Dr|Mueller|Rita|Messigasse|33|84432|Filz|Deutschland|13/12/1955|08912345
Y|33970,50|EUR|20/08/2009|Lawyer|4|64646464|Frau||Schmidt|Susanne|Hueftgasse|55|89363|Maus|Deutschland|23/08/1933|08934567|34343434|Herr|Dipl|Meier|Rudolf|Heislestr.|69|85433|Maus|Deutschland|28/05/1945|08934567|234567|Frau|Dr|Mueller|Rita|Messigasse|33|84432|Filz|Deutschland|13/12/1955|08912345|||||||||||||||||||||||||||||||||||||98757|5000785675||Lease|Privat|11/11/2009|48|11/11/2005||380,70|GH|Zielrate|234567899|32343450|Y||BMW 380 s|W54567890PA34569|M-H-3458|07/11/2005||||||||||||||||||||||||
N|10040,20|EUR|20/08/2009|Lawyer|4|4865465|Herr||Schulz|Karl|Nasenweg|77|83354|Schuh|Deutschland|18/01/1965|08972545|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||46789|50004765787||Lease|Privat|16/09/2012|60|16/09/2007||1234,56|OS|ZUS|98765432|32343450|Y||BMW 280 i|W74567890PA34570|M-H-3459|12/09/2007||||||||||||||||||||||||';
utl_file.PUT_LINE(v_out_file,v_header,TRUE);
-- Below will output a row of data which satisfy the requirements.
FOR body_output IN
( SELECT
AccountDetails.CUSTOMERNUMBER, AccountDetails.ACCOUNTNUMBER, CUSTOMERDETAILS.CDTITLE, CUSTOMERDETAILS.CDFIRSTNAME, CUSTOMERDETAILS.CDLASTNAME, AccountDetails.ACCOUNTTYPE,
AccountDetails.ORIGINALCONTRACTENDDATE, AccountDetails.CONTRACTTERM, AccountDetails.CONTRACTENDDATE, AccountDetails.BRANCHAREA, AccountDetails.PRODUCTTYPE,
AccountDetails.HOUSEBANKACCOUNT, AccountDetails.CARMODEL, AccountDetails.CARLICENCE, AccountDetails.ARREARSBALANCE, AccountDetails.CODEBTOR, AccountDetails.GUARANTORNUMBER
FROM AccountDetails
JOIN CUSTOMERDETAILS ON AccountDetails.CUSTOMERNUMBER = CUSTOMERDETAILS.CUSTOMERS1
WHERE EXISTS
( SELECT *
FROM Dcaaccountallocation
JOIN DebtEpisodes ON DebtEpisodes.ACCOUNTID = Dcaaccountallocation.ACCOUNTID
WHERE Dcaaccountallocation.dcaid = 41
AND Dcaaccountallocation.status = 3
AND DebtEpisodes.DCASentDate IS NULL
AND Dcaaccountallocation.ACCOUNTID = AccountDetails.ACCOUNTNUMBER
AND DebtEpisodes.DCAORLAWYER = 'DCA'
LOOP
UTL_FILE.PUT_LINE (v_out_file,
body_output.CUSTOMERNUMBER|| '|' || body_output.ACCOUNTNUMBER|| '|' ||body_output.CDTITLE|| '||' ||body_output.CDFIRSTNAME || '|||||' ||
body_output.CDLASTNAME|| '||||' || body_output.ACCOUNTTYPE|| '|' ||body_output.ORIGINALCONTRACTENDDATE|| '||||' ||body_output.CONTRACTTERM || '|||||' ||
body_output.CONTRACTENDDATE|| '|' || body_output.BRANCHAREA|| '||' ||body_output.PRODUCTTYPE|| '||' ||
body_output.HOUSEBANKACCOUNT|| '|||' || body_output.CARMODEL|| '||||' ||body_output.CARLICENCE|| '|' ||
body_output.ARREARSBALANCE|| '||||' || body_output.CODEBTOR|| '|' ||body_output.GUARANTORnumber);
END LOOP;
UTL_FILE.fclose (v_out_file);
EXCEPTION
WHEN OTHERS THEN
UTL_FILE.put_line (v_out_file, 'failed');
-- If any errors occur when closing the file, then we close the opened file.
IF utl_file.is_open(v_out_file) THEN
UTL_FILE.fclose (v_out_file);
END IF;
END;
UPDATE DebtEpisodes
SET handoverdate = null
WHERE DCAORLAWYER = 'DCA'
AND accountid IN
( SELECT accountid
FROM Dcaaccountallocation
WHERE Dcaaccountallocation.status = 3
AND Dcaaccountallocation.dcaid = 41
END LOOP;
END DCA_BMW_OUT;
Currently, the above codes issue is that although many rows of data have been inputted in all the tables, with regards to the select criteria above (in italics), it only produces one row of data when i expect more than one to appear.
If the query only outputs one row but you're expecting it to produce more than one row, then you need to dissect the statement to find out where the output is being unduly restricted
I was told maybe an outerloop or an inner loop would do the trick, but really stuck on how and where to put it.
Hope this makes sense guys and I would really appreciate your time.
Thanksif i run this particular code
( SELECT
AccountDetails.CUSTOMERNUMBER, AccountDetails.ACCOUNTNUMBER, CUSTOMERDETAILS.CDTITLE, CUSTOMERDETAILS.CDFIRSTNAME, CUSTOMERDETAILS.CDLASTNAME, AccountDetails.ACCOUNTTYPE,
AccountDetails.ORIGINALCONTRACTENDDATE, AccountDetails.CONTRACTTERM, AccountDetails.CONTRACTENDDATE, AccountDetails.BRANCHAREA, AccountDetails.PRODUCTTYPE,
AccountDetails.HOUSEBANKACCOUNT, AccountDetails.CARMODEL, AccountDetails.CARLICENCE, AccountDetails.ARREARSBALANCE, AccountDetails.CODEBTOR, AccountDetails.GUARANTORNUMBER
FROM AccountDetails
JOIN CUSTOMERDETAILS ON AccountDetails.CUSTOMERNUMBER = CUSTOMERDETAILS.CUSTOMERS1
WHERE EXISTS
( SELECT *
FROM Dcaaccountallocation
JOIN DebtEpisodes ON DebtEpisodes.ACCOUNTID = Dcaaccountallocation.ACCOUNTID
WHERE Dcaaccountallocation.dcaid = 41
AND Dcaaccountallocation.status = 2
AND DebtEpisodes.DCASentDate IS NULL
AND Dcaaccountallocation.ACCOUNTID = AccountDetails.ACCOUNTNUMBER
AND DebtEpisodes.DCAORLAWYER = 'DCA'
This returns 1 row of data
However if i run a small part of the above code...
SELECT *
FROM Dcaaccountallocation
JOIN DebtEpisodes ON DebtEpisodes.ACCOUNTID = Dcaaccountallocation.ACCOUNTID
WHERE Dcaaccountallocation.dcaid = 41
AND Dcaaccountallocation.status = 2
It returns a lot of rows with a status of 2
Now i presume what I am going to do is to ensure that all the fields provide satisfactory requirements, with regards to the above code. Although I have many records in all the stated tables already.
:( -
Fetching more than one row from a table after selecting one value from the dropdown
Hi Experts,
How can we fetch more than one row from a table after selecting one value from the dropdown.
The scenario is that I have some entries in the dropdown like below
A B C
11256 VID 911256
11256 VID 811256
11256 SONY 11256
The 'B' values are there in the dropdown. I have removed the duplicate entries from the dropdown so now the dropdownlist has only two values.for eg- 'VID' and'SONY'. So now, after selecting 'VID' from the dropdown I should get all the 'C' values. After this the "C' values are to be passed to other methods to fetch some data from other tables.
Request your help on this.
Thanks,
Preeetam Narkhede.Hi Preetam!
I hope I understand your request proberly, since this is more about Java and less about WebDynpro, but if I'm wrong, just follow up on this.
Supposed you have some collection of your original table data stored in variable "origin". Populate a Hashtable using the values from column "B" (let's assume it's Strings) as keys and an ArrayList of whatever "C" is (let's assume String instances, too) as value (there's a lot of ways to iterate over whatever your datasource is, and since we do not know what your datasource is, maybe you'll have to follow another approach to get b and c vaues,but the principle should remain the same):
// Declare a private variable for your Data at the appropriate place in your code
private Hashtable temp = new Hashtable<String, ArrayList<String>>();
// Then, in the method you use to retrieve backend data and populate the dropdown,
// populate the Hashtable, too
Iterator<TableData> a = origin.iterator();
while (a.hasNext()) {
TableData current = a.next();
String b = current.getB();
String c = current.getC();
ArrayList<String> values = this.temp.get(b);
if (values == null) {
values = new ArrayList<String>();
values.add(c);
this.temp.put(b, values);
So after this, you'll have a Hashtable with the B values als keys and collections of C values of this particular B as value:
VID --> (911256, 811256)
SONY --> (11256)
Use
temp.keySet()
to populate your dropdown.
After the user selects an entry from the dropdown (let's say stored in variable selectedB), you will be able to retrieve the collection of c's from your Hashtable
// In the metod you handle the selection event with, get the c value collection
//and use it to select from your other table
ArrayList<String> selectedCs = this.temp.get(selectedB);
// now iterate over the selectedCs items and use each of these
//to continue retrieving whatever data you need...
for (String oneC : selectedCs) {
// Select Data from backend using oneC in the where-Clause or whatever...
Hope that helps
Michael -
How to bring the more than one rows from the table into the script
Hi
I have to bring more than one rows from the table into the Main windows of the script. so plz help me out.
Thanks in Advance
AnanyaHi Ananya,
Bring more than one row into main window of script.
For this you need to do some changes for data which you pass to main window.At a time you need to pass more than one row,so for this you need to define one structure.See below code.
Types:begin of ty_rows,
include structure (your row_structure),
include structure (your row_sturcture),
Types:end of ty_rows.
for example....
If i need to pass 2 vendor details at a time to main window then the structure should be like this.
Types:begin of ty_rows,
vendor1 like lfa1-lifnr,
vendor1_name like lfa1-name1,
vendor2 like lfa1-lifnr,
vendor2_name like lfa1-name1,
end of ty_rows.
Data:i_main type standard table of ty_rows,
wa_main type ty_rows.
Based on condition you can pass more than one rows of your actual internal table data to i_main internal table.
Then you can pass i_main internal table to your main window.
I think this will help you.
Cheers,
Bujji -
How to retrive more than one row value from table
hi,
I had create one table if i entered value in more than one row, the second row override the first row value and while printing it in flat file i am getting the second value entered twice.
i created one context for each column.
plz provide me a solution..........
very urgent..........
Regards,
KiruthikaHi,
Create seperate element for each row and then set values.
for(int i=0;i<4;i++)
IPrivate<view name>.I<node name>Element element = wdContext.node<node name>().create<node name>Element();
wdContext.node<node name>().addElement(element);
element.set<Att>();
to retrive:
int s=wdContext.node<node name>.size();
for(int j=0;j<s;J++){
wdcontext.node<nodename>.getnodeelementAt(j).getAttribute();
Check this link about tables
https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/bad3e990-0201-0010-3985-fa0936d901b4
Regards,
Vijayakhanna Raman -
Hacking application id equals() to allow more than one row per "primary key"
I have a read only entity whose primary key is not the real primary key
on the underlying table. The result is that I get more than one row per
"primary key". This is what I want. However KODO will not allow me do
it, because I am storing the collection in a HashSet() and the equals()
method on the application id object ensures that this set contains no
duplicates (as defined by the application id). At least thats how it
seems to behave.
So, I have hacked the equals() method to do this:
public boolean equals (Object ob)
if (this == ob)
return true;
// Doing this because we expect more than one row from
// REF_CODES for the same domain/shortCode combination.
// This is ok to do (I guess?) as long as we are only
// doing selects using this class.
return false;
Will this hack have any side effects? Is there another option? Like
using a list collection? Is so, which collections are supported?
Thanks,
Mike.The "primary key" I am using it already a compound key of two columns.
The real key on the underlying table is a three column key. But the
problem is that the table represents two different application level
entities. I could deal with it when I was hand-writing SQL (I could do
a distinct for example) but now I am relying on foreign key
relationships since I moved to JDO. Not sure what to do. Best solution
is to rework the table, but there is a lot of legacy code (that other
teams use and maintain) relying on this table. I guess I'll use the
weekend for inspiration ;-)
Steve Kim wrote:
This sounds like a dangerous operation. Even if this works now, I
cannot promise future compatibility... and in fact may result in bad
data (for example in caching both at the PM and PMF level) Is there no
other field that you can reference as part of the primary key? Primary
Keys can be multi columned (e.g. last_name, soc_sec_number)
Mike Hogan wrote:
I have a read only entity whose primary key is not the real primary
key on the underlying table. The result is that I get more than one
row per "primary key". This is what I want. However KODO will not
allow me do it, because I am storing the collection in a HashSet() and
the equals() method on the application id object ensures that this set
contains no duplicates (as defined by the application id). At least
thats how it seems to behave.
So, I have hacked the equals() method to do this:
public boolean equals (Object ob)
if (this == ob)
return true;
// Doing this because we expect more than one row from
// REF_CODES for the same domain/shortCode combination.
// This is ok to do (I guess?) as long as we are only
// doing selects using this class.
return false;
Will this hack have any side effects? Is there another option? Like
using a list collection? Is so, which collections are supported?
Thanks,
Mike. -
How to find out which sub query returns more than one row
Hi all,
Can any one give me clue ,how to find out which sub query returns more than one row in the following query .
/* Formatted on 2011/05/17 19:22 (Formatter Plus v4.8.8) */
SELECT a.*, ROWNUM AS rnm
FROM (SELECT DISTINCT '1' AS "Page View", ou.org_unit_name AS "Org",
prxm.mbr_idntfr AS "Beneficiary ID",
md.last_name
|| ', '
|| md.first_name AS "Beneficiary Name",
pci.idntfr AS "Tracking No.",
TO_CHAR (TRUNC (req.pa_rqst_date),
'MM/dd/yyyy'
) AS "Request Date",
sts.status_name AS "Status",
req.pa_rqst_sid AS "Request #",
prxm.mbr_sid AS "Mbr_sid",
TO_CHAR
(TRUNC (req.pa_revision_date),
'MM/dd/yyyy'
) AS "Last Updated",
TO_CHAR (psd.TO_DATE, 'MM/dd/yyyy') AS "TO_DATE",
prxpl.prvdr_lctn_iid AS "PRVDR_LCTN_IID",
pd.prvdr_sid AS "PRVDR_SID", 'Y' AS "State View",
DECODE
((SELECT DISTINCT pd.national_prvdr_idntfr
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid =
req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
0, (SELECT prxplo.prvdr_lctn_idntfr
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
NULL, (SELECT prxplo.prvdr_lctn_idntfr
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
(SELECT DISTINCT pd.national_prvdr_idntfr
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid =
req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR')
) AS "NPI/ID",
DECODE
((SELECT pd.org_bsns_name
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
NULL, (SELECT pd.last_name
|| ', '
|| pd.first_name
|| ' '
|| pd.middle_name
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
(SELECT pd.org_bsns_name
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR')
) AS "Prvdr Name",
TO_CHAR (psd.from_date,
'MM/dd/yyyy'
) AS "Srvc From Date",
TO_CHAR (req.validity_start_date,
'MM/DD/YYYY'
) AS "Due Date",
(fn_get_busniess_days (TRUNC (req.validity_start_date))
) AS "Days<br>Left",
req.pa_mode_type_lkpcd AS "Source",
TO_CHAR (TRUNC (wmdtl.rtng_date),
'MM/dd/yyyy'
) AS "Assigned On",
NVL (wmdtl.assigned_to_user_name,
'Not Assigned'
) AS "Assigned To",
req.org_unit_sid AS "OrgUnitSid",
TO_CHAR
(wmdtl.modified_date,
'MM/dd/yyyy hh24:mi:ss'
) AS "WTRD_MODIFIED_DATE",
TO_CHAR (wmdtl.rtng_date,
'MM/dd/yyyy'
) AS "WTRD_RTNG_DATE",
req.status_cid AS "PA_STATUS_CID",
TO_CHAR (req.modified_date,
'MM/dd/yyyy'
) AS "PA_REQ_MODIFIED_DATE",
prs.state_pa_srvc_type_code
AS "STATE_PA_SRVC_TYPE_CODE",
wmdtl.wm_pa_task_rtng_dtl_sid
AS "WM_TASK_RTNG_DTL_SID",
wmdtl.assigned_to_user_acct_sid
AS "WTRD_Assigned_to_user_acct_sid",
(fn_get_busniess_days (TRUNC (req.validity_start_date))
) AS "Days<br>LeftSort",
wmdtl.assigned_to_org_unit_sid
AS "WTRD_Assigned_to_OrgUntSid",
DECODE
((SELECT COUNT (*)
FROM pa_request_status prs
WHERE prs.pa_rqst_sid = req.pa_rqst_sid
AND prs.status_cid = 5
AND prs.oprtnl_flag = 'I'),
0, 'N',
'Y'
) AS "SHOW_UTILIZATION"
FROM pa_request req,
pa_certification_identifier pci,
status sts,
pa_request_x_member prxm,
wm_pa_task_routing_detail wmdtl,
pa_service_date psd,
org_unit ou,
pa_request_service prs,
pa_request_x_provider_location prxpl,
provider_location pl,
provider_detail pd,
provider p,
mbr_dmgrphc md
WHERE req.oprtnl_flag = 'A'
AND req.status_cid NOT IN
(20, 30, 70, 25, 80, 96, 85, 5, 97, 98, 101)
AND req.org_unit_sid IN
(3057, 3142, 3058, 3143, 3059, 3144, 3060, 3145,
3061, 3146, 3062, 3147, 3063, 3148, 3064, 3149,
3065, 3150, 3066, 3151, 3067, 3152, 3068, 3153,
3069, 3154, 3070, 3155, 3071, 3156, 3072, 3157,
3073, 3158, 3074, 3159, 3075, 3160, 3076, 3161,
3077, 3162, 3078, 3163, 3079, 3164, 3080, 3165,
3081, 3166, 3082, 3167, 3083, 3168, 3084, 3169,
3085, 3170, 3086, 3171, 3087, 3172, 3088, 3173,
3089, 3174, 3090, 3175, 3091, 3176, 3092, 3177,
3093, 3178, 3094, 3179, 3095, 3180, 3096, 3181,
3097, 3182, 3098, 3183, 3099, 3184, 3100, 3185,
3101, 3186, 3102, 3187, 3103, 3003, 75000104,
75000108, 2006, 75000103, 75000102, 75000113,
75000111, 75000109, 2001, 2009, 75000105,
75000107, 2004, 2010, 2013, 2014, 2005, 2011,
75000112, 2002, 1001, 2012, 75000106, 2007,
75000101, 2003, 75000110, 2008, 3001, 3002, 3019,
3104, 3020, 3105, 3021, 3106, 3022, 3107, 3023,
3108, 3024, 3109, 3025, 3110, 3026, 3111, 3027,
3112, 3028, 3113, 3029, 3114, 3030, 3115, 3031,
3116, 3032, 3117, 3033, 3118, 3034, 3119, 3035,
3120, 3036, 3121, 3037, 3122, 3038, 3123, 3039,
3124, 3040, 3125, 3041, 3126, 3042, 3127, 3043,
3128, 3044, 3129, 3045, 3130, 3046, 3131, 3047,
3132, 3048, 3133, 3049, 3134, 3050, 3135, 3051,
3136, 3052, 3137, 3053, 3138, 3054, 3139, 3055,
3140, 3056, 3141)
AND req.pa_rqst_sid = prs.pa_rqst_sid
AND prs.oprtnl_flag = 'A'
AND prs.pa_rqst_srvc_sid = psd.pa_rqst_srvc_sid
AND psd.oprtnl_flag = 'A'
AND req.pa_rqst_sid = pci.pa_rqst_sid
AND pci.oprtnl_flag = 'A'
AND req.pa_rqst_sid = prxm.pa_rqst_sid
AND prxm.oprtnl_flag = 'A'
AND md.oprtnl_flag = 'A'
AND md.status_cid = 2
AND TRUNC (SYSDATE) BETWEEN md.from_date AND md.TO_DATE
AND prxm.mbr_sid = md.mbr_sid
AND ou.org_unit_sid = req.org_unit_sid
AND ou.oprtnl_flag = 'A'
AND req.pa_rqst_sid = prxpl.pa_rqst_sid
AND prxm.pa_rqst_sid = prxpl.pa_rqst_sid
AND pci.pa_rqst_sid = prxm.pa_rqst_sid
AND pci.pa_rqst_sid = wmdtl.subsystem_task_sid
AND pci.pa_rqst_sid = prxpl.pa_rqst_sid
AND prxpl.pa_prvdr_type_lkpcd = 'RR'
AND prxpl.oprtnl_flag = 'A'
AND req.status_cid = sts.status_cid
AND sts.status_type_cid = 3
AND sts.oprtnl_flag = 'A'
AND prxpl.prvdr_lctn_iid = pl.prvdr_lctn_iid
AND p.prvdr_sid = pd.prvdr_sid
AND p.prvdr_sid = pl.prvdr_sid
AND pd.oprtnl_flag = 'A'
AND pd.status_cid = 2
AND TRUNC (SYSDATE) BETWEEN pd.from_date AND pd.TO_DATE
AND wmdtl.subsystem_task_sid = req.pa_rqst_sid
AND wmdtl.subsystem_lkpcd = 'PA'
AND wmdtl.oprtnl_flag = 'A'
AND req.pa_rqst_date > (SYSDATE - 365)
ORDER BY TO_DATE ("Request Date", 'MM/dd/yyyy hh24:mi:ss') DESC,
"Beneficiary Name" ASC) a
WHERE ROWNUM < 102;regards,
P Prakash
Edited by: BluShadow on 17-May-2011 15:01
added {noformat}{noformat} tags around the code833560 wrote:
Can any one give me clue ,how to find out which sub query returns more than one row in the following query .This is why smaller, simpler queries are easier to work with than huge ones - when something like this goes wrong smaller queries are much eaiser to debug. Unfortunately using smaller, easier-to-work with queries is not always an option
Ganesh is right - you will have to dissect the big query bit by bit until you find the offending subquery. If there is another way I would like to find out about it too.
The easiest way to do this is probably to use block comments to isolate parts of the query bit by bit until you find the offending part. If you carefully examine the subqueries you might be able to figure out which one is returning multiple rows without commenting everything
Good luck! -
Xml to Oracle (Update more than one row)
Hi,
I want to update more than one row in table from .xml file. My xml file is as follows:
<ROOT>
<PROFILE PROFILEMASTER_PKEY="54" DB_MSTR_PKEY="2" PROFILE_NAME="Bhushans" DELIMETER="~" PRE_PROCESSOR="1" POST_PROCESSOR="10" PRE_PROCESSOR_TYPE="1" POST_PROCESSOR_TYPE="2" GROUPID="2" />
<PROFILEDETAILS PROFILEMASTER_PKEY="54" TARGET_SOURCE_TABLE="FM_FEEDVALIDATION_LU" COLUMN_NAME="FEEDVALIDATION_ID" DATA_TYPE="NUMBER" DATA_SIZE="22" START_POSITION="12" END_POSITION="22" COLUMNORDER="1" PROFILEDETAILS_PKEY="399"/>
<PROFILEDETAILS PROFILEMASTER_PKEY="54" TARGET_SOURCE_TABLE="FM_FEEDVALIDATION_LU" COLUMN_NAME="CHANGE_TYPE" DATA_TYPE="VARCHAR2" DATA_SIZE="1" START_POSITION="12" END_POSITION="144" COLUMNORDER="5" PROFILEDETAILS_PKEY="403"/>
<OPTIONS PROFILEMASTER_PKEY ="54" LDR_SYNTX_DTLS_PKEY ="19" OPTIONVALUE="@" PROFILE_CFILE_PKEY="337" />
<OPTIONS PROFILEMASTER_PKEY ="54" LDR_SYNTX_DTLS_PKEY ="19" OPTIONVALUE="~" PROFILE_CFILE_PKEY="336" />
</ROOT>
To update according to xml file, I have written following procedure. My procedure updates the table if u r updating 1 row. If you try to update more than 1 row, I mean .xml file contains more than 1 row then my procedure doesn't work. Please help to solve this problem.
Procedure:
create or replace procedure fm_prc_xml_dup_up
as
f utl_file.file_type;
s varchar2(2000);
v varchar2(3000);
xml XMLType;
v_pmpk number;
v_sdtl_pk number;
chng_typ VARCHAR2(20);
type r1 is ref cursor;
rcur r1;
v1 varchar2(120);
v2 number;
begin
f := utl_file.fopen('CITI', 'S.XML', 'R');
loop
utl_file.get_line(f, s);
v := v || ' ' || s;
end loop;
exception
when no_data_found then
utl_file.fclose(f);
xml := xmltype(v);
SELECT extract(xml, 'ROOT/CHANGE/@CHANGETYPE').getstringval()
INTO CHNG_TYP
FROM DUAL;
UPDATE FM_PROFILEMAST
set db_mstr_pkey = extract(xml, 'ROOT/PROFILE/@DB_MSTR_PKEY').getnumberval(),
profile_name = extract(xml, 'ROOT/PROFILE/@PROFILE_NAME').getstringval(),
file_type = extract(xml, 'ROOT/PROFILE/@FILE_TYPE').getstringval(),
delimiter = extract(xml, 'ROOT/PROFILE/@DELIMETER').getstringval(),
pre_processor = extract(xml, 'ROOT/PROFILE/@PRE_PROCESSOR').getstringval(),
post_processor = extract(xml, 'ROOT/PROFILE/@POST_PROCESSOR').getstringval(),
pre_processor_type = extract(xml, 'ROOT/PROFILE/@PRE_PROCESSOR_TYPE').getstringval(),
post_processor_type = extract(xml, 'ROOT/PROFILE/@POST_PROCESSOR_TYPE').getstringval(),
groupid = extract(xml, 'ROOT/PROFILE/@GROUPID').getstringval(),
change_type = 'U',
change_by = chng_typ,
change_dt = default,
active_flag = default
WHERE profilemaster_pkey = extract(xml, 'ROOT/PROFILE/@PROFILEMASTER_PKEY').getnumberval();
UPDATE FM_PROFILEDET
SET target_source_table = extract(xml, 'ROOT/PROFILEDETAILS/@TARGET_SOURCE_TABLE').getstringval(),
column_name = extract(xml, 'ROOT/PROFILEDETAILS/@COLUMN_NAME').getstringval(),
data_type = extract(xml, 'ROOT/PROFILEDETAILS/@DATA_TYPE').getstringval(),
data_size = extract(xml, 'ROOT/PROFILEDETAILS/@DATA_SIZE').getnumberval(),
start_position = extract(xml, 'ROOT/PROFILEDETAILS/@START_POSITION').getnumberval(),
end_position = extract(xml, 'ROOT/PROFILEDETAILS/@END_POSITION').getnumberval(),
change_by = chng_typ,
change_dt = default,
columnorder = extract(xml, 'ROOT/PROFILEDETAILS/@COLUMNORDER').getstringval(),
column_format = extract(xml, 'ROOT/PROFILEDETAILS/@COLUMN_FORMAT').getstringval(),
nullable = extract(xml, 'ROOT/PROFILEDETAILS/@NULLABLE').getstringval(),
change_type ='U',
active_flag = default
WHERE profiledetails_pkey = extract(xml, 'ROOT/PROFILEDETAILS/@PROFILEDETAILS_PKEY').getstringval();
UPDATE FM_PROFILE_CFILE
SET profilemaster_pkey = extract(xml, 'ROOT/PROFILE/@PROFILEMASTER_PKEY').getnumberval(),
ldr_syntx_dtls_pkey = extract(xml, 'ROOT/OPTIONS/@LDR_SYNTX_DTLS_PKEY').getstringval(),
val = extract(xml, 'ROOT/OPTIONS/@OPTIONVALUE').getstringval(),
change_by = chng_typ,
change_dt = default,
sub_line_seq = extract(xml, 'ROOT/OPTIONS/@SUB_LINE_SEQ').getstringval(),
change_type = 'U',
active_flag = default
where profile_cfile_pkey = extract(xml, 'ROOT/OPTIONS/@PROFILE_CFILE_PKEY').getnumberval();
END;Hi Bhushan,
one where clause is missing in the main update.
update fm_profiledet
set (....)
=(select ....)
where id in (select your profiledetails_pkey from the xml). <--this where clause were missing.
if xml extracting is too slow(xml very large) then you can create a procedure where exract your data from the xml and then update rows in for loop.
something like this
create procedure up_xmls(p_xml xmltype) is
cursor cur_xml(p_xml xmltype) is
select ......<--here you extract your xml
begin
for r_row in cur_xml(p_xml) loop
update fm_profiledet set target_source_table=r_row.target_source_table
where profiledetails_pkey=r_row.profiledetails_pkey;
end loop;
end;this should work:
SQL> drop table fm_profiledet;
Table dropped.
SQL> create table fm_profiledet(
2 profiledetails_pkey number
3 ,target_source_table varchar2(100)
4 ,column_name varchar2(100)
5 ,data_type varchar2(100)
6 ,data_size number
7 ,start_position number
8 ,change_type varchar2(100)
9 )
10 /
Table created.
SQL>
SQL>
SQL> insert into fm_profiledet
2 values(399,'test','test1','test2',1,2,'A')
3 /
1 row created.
SQL>
SQL>
SQL> insert into fm_profiledet
2 values(403,'test3','test4','test5',3,4,'B')
3 /
1 row created.
SQL> insert into fm_profiledet
2 values(443,'test3','test4','test5',3,7,'B')
3 /
1 row created.
SQL>
SQL>
SQL> select * from fm_profiledet;
PROFILEDETAILS_PKEY TARGET_SOU COLUMN_NAM DATA_TYPE DATA_SIZE START_POSITION CHANGE_TYP
399 test test1 test2 1 2 A
403 test3 test4 test5 3 4 B
443 test3 test4 test5 3 7 B
SQL>
SQL> create or replace directory xmldir as '/home/ants';
Directory created.
SQL>
SQL>
SQL>
SQL> update fm_profiledet fm
2 set (target_source_table,column_name, data_type, data_size, start_position,change_type)
3 =(
4 select target_source_table
5 , column_name
6 , data_type
7 , data_size
8 , start_position
9 , change_type
10 from(
11 select
12 extractValue(value(x),'/PROFILEDETAILS/@PROFILEDETAILS_PKEY') profiledetails_pkey
13 , extractValue(value(x),'/PROFILEDETAILS/@TARGET_SOURCE_TABLE') target_source_table
14 , extractValue(value(x),'/PROFILEDETAILS/@COLUMN_NAME') column_name
15 , extractValue(value(x),'/PROFILEDETAILS/@DATA_TYPE') data_type
16 , extractValue(value(x),'/PROFILEDETAILS/@DATA_SIZE') data_size
17 , extractValue(value(x),'/PROFILEDETAILS/@START_POSITION') start_position
18 ,'U' change_type
19 from
20 table(xmlsequence(extract(xmltype(bfilename('XMLDIR','prof.xml')
21 ,nls_charset_id('AL32UTF8'))
22 , '/ROOT/PROFILEDETAILS'))) x
23 ) s
24 where s.profiledetails_pkey=fm.profiledetails_pkey)
25 where
26 fm.profiledetails_pkey in (select
27 extractValue(value(x),'/PROFILEDETAILS/@PROFILEDETAILS_PKEY') profiledetails_pkey
28 from
29 table(xmlsequence(extract(xmltype(bfilename('XMLDIR','prof.xml')
30 ,nls_charset_id('AL32UTF8'))
31 , '/ROOT/PROFILEDETAILS'))) x
32 );
2 rows updated.
SQL>
SQL>
SQL> select * from fm_profiledet;
PROFILEDETAILS_PKEY TARGET_SOU COLUMN_NAM DATA_TYPE DATA_SIZE START_POSITION CHANGE_TYP
399 FM_FEEDVAL FEEDVALIDA NUMBER 22 12 U
IDATION_LU TION_ID
403 FM_FEEDVAL CHANGE_TYP VARCHAR2 1 12 U
IDATION_LU E
443 test3 test4 test5 3 7 B
SQL> spool off;Ants
Message was edited by:
Ants Hindpere -
Single row subquery Returning more than one row
Hi,
This is urgent.............
could u any one please suggest me on this query it returning single row subquey returnin more than one row
In this 2nd suquery fails some of the order_numbers returning more than price_list based on dates and in that situvation also my query has to successfull
fro that i added this condition l.ordered_quantity between trunc(product_attr_value_from) and (product_attr_value_to) for that condition also failing this query
pls give me the correct condition to approach this solution
select
substr(party.party_name,1,13),
c.account_number,
substr(h.order_number||'-'||l.line_number||'-'||l.shipment_number,1,15),
q.name,l.unit_selling_price,
(select qll.operand
apps.qp_list_headers qlh,
apps.qp_list_lines qll,
apps.qp_list_lines qllx
apps.qp_pricing_attributes qpa,
apps.qp_rltd_modifiers qrm,
apps.mtl_system_items msi
wherer qll.list_header_id=qlh.list_header_id
and qpa.list_header_id=qlh.list_header_id
and qpa.list_line_id=qll.list_line_id
and qrm.rltd_modifier_grp_type='PRICE BREAK'
and qll.list_line_id=qrm.to_rltd_modifier_id
and qll.list_line_type_code='PLL'
and qllx.list_header_id=qlh.lsit_header_id
and qllx.list_line_id=qrm.from_rltd_modifier_id
and qllx.list_line_type_code='PBH'
and qlh.list_header_id=l.price_list_id
and qpa.product_attr_value=msi.inventory_item_id
and qpa.product_attr_value=l.inventory_item_id
and msi.segment2 is null
and msi.organization_id=89
and trunc(l.request_date) between trunc(qllx.start_date_active) and trunc(nvl(qllx.end_date_active,sysdate))
and l_ordered_quantity between qpa.pricing_attr_value_from and qpa.pricing_attr_value_to
and qpa.product_uom_code=l.pricing_quantity_uom),
substr(l.ordered_item,1,13),
u.user_name,
t.name,
l.ordered_quantity,
l.creation_date,
l.request_date,
l.pricing_date,
l.flow_status_code
from apps.oe_order_headers_all h,
hz_cust_Accounts c,
hz_parties party,
apps.oe_order_lines_all l,
apps.qp_list_headers_tl q,
apps.qp_list_headers_b qb,
apps.fnd_user u,
apps.so_order_types_all t
where h.header_id=l.header_id
and h.sold_to_org_id=c.cust_account_id
and c.party_id=party.party_id
and trunc(l.request_date)!=trunc(l.pricing_date)
and qb.attribute1='Q'
and q.list_header_id=qb.list_header_id
and l.price_list_id=q.list_header_id
and l.flow_status_code=!='CANCELLED'
AND t.name!='ECOM'
and t.name!='RMA'
and l.open_flag='Y'
and l.item_type_code='MODEL'
and u.user_id=l.created_by
and t.order_type_id=h.order_type_id
and u.user_name='XXCONVERSION'
and (l.unit_selling_price -
(select qll.operand
from apps.qp_list_headers qlh,
apps.qp_lsit_lines qll,
apps.qp_list_lines qllx,
apps.qp_pricing_attributes qpa,
apps.qp_rltd_modifiers qrm,
apps.mtl_system_items msi
where qll.list_header_id=qlh.list_header_id
and qpa.list_header_id=qlh.lsit_header_id
and qpa.list_line_id=qll.list_line_id
and qrm.rltd_modifier_grp_type='PRICE BREAK'
AND qll.list_line_id=qrm.to_rltd_modifier_id
and qll.list_line_type_code='PLL'
and qllx.list_header_id=qlh.list_header_id
and qllx.list_line_id=qrm.from_rltd_modifier_id
and qllx.list_line_type_code='PBH'
and qlh.list_header_id=l.price_list_id
and qpa.product_attr_value=msi.inventory_item_id
and qpa.product_Attr_value=l.inventory_item_id
and msi.segmetn2 is null
and msi.organization_id=89
trunc(l.request_date) between trunc(qllx.start_date_active) and trunc(nvl(qllx.end_date_active,sysdate)) and
and l.ordered_quantity between qpa.pricing_attr_value_from and qpa.pricing_attr_value_to
and qpa.product_uom_code=l.pricing_quantity_uom)!=0)
order by creation_dateHi,
995631 wrote:
Hi,
This is urgent.............Then don't use this forum.
could u any one please suggest me on this query it returning single row subquey returnin more than one row
In this 2nd suquery fails some of the order_numbers returning more than price_list based on dates and in that situvation also my query has to successfullRemember, none of the people who want to help you are as familiar with your application as you are, so you have to explain things that are obvious to you.
What does "sucessful" mean in this case? Does is mean producing the right results? What are the right results? How can you tell them apart from the wrong results?
As the errror message says, the (immediate) problem is that a single-row sub-query is returning more than a single row. If the sub-query tries to bring back more than 1 row, which one do you want to use? Or do you want to use some kind of aggregate, such as the average, which might not be the same as any of them?
Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Simplify the problem as much as possible. For example, remove all columns and tables that have nothing to do with the part you don't know how to do.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
ORA-01427: single-row subquery returns more than one row HELP
I need to update baemployee.Stock_nbr field with select substr(C.CHECK_DIGIT, 3, 10)
from EMP_CHECK_DIG c where C.EMPLOYEE = e.EMPLOYEE
Please help.
update baemployee e
set Stock_nbr = (select substr(C.CHECK_DIGIT, 3, 10)
from EMP_CHECK_DIG c where C.EMPLOYEE = e.EMPLOYEE)
where exists
(select C.CHECK_DIGIT
from EMP_CHECK_DIG c where C.EMPLOYEE = e.EMPLOYEE)
and exists (select 1 from EMPLOYEE ee where ee.employee = e.employee and ee.emp_status like 'A%');
ORA-01427: single-row subquery returns more than one rowHi,
Welcome to the forum!
Whenever you have a question, please post some sample data, so that people can re-create the problem and test their solutions.
CREATE TABLE and INSERT statements, like the ones below, are great:
CREATE TABLE baemployee
( employee NUMBER (4)
, stock_nbr VARCHAR2 (10)
INSERT INTO baemployee (employee, stock_nbr) VALUES (1234, 'FUBAR');
CREATE TABLE employee
( employee NUMBER (4)
, emp_status VARCHAR2 (10)
INSERT INTO employee (employee, emp_status) VALUES (1234, 'ACTIVE');CREATE TABLE AS is good, too:
CREATE TABLE emp_check_dig
AS SELECT 1234 AS employee, 'AA1234567890ZZZ' AS check_digit FROM dual
UNION ALL SELECT 1234, 'AA2121212121ZZZ' FROM dual
;Also post the results you want from that data. In this case, the results would be the contents of the baemployee table after you run the UPDATE.
Would you want:
employee stock_nbr
1234 1234567890or would you want
employee stock_nbr
1234 2121212121If you run the UPDATE statement you posted with the data above, you'll get the "ORA-01427: single-row subquery returns more than one row" error, and you can see what causes it: there is more than one row from emp_check_dig that could be used to UPDATE the same row of baemployee. Say what you want to do in this situation (and why), and someone will help you find a way to do it. -
ORA-01427: single-row subquery returns more than one row -- no solution
Hello to all:
I have to tables:
Table a anwender (Email,Dept). --> all fields are filled
Table b dingo (Name,email,dept) --> all fields are filled
I now want to update the table a with the data from table b:
update anwender a set a.abteilung = ( select distinct b.abteilung from dingo b where b.email = a.email);
Then I got the error: ORA-01427: single-row subquery returns more than one row
Every dept is about 100x in the database, so it is clear that i got more than one row back. But how can I update the table now?Okay, I got several duplicates, and I deletet a lot of data in my database.
Now I want to remove all entries with more than one departments per mail adresses.
a
select email,count(abteilung) from dingo group by email having count(abteilung)>1 order by count(abteilung)
shows me all the fake mailadresses.
But a
delete from dingo where email in (select email,count(abteilung) from dingo group by email having count(abteilung)>1 order by count(abteilung) );
gives me a
SQL Error: ORA-00907: missing right parenthesis
I´m very confused now ...
Oops, now I got the solution:
delete from dingo where email in (select email from (select email,count(abteilung) from dingo group by email having count(abteilung)>1 )) ;
Edited by: user8309218 on Dec 18, 2009 6:24 AM -
Update gives "single-row subquery returns more than one row"
Hi,
I have to update a table by getting values from two other tables. While doing that the inner query returns more than one value. I am not sure how to implement the logic without returning more than one row in sub quesry. Need help on that.
My query:
update buf_office_str o
set o.manager_ident =
(select sp.ident
from se2_r_src_sourceperson sp ,
(select distinct director_name, team_name from buf_sales_dump )t
where SP.SRCNAME = upper(substr(t.director_name,instr(t.director_name,' ')+1,length(t.director_name))||', '||substr(t.director_name,1,instr(t.director_name,' ')-1 ) )
and o.office_descr = t.team_name
Basically the query gets teh manager id from sp table where sp.srcname = t.team-name.
The office descr should be equal to the team_name.
This is the logic I am working towards:
For each office, i get the office_descr and get corresponding team_name. Match the team's director_name (from table t) with the sp.name and return the employee's id (sp.ident) for that office_descr.
I need to update all 50 offices with corresponding managerid for that office in buf_office_str table.
Is it possible to get done in one update? Pls let me know.Hi,
"Single-row subquery returns more than one row" is one of those error messages that actually means what it says: the correlated sub-query in your SET clause is sometimes returning 2 or more rows .
The solution could be as simple as making the sub-query SELECT DISTINCT , as its in-line view, t, already is.
It's possible you have bad data, or a mistake in your statement.
To find the problem cases, you can run something like this:
WITH sub_q AS
SELECT -- DISTINCT ?
sp.ident
, t.team_name
, COUNT (*) OVER (PARTITION BY t.team_name) AS cnt
FROM se2_r_src_sourceperson sp
, ( SELECT DISTINCT director_name
, team_name
FROM buf_sales_dump
) t
WHERE sp.srcname = UPPER ( SUBSTR ( t.director_name
, INSTR ( t.director_name
) + 1
, LENGTH (t.director_name)
|| ', '
|| SUBSTR ( t.director_name
, 1
, INSTR ( t.director_name
) - 1
SELECT o.* -- or whatever helps you
, sq.*
FROM buf_office_str o
JOIN sub_q sq ON o.office_descr = sq.team_name
WHERE sq.cnt > 1
;If you'd like more help, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables as they exist before the UPDATE, and the results you want from that data (that is, the contents of buf_office_str after the UPDATE). Make sure the problem occurs with the sample data you post. -
How to from more than one delivery note - conversion into one invoice
Dear Experts,
How to from more than one delivery note - conversion into one invoice?
Thanks and best regards,
Wilson HongDear Wilson Hong,
Single invoice for multiple deliveries will takes place based on these criterion
1.If you want single billing document for multiple deliveries these data should be same in all order for all items.
-> Payer
-> Inco term
-> Payment term
-> Actual GI Date from Delivery
-> Shipping Condition
-> Account Assignment Group
-> Exchange rate (in case of export sale order)
-> Foreign trade data.
2.In addition to this you need to maintain proper copy control settings between delivery and invoice.
Go to VTFL transaction input your delivery type and invoice type then go in to the item level settings here you find field Data VBRK/VBRP maintain this field with routine 3-Single invoice.
If the above data and settings are exists you can do single invoice for multiple deliveries.
I hope this will help you,
Regards,
Murali.
Maybe you are looking for
-
Foreign trade / Customs info
Hello experts, I have a problem with billing split. The scenario is the following: I have created a purchasing organization that belongs to a society called UMA. This purchasing organization has a plant (UMC) without any warehouse (at the moment, it
-
Printers are installed on the server. DNS, OD working fine. Print service is turned on and started. The main printer is listed in the queue, and IPP, LPR (with Bonjour) are turned on. The client computers "see" the printer via Bonjour, but when I cli
-
Can I use or convert existing .cfa & .pek files to use in a new video?
I accidentally but permanently deleted all source files for a short video I was working on. I still have video and audio files located in the Adobe Elements folders. I can use the video files (MPEGs) to reconstruct the video portion but I can't se
-
Height of a line in a dynamic table
Hi experts, How could i set the line height of 1 row in a dynamic table rewards if successful
-
Jwsdp_1.2 - build.properties not accessible
Hello, since I've updated my jwsdp-version (to jwsdp_1.2), I cannot use ant to install my services, because the manager.username and manager.password in build.xml aren't accessible for ant, although a build.properties files exists in my home director