Problem :fetching more than one record
In the below code ,i am receiving error that '"fetch returns more than record"..Is there any way to solve this problem
declare
cursor cur_test is
select * from test_for_cursor where i=&i for update;
r test_for_cursor%rowtype;
r1 test_for_cursor.i%type;
begin
open cur_test;
loop
fetch cur_test into r;
exit when cur_test%notfound;
update test_for_cursor set i=r.i+2 where i=r.i returning i into r1;
dbms_output.put_line(r1);
end loop;
close cur_test;
end;
Try this
DECLARE
CURSOR cur_test
IS
SELECT *
FROM test_for_cursor
WHERE i = &i
FOR UPDATE;
r test_for_cursor%ROWTYPE;
TYPE r1_typ IS TABLE OF test_for_cursor.i%TYPE;
r1 r1_typ;
BEGIN
OPEN cur_test;
LOOP
FETCH cur_test
INTO r;
EXIT WHEN cur_test%NOTFOUND;
UPDATE test_for_cursor
SET i = r.i + 2
WHERE i = r.i
RETURNING i
BULK COLLECT INTO r1;
FOR j IN 1 .. r1.COUNT
LOOP
DBMS_OUTPUT.put_line (r1(j));
END LOOP;
END LOOP;
CLOSE cur_test;
END;Some correction.
Message was edited by:
michaels
Similar Messages
-
How to concat columns from more than one record?
I have a function that takes an Oracle long and returns it as a varchar so that I can use it in the Microsoft world. My problem is that the SELECT returns more than one row (which is valid) and I need the Long fields to be concatenated into the one varchar returned. Currently I get an error saying more than one record is returned. This is my function:
CREATE or replace function m4owner.Get_Request_Text
(av_REQUEST_ID varchar2, av_REQUEST_LINE number, av_TEXT_LINE_CODE varchar2)
RETURN varchar2
IS
long_var LONG;
BEGIN
SELECT TEXT INTO long_var
FROM M4OWNER.REQUEST_TEXT
WHERE REQUEST_ID = av_REQUEST_ID
AND REQUEST_LINE = av_REQUEST_LINE
AND TEXT_LINE_CODE = av_TEXT_LINE_CODE;
return long_var;
END;CREATE or replace function m4owner.Get_Request_Text (av_REQUEST_ID varchar2,
av_REQUEST_LINE number,
av_TEXT_LINE_CODE varchar2) RETURN varchar2 IS
long_var LONG;
BEGIN
for t1 in (SELECT TEXT FROM M4OWNER.REQUEST_TEXT
WHERE REQUEST_ID = av_REQUEST_ID
AND REQUEST_LINE = av_REQUEST_LINE
AND TEXT_LINE_CODE = av_TEXT_LINE_CODE) loop
long_var := long_var || t1.text;
end loop
return long_var;
END; note: untested -
RFC to XI File - can NEVER EVER get more than one record in Output file.
Hi guys
This might be related to my other post on File conversion but whatever I do I just can't seem to get more than one record in the output file
the payload from R3==> XI seems fine
for example
<?xml version="1.0" encoding="UTF-8" ?>
- <rfc:Z_XI_005_RFC xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
- <IP_CUSTOMER_HEADER>
- <item>
<CUSTOMERID>1000001</CUSTOMERID>
<COMPANY>One-time ship-to</COMPANY>
<SHORT_NAME>ONE-TIME</SHORT_NAME>
<STREET />
<STREET2 />
<STREET3 />
<STREET4 />
...... more data
</item>
then next customer master data and so on
- <item>
<CUSTOMERID>1000005</CUSTOMERID>
<COMPANY>ddfask</COMPANY>
<SHORT_NAME>;LK;L</SHORT_NAME>
<STREET />
<STREET2 />
<STREET3 />
<STREET4/>
etc etc until
<HKUNNR>60000</HKUNNR>
<SALES_REGION />
</item>
</IP_CUSTOMER_HEADER>
</rfc:Z_XI_005_RFC>
All I get on the Output target file
<?xml version="1.0" encoding="UTF-8" ?>
- <ns1:MT_customer_header xmlns:ns1="http://avenue.com/xi/test">
<CustomerId>1000001</CustomerId>
<company>One-time ship-to</company>
<shortname>ONE-TIME</shortname>
.... more data
</ns1:MT_customer_header>
the <item> and subsequent records all seem to have vanished.
I must be doing something PARTICULARLY stupid as nobody else ever seems to have this problem -- I've tried almost every possible combination but still to no avail
The function module is passing a table to XI in the correct structure and the payload seems to be fine so what on earth is broken here !!!,.
Cheers
JimboThanks everybody -- it's working now
RFC call was passing data correctly
function z_xi_005_rfc.
""Local interface:
*" TABLES
*" IP_CUSTOMER_HEADER STRUCTURE ZAP_CUSTOMER_INFO_2
endfunction.
in debug mode table data was fine -- in this instance 3 records were being passed.
3 errors in mapping etc fixed (with help from SDN - thanks)
1) missing the ITEM level in the Data type (hence mapping)
2) needed 0:unbounded in the occurrence
3) also mapping Item====>Item was missing (sub fields were ok)
Points awarded
final file output ok output now ok (with 3 fields only for testing)
<?xml version="1.0" encoding="UTF-8" ?>
- <ns1:MT_customer_header xmlns:ns1="http://avenue.com/xi/test">
- <item>
<Customerid>1000001</Customerid>
<company>One-time ship-to</company>
<shortname>ONE-TIME</shortname>
</item>
- <item>
<Customerid>1000005</Customerid>
<company>ddfask</company>
<shortname>;LK;L</shortname>
</item>
- <item>
<Customerid>1000010</Customerid>
<company>One Time Customer Test</company>
<shortname>SADFIWQEFG</shortname>
</item>
</ns1:MT_customer_header>
Now only the final problem to make file content conversion work.
Once again thanks --sometimes what seem trivial or simple problems take AGES to fix until someone else gives you a clue --that's why boards like SDN are great value.
Cheers
Jimbo -
How to apply data into 2 tables AND to more than one record in same table?
Hello,
I am trying to apply/insert data into 2 tables AND at the same time apply data to more than one record (in the same table). How would I do this in APEX?
I have updated using one table with no problem, however, when I try updating with the two tables/ multiple record sets, I get errors.
I appreciate the help.
Thanks.
LindaYou can achieve what you want using PL/SQL. Can you post ur code?
-
Hi,
I am using APEX_ITEM.SELECT_LIST_FROM_QUERY_XL(). When I try to fetch more than 1000 records in PL/SQL block .It throws character string buffer too small. I donot know how much records it will fetch because it is dynamically generated.
could you please anyone help me out.Hi
I agree that a popup LOV would be better, for two reasons:
1 - Even if you could construct a select list with over 1,000 items, users may find it awkward to use as they would have to scroll to find the item they want - at best they could type in the first character of an item but they'd have to scroll from then on or keep pressing the same character to move down one item at a time.
2 - The fact that you're using that function to generate the list implies that you are using a tabular form and, therefore, that there will be several instances of the list on your page. If so, the time taken to generate the page and download it may slow page load time considerably.
If you do need to have select lists, there are techniques that you can use to do this - typically, this would involve creating small lists in the form, a hidden select list created as a normal page item and then using javascript to copy the hidden list items into the tabular form fields.
Andy -
How to show more than one record at a form-like style report?
Hi All,
I developed a form-like style report
I want it to show more than one record at once (At the same page)
I tried that by setting the value to "Maximum records per page" property for the repeating frame to 10
but when I close the property palete and open it agian the value is returned to 1 !!!
how to show more than one record at the same page?????
Thank uHi,
there's perhaps another property like "page protect". If than 2 records didn't fit at one page there's a page break. Or is there any object inside the repeating frame with page-break properties? Sorry .. it's like looking into a chrystal ball ...
Regards
Rainer -
Master_detail for more than one record at a time
Hi,
How can i display master_detail records for more than one records at a time, for example, i have two tables A and B , A has username and role and B has username and profile. here i wanted to display 10 users at a time on my 6i form with username, role and profile.
i have created a master-detail relation ship with these tables when i'm executing F8 on blcok A , it displays 10 records on BlockA but, only one at a time on block B, how can i display all corresponding records on block B at a time.
Thanks for your help.BcjThanks Roberts, that was realy informative due to some doubts i would like to confirm my requirements , i have two blocks A and B and each master record has only one detail record. but i wanted to display at least 10 master_detail relationships(records) on the form at a time, i would like to know is it possible to do without creating any table or view for example,
data in table A,
username role
AAA R1
BBB R2
CCC R3
data in table B,
username profile
AAA P1
BBB P2
CCC P3
i wanted to display it on form like below,
username role profile
AAA R1 P1
BBB R2 P2
CCC R3 P3
Also would like to know that how can i select data from dba_users, any restriction is there on forms 6i, i can select it on sqlplus.
Thanks Again, Bcj -
In which IT To Date is not allowed & not having more than one record
Hi all,
Could you please tell me "In which IT To Date is not allowed & not having more than one record ?"
Thanks in advance
Regards,
AsiyaHi,
Just go through IT0003 and see if it fulfills the requirements or not.
Param -
Wanted to catch more than one record in selected rows
Hi all,
I am using the following function to catch the selected rows.
CALL METHOD w_grid->get_selected_rows
IMPORTING
et_index_rows = i_selected_rows.
it is catching only one row.
but i want to catch more than one record.
for example i will select more than one record from the grid and press the approve button. so that the status will change in the database.
but what is happening is if i select 2 or more records it is approving only first record. because in the i_selected_rows only first row is catching. what i have to do to catch other select rows also.
thanking u.
regards,
giri.Hi,
CALL METHOD w_grid->get_selected_rows
IMPORTING
et_index_rows = i_selected_rows[] ."<<<< try to put these into []
please not open multiple threads
a® -
How to return more than one record through OUT parameter in procedure
Hi,
I want to create a procedure which accepts one input and returns more than one record as output.
example:
Input = DeptNo
Output= Empno,ename,sal,comm,job
Scenario:
There can be more than one employee in department we pass as the IN parameter. OUT parameter has to return all the records of the corresponding employee details in that department.
Thanks in advance for your help
Regards,
K.Vijay-- I think you can try something like this using ref cursor:
-- create a package for the type ref cursor and execute
CREATE OR REPLACE PACKAGE PACK_REFCURSOR_FOR_TABLES AS
TYPE DATA_TableRows IS REF CURSOR;
END;
-- after executing the package above, create your procedure:
CREATE OR REPLACE PROCEDURE GET_EMP (
IN_nDeptNo IN number,
OUT_Emp OUT PACK_REFCURSOR_FOR_TABLES.DATA_TableRows)
IS
BEGIN
-- leave query open (implicit) as this will return data
OPEN OUT_Emp FOR
SELECT *
FROM tblEmp
WHERE DeptNo = IN_nDeptNo;
END;
--execute the procedure and you're done -
How can i select more than one record in a LOV
I want to select more than one record in a LOV and put them together before to display them in an item.
This is not possible with a default LOV, so you'll need to create your own. There are a number of ways to select multiple records:
a) you can use a tree and set Multi-Selection to Yes
2) you can use a normal block with a checkbox on each row for the user to select records
three) with the [SYSTEM.MOUSE_BUTTON_MODIFIERS|http://www.oracle.com/webapps/online-help/forms/10g/topics/designing_forms/mouse/at0604.html?tp=true] variable you can allow users to ctrl+click to select many records in a block. set the background colour to indicate a record has been selected
iv) there is a pjc in the [demo code section|http://download.oracle.com/otndocs/demos/Forms_Demos_10gr2.zip] which lets you select many rows in a poplist -
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 can I display more than one record with result set meta data?
Hi,
My code:
ArrayList<String> resultList = new ArrayList<String>();
rs=ps.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
while(rs.next()){
for(int k=1;k<=rsmd.getColumnCount();k++){
resultList.add(rs.getString(k));
ps.close();
}catch(Exception e){
e.printStackTrace();
return resultList;
public String test(ArrayList result)throws Exception{
String data=
"<tr>"+
"<td class=normalFont>"+result.get(0)+"</td>"+
"<td class=normalFont>"+result.get(1)+"</td>"+
"</tr>";
return data;
} All the things are wroking but the problem is that ArrayList is displaying just one record whereas I have more than 20 records to display. I tried with loop like: i<result.size(); and result.get(i) then its throwing exception
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 I stuck here for the last more than 2 days. Please help me
Best regardsRaakh wrote:
Still waiting .....I would have answered much earlier, but when I saw this little bit of impatience, I decided to delay answering for a while.
ArrayList<String> list = new ArrayList<String>();
list.add("abc");
list.add("def");
list.add("ghi");
System.out.println(list.get(0));
abc
System.out.println(list.get(1));
def
System.out.printnln(list);
[abc, def, ghi]That list has 3 items. Each one is a String.
But here is what you appear to be doing:
select * from person
+-----+-------------+-------------+--------+
| id | first name | last name | height |
+-----+-------------+-------------+--------+
| 1 | Joe | Smith | 180 |
+-----+-------------+-------------+--------+
| 2 | Mary | Jones | 144 |
+-----+-------------+-------------+--------+
for each row in ResultSet {
for each column in ResultSet {
list.add(that element);
// which becomes
list.add(1);
list.add("Joe");
list.add("Smith");
list.add(180);
list.add(2);
list.add("Mary");
list.add("Jones");
list.add(144);
System.out.println(list.get(0));
1
System.out.println(list.get(1));
Joe
System.out.printlN(list);
[1, Joe, Smith, 180, 2, Mary, Jones, 144]That list has 8 items. Some of them are Strings and some of them are Integers. I would assume that, for this sample case, you would want a list with 2 items, both of which are Person objects. However, it really isn't clear from your posts what you are trying to do or what difficulty you're having, so I'm just guessing. -
How to update more than one records at one time
hello guys..
how to update a few records (more than one) with different
IDs at the same time? i tried to make a query like this (see
below), but only one record (more than one data in the same
field)has been updated.
<cfquery name="rec" datasource="DatKoku">
select *
from tbl_pilih
where id_pel = '#form.idpel#'
</cfquery>
<cfquery name="updtrecord" datasource="DatKoku">
update tbl_pilih
set
kptsn = '#form.suk_pil#',
trkh_kptsn =
'#Dateformat(TodayDate,"dd/mm/yy")#|#TimeFormat(Now(),"hh:mm:ss
tt")#'
where id_pel = '#rec.id_pel#'
</cfquery>
<cfquery name="outputrecord" datasource="DatKoku">
select *
from tbl_pilih
where id_pel = '#form.idpel#'
</cfquery>Take the query,
<cfquery name="rec" datasource="DatKoku">
select *
from tbl_pilih
where id_pel = '#form.idpel#'
</cfquery>
If every row in the table has a distinct id_pel, then what
you ask is actually an impossible question. It will have no answer.
Distinct IDs imply that the resultset will contain
at most one distinct value of id_pel. That means, there can
be at most one row that satisfies the condition,
where id_pel = '#rec.id_pel#' in the update query. That in
turn means the update query can update at most one row at a time.
If, however, the resultset of
rec consists of multiple rows, it will mean that there are
multiple rows in the table that have the same
id_pel . Then, your update query,
updtrecord, should update all the rows that share that value
of id_pel. -
How can i insert more than one record a time in a JSP page?
Hi experts,
I'm working with JDeveloper version 3.2 application server 9i.
I want to insert more than 1 record using a jsp page and then perform a commit at the end.
do you can help me with this problem/challenge?
Thank you,
Regards,
Mariostatement.executeBatch() maybe?
Maybe you are looking for
-
How can I make a decorative page border in Pages?
How can I make a decorative page border in Pages?
-
Executing an OS command from web PL/SQL
Hi, I'm developing a web application with the PL/SQL web toolkit. A link on one of the screens needs to be able to start a batch file on the server (Win2000). Two questions: - How an executable or batch file on the operating system be started from a
-
Multiple output type against a billing type
Hi All, I have a small requirement, I have created 2 output types and I want to assign it to the same billing document. As per requirement, I can choose 2 different prints for same document. But, when I am checking through issue output to through a b
-
Where do I get the BRITISH English version of Firefox 15.0.1 for a downgrade?
I want to downgrade Firefox to v15.0.1, but US English versions are the only old versions I an find. Where do I get old BRITISH English versions?
-
Does Captivate 2 work in Windows 7?
Yes I know everyone will think it's incredible that we've still got Captivate 2 but it was running fine up until we got Windows 7 installed at work. We can get it to load up but it's not recording properly. Thanks anyone for your help! Jane