for cursor loop
Hi all!IAM using the coding according to the button click on the trigger of my block...
declare
cursor c1 is
select employeeid
from empmgt.emp_reporting
where reporting_officer = :purchase_login.username;
begin
first_record;
for c1rec in (select employeeid
from empmgt.emp_reporting
where reporting_officer = :purchase_login.username)
loop
:purchase_indent1.employee_id := c1rec.employeeid;
if :purchase_indent1.employee_id=c1rec.employeeid then
select employee_id,employee_name,designation,division_section,
indent_no,apply_date,project_no,detailed_spec,quantity,
estimated_cost,total,proprietor,proprietor_name,distributor,deadline_delivery,required_date,
install_availability,available_vendors,pl_approval
into
:purchase_indent1.employee_id,:purchase_indent1.employee_name,:purchase_indent1.designation,
:purchase_indent1.division_section,:purchase_indent1.indent_no,:purchase_indent1.apply_date,
:purchase_indent1.project_no,:purchase_indent1.detailed_spec,:purchase_indent1.quantity,
:purchase_indent1.estimated_cost,:purchase_indent1.total,:purchase_indent1.proprietor,
:purchase_indent1.proprietor_name,:purchase_indent1.distributor,:purchase_indent1.deadline_delivery,
:purchase_indent1.required_date,:purchase_indent1.install_availability,:purchase_indent1.available_vendors,:purchase_indent1.pl_approval
from
purchase.purchase_indent
where
*employee_id=c1rec.employeeid;*
end if;
next_record;
end loop;
exception when no_data_found then
:purchase_indent1.employee_id:='';
message('');
end;
first_record;
declare
cursor c1 is
select employeeid
from empmgt.emp_reporting
where reporting_officer = :purchase_login.username;
begin
first_record;
for c1rec in (select employeeid
from empmgt.emp_reporting
where reporting_officer = :purchase_login.username)
loop
:purchase_indent1.employee_id := c1rec.employeeid;
if :purchase_indent1.employee_id=c1rec.employeeid then
select employee_id,employee_name,designation,division_section,
indent_no,apply_date,project_no,detailed_spec,quantity,
estimated_cost,total,proprietor,proprietor_name,distributor,deadline_delivery,required_date,
install_availability,available_vendors,pl_approval
into
:purchase_indent1.employee_id,:purchase_indent1.employee_name,:purchase_indent1.designation,
:purchase_indent1.division_section,:purchase_indent1.indent_no,:purchase_indent1.apply_date,
:purchase_indent1.project_no,:purchase_indent1.detailed_spec,:purchase_indent1.quantity,
:purchase_indent1.estimated_cost,:purchase_indent1.total,:purchase_indent1.proprietor,
:purchase_indent1.proprietor_name,:purchase_indent1.distributor,:purchase_indent1.deadline_delivery,
:purchase_indent1.required_date,:purchase_indent1.install_availability,:purchase_indent1.available_vendors,:purchase_indent1.pl_approval
from
purchase.purchase_indent
where
*pl_approval!='Approved';*
end if;
next_record;
end loop;
exception when no_data_found then
:purchase_indent1.employee_id:='';
message('');
end;
first_record;
Now the first code works well separately... The second code does not work now... It shows the errorora-01422 TOO MANY ROWS
So do you mean I should go nested cursors? or is there another solution?pls help to solve this problem!
Thanks and greetings
user 10685325
Published by: user10685325 on May 11, 2009 01:03
I think I understand your problem.
Rownum is an option, but not the solution as an assistant said.
See, the first query works well because you have expicitly mentioned in where clause here the condition:
employee_id = c1rec. EmployeeID;
so, it will return you a rank only, but in the second query, you gave pl_approval! = 'Approved'; who certainly will return multiple lines like pl_approval me, this is a pretty generic column.
In my opinion you need to change your code something like this:
select employeeid into :purchase_indent1.employee_id
from empmgt.emp_reporting
where reporting_officer = :purchase_login.username);
if :purchase_indent1.employee_id is not null then --or you can check something else for validity
For c1 in (
select employee_id,employee_name,designation,division_section,
indent_no,apply_date,project_no,detailed_spec,quantity,
estimated_cost,total,proprietor,proprietor_name,distributor,deadline_delivery,required_date,
install_availability,available_vendors,pl_approval
from
purchase.purchase_indent
where
*pl_approval!='Approved'* )
loop
:purchase_indent1.employee_id := c1.employee_id;
:purchase_indent1.employee_name := C1.employee_name;
Similarly copy all the data block items from the cursor variable
next_record;
end loop;
end if;
exception when no_data_found then
:purchase_indent1.employee_id:='';
message('');
end;
first_record;
You can change this code a bit according to your need, but I think that's what you want rather than what you wrote.
It may be useful
Please try it once and let me know if it works...
Check the answer as useful / OK, if this can help you
Carole
Published by: Carole Punj on May 11, 2009 03:19
Tags: Oracle Development
Similar Questions
-
only the update by removing for cursor loop
Hello
I have the cursor for loop below update a flag. Need to convert the single update by removing the loop.
po_date po_number BLACK flag
123 123 - 1 12 December 2015
123 123 - 2 December 15, 2015
123 123 - 3 December 21, 2016
Result
=====
po_date po_number BLACK flag
123 123 - 1 12 December 2015 MUL
123 123 - 2 15 December 2015 MUL
123 123 - 3 December 21, 2016
So, if there are several BLACK for a PO_number, then Mark flag = "MUL" for the two records which are min as the max po_date.
I'm in select * from alm_po_quotes
loop
Update alm_po_quotes
flag of the value = 'MUL '.
where po_number = i.po_number
and
po_date < (select MAX (po_date) in the alm_po_quotes where po_number = i.po_number);
end of loop
Commit
Please notify.
Thank you
In your update, simply add the clause as below
-Statement to merge
MERGE INTO alm_po_quotes apq
USING (SELECT MAX (po_date), mxpo_date,
APQ.po_number
Of alm_po_quotes apq
GROUP BY apq.po_number
After HAVING COUNT (DISTINCT apq.crno) > 1
) q1
WE (apq.po_number = q1.po_number
AND apq.po_date<>
WHEN MATCHED THEN
UPDATE SET apq.flag = 'MUL '.
;
-Update statement
UPDATE alm_po_quotes apq SET apq.flag = 'MUL '.
WHERE apq.po_date< (select="" max(po_date)="">
Of alm_po_quotes apq1
WHERE apq.po_number = apq1.po_number
GROUP BY apq1.po_number
After HAVING COUNT (DISTINCT apq1.crno) > 1
);
OUTPUT:-
=======
PO_NUMBER CRNO PO_DATE FLAG 123 123 1 12/12/2015 MUL 123 123 2 15/12/2015 MUL 123 123 3 21/12/2016 - -
Avoid calling the procedure in the cursor loop
Hi all
The following example of procedure the procedure written in cursor loop, is called each time until the end of the cursor loop...
What would be the alternative methods to write the procedure above instead to call the procedure inside the cursor for loopprocedure proc_main is DECLARE cursor c1 is select e.empno empno ,e.ename ename ,d.dname dname ,d.loc loc from emp e,dept d where e.deptno = d.deptno ; BEGIN for i in c1 LOOP proc_test(i.empno,i.ename,i.dname,i.loc) ; end loop; END; ----------- PROCEDURE proc_test (p_empno,p_ename,p_dname,p_loc) is --- --- begin select * into v1,v2,v3 .. from temp_tab where col1 =p_empno ---- ---- end;
My idea is to use collections... could you give me the code example using collections to meet the above criteria
Thank you
Published by: smile on February 28, 2012 15:45The ideal would be to collect all SQL logic and put as much of it in a single SQL statement as possible. It would be also great to determine what is the final outcome of the process and use it as a starting point for your SQL. For example, if the desired result is to upgrade the salaries of the employees where they have an entry in table x, you might find that you can avoid needing to separate the logic between multiple, i.e. instead of procedures
procedure proc_main is DECLARE cursor c1 is select e.empno empno ,e.ename ename ,d.dname dname ,d.loc loc from emp e,dept d where e.deptno = d.deptno ; BEGIN for i in c1 LOOP proc_test(i.empno,i.ename,i.dname,i.loc) ; end loop; END; ----------- PROCEDURE proc_test (p_empno,p_ename,p_dname,p_loc) is --- --- begin select * into v1,v2,v3 .. from temp_tab where col1 =p_empno ---- ---- UPDATE emp e SET sal = v2 WHERE e.empno = p_Empno; end;
You may simply have
procedure proc_main is BEGIN UPDATE emp e SET sal = ( SELECT t.new_sal FROM temp_tab t WHERE t.empno = e.empno ) WHERE EXISTS ( SELECT NULL FROM temp_tab t WHERE t.empno = e.empno ); END;
Even if your logic is more complex, you are likely to find that you can merge several of the statements that you could be running in a loop and replace that loop with a join.
Given the particular structure of what you posted if, instead of calling the procedure in a loop, you can simply move the cursor c1 as a parameter to proc_test that is
procedure proc_main is lc_c1 sys_refcursor; BEGIN OPEN lc_c1 FOR select e.empno empno ,e.ename ename ,d.dname dname ,d.loc loc from emp e,dept d where e.deptno = d.deptno ; proc_test(c1) ; END; ----------- PROCEDURE proc_test (p_Cursor sys_refcursor) is begin LOOP FETCH .... ...DO SOMETHING... EXIT WHEN p_Cursor%NOTFOUND; END LOOP; CLOSE p_Cursor; END;
But I highly recommend that you consider trying to merge as much of your SQL before considering the approach of cursor.
HTH
David
-
Hi all
I face a problem of cursor loop. My table got 4 record, but it loop 5 times.
CREATE OR REPLACE PROCEDURE PLOTTER. TRACER_SEARCH_SCHEDULE_BW
IS
number of c_job_id;
c_lot_no varchar (4000);
number of c_generation;
c_facility varchar (30);
-get all pending calendar backward
CURSOR cur_backward_schedule
IS
SELECT JOB_ID, LOT_NO, GENERATION, INSTALLATION
OF TRACER_SEARCH_SCHEDULE
WHERE PROCESS_STATUS = 'Pending' AND TRACE_TYPE = "backwards".
ORDER BY JOB_ID;
BEGIN
OPEN cur_backward_schedule.
LOOP
EXTRACT the cur_backward_schedule IN c_job_id, c_lot_no, c_generation, c_facility;
DBMS_OUTPUT. Put_line (cur_backward_schedule % RowCount);
-split and insert into TRACER_TEST_TABLE
insert into TRACER_TEST_TABLE (installation, lot_no, generation)
Select * from table (select SPLIT_LOT (installation, lot_no, generation) in tracer_search_schedule where job_id = c_job_id);
EXIT WHEN cur_backward_schedule % ROWCOUNT > cur_backward_schedule % COUNTY or cur_backward_schedule NOTFOUND;
END LOOP;
CLOSE Cur_backward_schedule;
COMMIT;
END;
/
for above DBMS_OUTPUT. Put_line, it shows that
1
2
3
4
4
Published by: skymonster84 on March 23, 2010 16:47What is the problem with just a simple use of OUTPUT after EXTRACTION...
CREATE OR REPLACE PROCEDURE TRACER.TRACER_SEARCH_SCHEDULE_BW IS c_job_id number; c_lot_no varchar(4000); c_generation number; c_facility varchar(30); --get all pending backward schedule CURSOR cur_backward_schedule IS SELECT JOB_ID, LOT_NO, GENERATION, FACILITY FROM TRACER_SEARCH_SCHEDULE WHERE PROCESS_STATUS = 'Pending' AND TRACE_TYPE = 'Backward' ORDER BY JOB_ID; BEGIN OPEN cur_backward_schedule; LOOP FETCH cur_backward_schedule INTO c_job_id, c_lot_no, c_generation, c_facility; EXIT WHEN cur_backward_schedule%NOTFOUND; DBMS_OUTPUT.PUT_LINE(cur_backward_schedule%ROWCOUNT); --split and insert into TRACER_TEST_TABLE insert into TRACER_TEST_TABLE (facility, lot_no, generation) select * from table(select SPLIT_LOT(facility, lot_no, generation) from tracer_search_schedule where job_id=c_job_id); --EXIT WHEN cur_backward_schedule%ROWCOUNT > cur_backward_schedule%COUNT or cur_backward_schedule%NOTFOUND; END LOOP; CLOSE cur_backward_schedule; COMMIT; END; /
-
Possibility to use the Enum control as an index for the loop entry For
Hello world
I'm curious to know if an ENUM type could be an index entry for a loop For (in fact, I tried in labview but it did NOT work).
I use Enum to my two configurations (only two elements), but sometimes I need to run the two together.
I wonder if it has a good structure to manage it, or simply replace ENUM with table.
Thank you
-Kunsheng
Here is an example of use of the nodes of property:
-
TestStand blocks by "for each" loop
TestStand crashes from time to time for unknown reasons. We believe that 'foreach' loops could be the reason. By replacing the "for each" loop with a loop and iterate using the index, the problem is solved.
Is this a known problem in Teststand? Is it possible that this is resolved in Teststand 4.1 (we use 4.0.1)?
Kind regards
Jeroen Coulembier
This looks exactly like a previous problem (98902) report, which has been fixed in 4.1.
-
Why loops run after that assignment of processors for timed loops?
I have 256 call loops of two frames in my code. When I execute the code without affecting processors only 128 call loop runs at the same time, however when I attribute a different processor to each of them (0-255) then only 4 runs at the same time. Why is this? How can I make all run simultaneously?
Attached: two snapshots of the code. 1 shows a small portion of the call loops, and the other is the part of code that communicates with an FPGA VI which controls the status of the outputs (using a CRio-9066.) For call loops, the small Sun icon is a Subvi, which generates values for the time delay dt call loops.
doug333 wrote:
They run on the computer VI and I don't know how many processors available I!
Windows? If this is the case, don't bother with call loops. They add overhead and you're very unlikely to get something from him. Even basic affinity rarely helps. Normal just use While loop with a ms funtion in here waiting.
-
Hello:
I'm fighting with digital table of 1 d writeing in a binary file and start a new line or insert a separator for each loop writing file. So for each loop, it runs, LABVIEW code will collect a table 1 d with 253 pieces of a spectrometer. When I write these tables in the binay file and the following stack just after the previous table (I used MATLAB read binary file). However whenever if there is missing data point, the entire table is shifted. So I would save that table 1-d to N - D array and N is how many times the loop executes.
I'm not very familiar with how write binary IO files works? Can anyone help figure this? I tried to use the file position, but this feature is only for writing string to Bodet. But I really want to write 1 d digital table in N - D array. How can I do that.
Thanks in advance
lawsberry_pi wrote:
So, how can I not do the addition of a length at the beginning of each entry? Is it possible to do?
On top of the binary file write is a Boolean entry called ' Prepend/chain on size table (T) '. It is default to TRUE. Set it to false.
Also, be aware that Matlab like Little Endian in LabVIEW by default Big Endian. If you probably set your "endianness" on writing binary file as well.
-
Any built-in support for cursors on the graph and trend curves
Hello
I went through the documentation to verify that no support exists to draw trend lines and using the slider on the axis (bargraph) but could not find anything related to it. Can you please confirm if there is any built-in support for cursors/trend lines in the component ojchart (bar graph) of the current version of JET.
Thank you
Subhash
Hi Adoni,
Due to the large number of possible algorithms, we do not provide built in calculation for trend lines. Our goal is rather to ensure that the user can display trend lines what they calculated, with the right amount of interactivity support. We have a very basic demo of this feature in the Cookbook: Oracle JET - graphics - Custom graphics: trendline. In this demonstration, we recommend using reference objects, rather than additional series, because the objects of reference do not allow a user to interact with the individual points or use features such as selection or drilling, which would be undesirable for a trend line.
On the second question, could you give more details on this cursor you are referring? We have two ways to use our zoom and scroll feature:
- Preview: Oracle JET - graph - Zoom & scroll: the time axis
- Simple scrollbar: Oracle JET - graph - Zoom & scroll: categorical axis
Thank you
Hugh
-
Hey people,
I've heard for loops is the best way to accomplish what I need. With my level of coding, I try to have that when all checkbox States are true, then a specific image. the question is when I was using earphones of events within each of the mouse click events, this would trigger the click on the ninth all the conditions would be met. The syntax for a loop seems daunting, is it possible to run my function, so it is always "listening" or will run eimmeidatley if the conditions are met?
OFbandSEVENclose.addEventListener (MouseEvent.CLICK, OnFRYERbandSEVENclose);
function OnFRYERbandSEVENclose (e: MouseEvent): void
{
gotoAndPlay (1);
}
OFbandSEVENcheckONE.visible = false;
OFbandSEVENcheckTWO.visible = false;
OFbandSEVENcheckTHREE.visible = false;
OFbandSEVENcheckFOUR.visible = false;
OFbandSEVENcheckFIVE.visible = false;
OFbandSEVENcheckSIX.visible = false;
OFbandSEVENcheckSEVEN.visible = false;
OFbandSEVENcheckEIGHT.visible = false;
OFbandSEVENcheckBUTTON1.addEventListener (MouseEvent.CLICK, checkbuttonONE, false, 0, true);
function checkbuttonONE(e:Event):void
{
If (OFbandSEVENcheckONE.visible == true) {}
OFbandSEVENcheckONE.visible = false;
} else {}
OFbandSEVENcheckONE.visible = true;
}
}
OFbandSEVENcheckBUTTON2.addEventListener (MouseEvent.CLICK, checkbuttonTWO, false, 0, true);
function checkbuttonTWO(e:Event):void
{
If (OFbandSEVENcheckTWO.visible == true) {}
OFbandSEVENcheckTWO.visible = false;
} else {}
OFbandSEVENcheckTWO.visible = true;
}
}
OFbandSEVENcheckBUTTON3.addEventListener (MouseEvent.CLICK, checkbuttonTHREE, false, 0, true);
function checkbuttonTHREE(e:Event):void
{
If (OFbandSEVENcheckTHREE.visible == true) {}
OFbandSEVENcheckTHREE.visible = false;
} else {}
OFbandSEVENcheckTHREE.visible = true;
}
}
OFbandSEVENcheckBUTTON4.addEventListener (MouseEvent.CLICK, checkbuttonFOUR, false, 0, true);
function checkbuttonFOUR(e:Event):void
{
If (OFbandSEVENcheckFOUR.visible == true) {}
OFbandSEVENcheckFOUR.visible = false;
} else {}
OFbandSEVENcheckFOUR.visible = true;
}
}
OFbandSEVENcheckBUTTON5.addEventListener (MouseEvent.CLICK, checkbuttonFIVE, false, 0, true);
function checkbuttonFIVE(e:Event):void
{
If (OFbandSEVENcheckFIVE.visible == true) {}
OFbandSEVENcheckFIVE.visible = false;
} else {}
OFbandSEVENcheckFIVE.visible = true;
}
}
OFbandSEVENcheckBUTTON6.addEventListener (MouseEvent.CLICK, checkbuttonSIX, false, 0, true);
function checkbuttonSIX(e:Event):void
{
If (OFbandSEVENcheckSIX.visible == true) {}
OFbandSEVENcheckSIX.visible = false;
} else {}
OFbandSEVENcheckSIX.visible = true;
}
}
OFbandSEVENcheckBUTTON7.addEventListener (MouseEvent.CLICK, checkbuttonSEVEN, false, 0, true);
function checkbuttonSEVEN(e:Event):void
{
If (OFbandSEVENcheckSEVEN.visible == true) {}
OFbandSEVENcheckSEVEN.visible = false;
} else {}
OFbandSEVENcheckSEVEN.visible = true;
}
}
OFbandSEVENcheckBUTTON8.addEventListener (MouseEvent.CLICK, checkbuttonEIGHT, false, 0, true);
function checkbuttonEIGHT(e:Event):void
{
If (OFbandSEVENcheckEIGHT.visible == true) {}
OFbandSEVENcheckEIGHT.visible = false;
} else {}
OFbandSEVENcheckEIGHT.visible = true;
}
}
THE FINAL SCREEN =.
function OFbandSEVENCOMPLETE(e:Event):void
{
If (OFbandSEVENcheckONE.visible == true & & OFbandSEVENcheckTWO.visible == true & & OFbandSEVENcheckTHREE.visible == true & & OFbandSEVENcheckFOUR.visible == true & & OFbandSEVENcheckFIVE.visible == true & & OFbandSEVENcheckSIX.visible == true & & OFbandSEVENcheckSEVEN.visible == true & & OFbandSEVENcheckEIGHT.visible == true) {}
gotoAndPlay (12);
}
}
Stop();
I see the problem:
check .visble [n-1] =! check .visible [n-1];
must be visible not folded down
-
is their an order for a loop. something like sym.loop("") or this. Sound.Loop(""). I especially need for two work to complete an audio file.
Thank you.
Hey, sabermaster -.
Not at the moment, but you can create your own effects loop using triggers on the timeline. What specific features do you want?
-Elaine
-
Hi there, new ActionScript in general, I have this code snippet I want again and again for always loop:
Quote:
If (controlID.text == "2") {}
trace ("worked");
} else {}
trace ("failed");
} -
Hello
I try to use for each loop:
FE Agreement_No
Customer
0.00
0.00 <? end foreach? >
It does not work. The FE code should be grouped?
Can anyone help?
Thank youCan you send me the files?
-
My instructions of tracing inside ma for each loop will not appear.
Please someone check my code. I'm no errors in flex builder. When I debug all vars are holding data prober. Thank you very much
"essa tkinen"
wrote in message
News:gr27rt$3SB$1@forums. Macromedia.com...
> Yes there are data there is a list of comma delimited keywords that are
> catagorys. the selectedCatArray holds to a list item. I want to
> returns true if the item is in this listOn the one hand, you will leave this function in the first round,
because you return the result inside the loop. Return immediately leave him
function. On the other hand, I am tempted to move on to something more like
this:for (var i = 0; i)<_item.cats.length; i++)="">
iCat var = item.cats ;
do your business here
}I had really bad luck to get for each to work the way I think that it
expected.HTH;
Amy
-
Cursor implicit FOR THE LOOP and WHERE CURRENT OF
Is it possible to add some updates and WHERE CURRENT OF for an implicit cusror of LOOPS? There seems to be no way to reference the cursor as you can with an explicit cursor.
BEGIN
FOR point IN)
SELECT last_name, job_id
Employees
WHERE job_id LIKE '% % CLERK '.
AND manager_id > 120
ORDER BY name
)
LOOP
...
...
...
END LOOP;
END;
/
Thank you
It must be an explicit cursor.
Maybe you are looking for
-
How to remove an email address when sending to a group
The Mac mini subscribed to Thunderbird because Mail/Comcast could receive but not send messages. I have groups listed in the address book. I can choose a group and Thunderbird sends BCC very well. I want to be able to eliminate some of the members of
-
HelloI just used the firefox sync, but it's just to put my favorites on my new computer. Then delete everything off my original computer. If I delete the bookmark on my old computer sync so will remove them on the new computer?
-
ENVY 15 laptop t: remove the back of the laptop (aluminum housing) ENVY
I am wanting to add an SSD 2.5 "to my computer laptop but how do you get the back without damaging the metal case?
-
I discovered a strange behavior of the method "to more specific class '... I use LV2011SP1. My request: I have an application that analyzes a collection of blobs of data, with each blob of data defined by a class of LV. Each of these blobs of data in
-
Update error message 09370001 dt000
I get an important message updated necessary. When I try to install it, it creates a restore point and then fails to install. error message 09370001 dt000. When I try to find info on the error message there is nothing to find. What's up windows