Counter - loop
Hello
I found this script in this forum.
The animation plays only once, but he should play six times...
Where is the error?
Thanks for your support!
Taking into sym.stop () inch of the end solve one of your problems, so do not do this, but there are two other issues here.
(1) your variables are incorrectly interchanged in the if statement.
At the present time, it is said: sym.setVariable ("countNum", ++ counter);
It must be said: sym.setVariable ("counter", ++ countNum);
(2) your if statement is always true, because you set the counter to 0 in each loop. This means that the animation will play very much, not only 6 times.
You must move the sym.setVariable ("counter", 0); to a point in time before the start of the loop. For example, in the new trigger to 0ms.
Tags: Edge Animate
Similar Questions
-
Integer from push the button inside of a counting loop
Hi all
I am currently working on a gui training. I am fairly new with labview and would appreciate any comments.
My main problem is in the lower left corner of the main loop. I hope to spend a whole in one number for each press of the button "Logging_EDACS".
I have problems with the main loop stuck. I did experiment with the condition of the loop to stop (I realize that the way it is Setup will not work now)
Again, I think that the main problem is with the loops.
Any help would be greatly appreciated.
Thank you very much
Kevin
First, you must read some tutorials. That said, I see what your problem is. Whenever your big loop performs an iteration, the smaller its shift register is reset to 0. If you still have 0 + 1 = 1. In fact, you don't even have this 'small' while loop, you just registers to offset a large.
Run with highest point running and you will be able to see what is happening.
-
I use
APEX_ITEM. CHECKBOX2)
p_idx => 1,
p_value = > ROWNUM.
p_attributes = > 'OFF ',.
p_checked_values = > NULL,
p_checked_values_delimiter = > ':',
p_item_id = > ' f01_ #ROWNUM #'.
p_item_label = > 'Label' for f01_ #ROWNUM #) "Select".
Suppose that there are ten checkboc on one page
PLSQL process when I use
-----------------------------------------------------------------------------------------
BECAUSE me in 1... APEX_APPLICATION. G_F01. COUNTING LOOP
When I click on box 5
declare
Start
insert into tablename values (APEX_APPLICATION. G_F01 (i);
end;
and use insert process itakes i = 1
----------------------------------------------------------------------------------------------------------
When using
declare
c = APEX_APPLICATION. G_F01 (i);
raise_application_error (-20001, c);
and use
Start
insert into tablename values (APEX_APPLICATION. G_F01 (c);
end;
then he gives no data found for rest of the uncontrolled boxes and c = 5;
Aiming:
https://community.Oracle.com/thread/1077806?TSTART=0
https://Apex.Oracle.com/pls/OTN/f?p=40323:1:1819542231041:no:
with the help of the above code, it worked
-
An associative array, how the records using the loop counter?
In the associative array, how the records using the loop counter? for example
declare type population is table of number index by varchar2(64); city_population population; begin city_population('Samillve') := 200; city_population('Lindenhurst') := 300; for i in 1 .. city_population.count loop dbms_output.put_line(city_population(i)); -- compiler error end loop; end; /
That would look like
SQL> ed Wrote file afiedt.buf 1 declare 2 type population is table of number index by varchar2(64); 3 city_population population; 4 l_index varchar2(64); 5 begin 6 city_population('Samillve') := 200; 7 city_population('Lindenhurst') := 300; 8 l_index := city_population.first; 9 while( l_index IS NOT NULL ) 10 loop 11 dbms_output.put_line(city_population(l_index )); 12 l_index := city_population.next(l_index); 13 end loop; 14* end; SQL> / 300 200 PL/SQL procedure successfully completed.
Justin
-
Hi all!
I learn PL/SQL on the book by Steve Bobrovsky (specified below, sample comes from it) and I have a question.
In the procedure of the below specified program used a currentElement integer variable to get the reference to the line in the nested table of data type % ROWTYPE.
Meanwhile, the program itself uses a common FOR... LOOP counter I have.
When I substituted a global variable of INTEGER type such for... The LOOP counter, an APEX have returned an error "ORA-01403: no data found.DECLARE TYPE partsTable IS TABLE OF parts%ROWTYPE; tempParts partsTable := partsTable(); CURSOR selectedParts IS SELECT * FROM parts ORDER BY id; currentPart selectedParts%ROWTYPE; currentElement INTEGER; PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS BEGIN DBMS_OUTPUT.PUT_LINE(' '); DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT); currentElement := p_collection.FIRST; FOR i IN 1 .. p_collection.COUNT LOOP DBMS_OUTPUT.PUT('Element #' || currentElement || ' is '); IF tempParts(currentElement).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.'); ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(currentElement).id || ' DESCRIPTION: ' || tempParts(currentElement).description); END IF; currentElement := p_collection.NEXT(currentElement); END LOOP; END printParts; BEGIN FOR currentPart IN selectedParts LOOP tempParts.EXTEND(2); tempParts(tempParts.LAST) := currentPart; END LOOP; printParts('Densely populated', tempParts); FOR i IN 1 .. tempParts.COUNT LOOP IF tempParts(i).id is NULL THEN tempParts.DELETE(i); END IF; END LOOP; FOR i IN 1 .. 50 LOOP DBMS_OUTPUT.PUT('-'); END LOOP; printParts('Sparsely populated', tempParts); END; /
When I tried to manage this code in SQL * Plus, the following picture emerged:DECLARE TYPE partsTable IS TABLE OF parts%ROWTYPE; tempParts partsTable := partsTable(); CURSOR selectedParts IS SELECT * FROM parts ORDER BY id; currentPart selectedParts%ROWTYPE; PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS BEGIN DBMS_OUTPUT.PUT_LINE(' '); DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT); FOR i IN 1 .. p_collection.COUNT LOOP DBMS_OUTPUT.PUT('Element is '); IF tempParts(i).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.'); ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(i).id || ' DESCRIPTION: ' || tempParts(i).description); END IF; END LOOP; END printParts; BEGIN FOR currentPart IN selectedParts LOOP tempParts.EXTEND(2); tempParts(tempParts.LAST) := currentPart; END LOOP; printParts('Densely populated', tempParts); FOR i IN 1 .. tempParts.COUNT LOOP IF tempParts(i).id is NULL THEN tempParts.DELETE(i); END IF; END LOOP; FOR i IN 1 .. 50 LOOP DBMS_OUTPUT.PUT('-'); END LOOP; printParts('Sparsely populated', tempParts); END; /
What's not in the code (or what I did not understand)? Help please!Densely populated elements: 10 Element is an empty element. Element is ID: 1 DESCRIPTION: Fax Machine Element is an empty element. Element is ID: 2 DESCRIPTION: Copy Machine Element is an empty element. Element is ID: 3 DESCRIPTION: Laptop PC Element is an empty element. Element is ID: 4 DESCRIPTION: Desktop PC Element is an empty element. Element is ID: 5 DESCRIPTION: Scanner -------------------------------------------------- Sparsely populated elements: 5 DECLARE * ERROR at line 1: ORA-01403: no data found ORA-06512: at line 14 ORA-06512: at line 35
Your error occurs because you are dealing with a sparsely populated collection and using an index for items that do not exist.
For collections of the low density of population, you must iterate through using FIRST and THEN as modeled not from 1 to COUNT.
The crucial difference between your code and the example is:
tempParts(i)
Which, as you have demonstrated, doesn't work very well (!) if there is no item (i).
The code example is a little unusual in my opinion.
currentElement := p_collection.FIRST; FOR i IN 1 .. p_collection.COUNT LOOP ... currentElement := p_collection.NEXT(currentElement); END LOOP;
It works, but it's an unusual way to iterate through a collection of rare which is perhaps most often done like this:
currentElement := p_collection.FIRST; WHILE(currentElement IS NOT NULL) LOOP ... currentElement := p_collection.NEXT(currentElement); END LOOP;
Which is perhaps less open to confusion.
In the end, the distinction between
tempParts(currentElement).id
and
tempParts(i).id
is crucial.
-
DLL slows parrellel while loop
Hello
I am changing a VI I wrote, to work with another piece of equipment. Communication tends to work directly through labVIEW. My new equipment provided with a driver/dll library and now I have many layers before reaching the material (LabVIEW-> driver-> software-> the measuring equipment). I have some time this account down to run alongside my Subvi who manages my method of measurement of the loop. As I put in place the screw that call DLLs that count - while loop slows down in the same frequency, I'm calling the dll. I've changed the "Run in the user interface thread" setting to the "Run in any thread" option in the call library function node. In fact, which got rid of my problem about 90%. But my meter still comes in a few seconds at the end. I wonder in what sense the crux of library function call delayed a seemingly parallel thread?
Any suggestion on the place where to continue searching for a fix?
Welcome them
/ Lorenz
It is hard to tell what might work without knowing your DLL and what he actually did, but I see something in your loop that will force LabVIEW to toggle the user interface thread! The property node to update the text of the start_method th button will ALWAYS force a change of context for the UI thread. If you can avoid this really should not be possible for the DLL block your loop more. At least try to not update this property if it needs to be changed with regard to the previous value and not at each iteration of the loop.
A guess is that the DLL actually interfaces to ActiveX code somehow. LabVIEW initializes its ActiveX environment to run in the UI thread, because it is the only safe thread system in LabVIEW to perform many threaded ActiveX components or when the data marshaling is involved. If your DLL tries also to connect to an ActiveX interface, it will be forced to go the UI thread that explains how to access the property in your loop can get delayed.
And another problem you have is the moment of software. count you down the loop increments of 10 ms, but Windows will be hardpressured for hard real-time performance. While you are not using the "wait until the next ms Multiple" to take account of some jitter, if the loop is blocked for more than 10 ms through an external resource, you will actually jump an interval.
Better would be to calculate the time elapsed directly reading the timer tick before entering the loop, then use the output of graduation of timer her to "wait until the next ms Multiple" to calculate the difference. Dividing this difference by 10, and then adding your counter value initial this result would give you the same value that you feed your VI calculation, but what about the real system clock, not a counter loop running asynchronously with questionable interval.
-
Best practices with the sliders with loops
I have the following code:
Declare CURSOR c_contacts_cursor IS SELECT OUTLET_CODE, OUTLET_NAME, CONTACT_NAME, MOBILE_NO, ALT_NO, ADDRESS1, ADDRESS2, CITY, POSTCODE, EMAIL FROM SYNC_CONTACTS WHERE (source = 'W' OR SOURCE = 'T') AND SURVIVAL_FLAG = 'Y'; TYPE temp_string IS TABLE OF VARCHAR2 (2000); V_OUTLET_CODE temp_string; V_OUTLET_NAME temp_string; V_CONTACT_NAME temp_string; V_MOBILE_NO temp_string; V_ALT_NO temp_string; V_ADDRESS1 temp_string; V_ADDRESS2 temp_string; V_CITY temp_string; V_POSTCODE temp_string; V_EMAIL temp_string; BEGIN OPEN c_contacts_cursor; FETCH c_contacts_cursor BULK COLLECT INTO V_OUTLET_CODE, V_OUTLET_NAME, V_CONTACT_NAME, V_MOBILE_NO, V_ALT_NO, V_ADDRESS1, V_ADDRESS2, V_CITY, V_POSTCODE, V_EMAIL; CLOSE c_contacts_cursor; FOR indx IN 1 .. V_OUTLET_CODE.count LOOP --xecutable statements on V_OUTLET_CODE(indx) and the like END LOOP; End;
I used the above structure at length in many functions and procedures of all associated with an application and works very well. However, I began to review my code and I thought he might be better way to do it. One of the methods I've found is cursor for loop: http://www.techonthenet.com/oracle/loops/cursor_for.php
and http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/cursor_for_loop_statement.htm#LNPLS1155
I'm trying to understand the advantages and disadvantages of each method. I get the following (rating my approach is, and cursor for loop is B
(1) A is faster because it uses in BULK COLLECT IN as opposed to B which is implicitly opens, fetch a row and close each round loop.
(2) A is a bit messy, a lot more code as opposed to B which is readable, ranger.
First of all, I would like to know, if my conclusions are correct or not?
Second, what other differences might be between the two?
Third, is there another approach, that I'm not aware? Or what improvement could be applied to my approach, if there is?
Hawk333 wrote:
Yes, I did. Executable statements are most HTTP POST and PUT request that write in MongoDB on a platform that does not write in BULK. So I have to write one record per HTTP request.
Then pass PL/SQL to run multipe HTTP put and recorded at the same time. In which case manual removal bulk buys you no performance gain and zero scalability.
Use DBMS_PARALLEL_EXECUTE to chunk the workload. Execute each thread (parallel work process) using a standard FOR cursor loop (for example for loop in(select...) end of loop; c...) --and inside the loop, make HTTP calls.
-
APEX_APPLICATION. G_F01. COUNT returns 0
Hello
I had trouble with checkboxes in an interactive report. I have an Application where the user should be able to see whether or not a given letter is sent. Information for these letters are stored in a table, with an id, an internal number and a column that contains 0, if the letter is not sent and a 1 if it is sent. So now, I'm trying to compile a report interactive APEX shows the values, which is a box that is checked if the letter is sent (in the column 1) or disabled (0 in the column).
The SQL query looks like this:
Select
...
APEX_ITEM. CheckBox (1, smells, Decode(sent,1,'CHECKED',null)) "sent."
...
It works very well. Now, the user must be able to check a box if he sent a letter and save the data in the table. Now, this is where I have some problems. I tried to loop through all the lines that are checked and uptdate in the table.
The PL/SQL code for dynamic action looks like this:
BECAUSE me IN 1.APEX_APPLICATION. G_F01. COUNTING LOOP
Update...
END LOOP;
Now, if I press the button nothing happens, if I output the value for APEX_APPLICATION. G_F01. Consider it always returns 0. I watched if the value of name for the checkbox control is correct, so the source code looks like this:
< input type = "checkbox" name = "f01" value = "1" >
I hope that you can explain to me why the value of PEX_APPLICATION. G_F01. COUNT is always zero.
Hello
When you submit the page, APEX_APPLICATION. Table G_Fxx collect only checked the values checkbox.
If no box is checked, then the array is empty.
Kind regards
Jari -
A loop in exonentially duplication line selector
Using Apex 4.2
Background
Created a tabular presentation based on a view. Removed all updates of several default lines and destruction, buttons and processes.
I use a tabular form due to the fact that I can access a line selector.
The data in the row itself are all read only so it is a report with a line selector.
It's because I can't find a way to select a line interactive report, well I can and did, but it's a work around.
Problem
I created a button to process the selector to run the code below:
begin kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'Selected Check Boxes:'||wwv_flow.g_f01(1)) ; kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'Selected Check Boxes:'||wwv_flow.g_f02(1)) ; for i in 1..wwv_flow.g_f01.count loop kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'i:'||i) ; kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'WF ID:'|| wwv_flow.g_f02 (wwv_flow.g_f01.count)) ; end loop; end;
I just wanted to see what would be output. For a line it works oddly and I can't find the ID based on the line
When I select multiple lines in the loop executes the wrong for the number of lines but manages also to the number of selected lines.
So if I've selected three lines this above procedure would go three times, each time to loop three times.
I put the scope of execution: created for and changed lines in the State of the button that is displayed.
Mandatory
I only want to loop through the selected lines once by click of a button
OR
Know what line I'm currently traveling.
Really would appreciate some sort of entry here.
The problem is not with the loop. It works perfectly. The problem is that it happens for the same number of rows are selected. I got around the problem with a global variable that I put and don't forget to run only loop once. Bit inefficient but still to learn the inner workings of the APEX
-
Raise the Exception in loop For
Currently my loop code isFOR i IN 2..vt_records.count LOOP EXIT WHEN INSTR(vt_records(i), v_delimiter,2) = 0; csv_to_array(vt_records(i), vt_record, v_delimiter); --| Workaround for the case when the last column is null IF vt_record.count < v_expected_csv_cols THEN FOR i IN 1..(v_expected_csv_cols - vt_record.COUNT) LOOP --RAISE_APPLICATION_ERROR(-20000, 'vt_Record.COUNT=' || vt_record.count || ' - loopcount=' || (v_expected_csv_cols-vt_record.COUNT)); vt_record(vt_record.COUNT+1) := NULL; END LOOP; END IF; begin --{ INSERT INTO cit_interface_correlation ( massupdateid, primarymatkey_hr, geokey_hr, depmatkey_hr, promokey_hr, statcalcday, usercorfactor, inst_user, inst_session, inst_date ) VALUES ( seq_cit_interface_correlation.nextval, vt_record(1), TRIM(vt_record(2)), TRIM(vt_record(3)), vt_record(4), TO_DATE(TRIM(vt_record(5)),'DD.MM.YYYY'), TRIM(vt_record(6)), v('APP_USER'), v('APP_SESSION'), sysdate ); --} end; END LOOP; {code] What I need to do is raise an exception if vt_record(5) is greater than sysdate. If any line has a date greater than sysdate then the loop should fail and not carry on. Cheers Gus
Like this?
for i in 2..vt_records.count loop exit when instr(vt_records(i), v_delimiter,2) = 0; csv_to_array(vt_records(i), vt_record, v_delimiter); if vt_record.count < v_expected_csv_cols then for i in 1..(v_expected_csv_cols - vt_record.count) loop vt_record(vt_record.count+1) := null; end loop; end if; if vt_record(5) > sysdate then raise_application_error(-20001, 'vt_record(5) is greater than sysdate'); else insert into cit_interface_correlation ( massupdateid, primarymatkey_hr, geokey_hr, depmatkey_hr, promokey_hr, statcalcday, usercorfactor, inst_user, inst_session, inst_date ) values ( seq_cit_interface_correlation.nextval, vt_record(1), trim(vt_record(2)), trim(vt_record(3)), vt_record(4), to_date(trim(vt_record(5)),'dd.mm.yyyy'), trim(vt_record(6)), v('APP_USER'), v('APP_SESSION'), sysdate ); end if; end loop;
-
Handling exceptions in a For loop
Hi guys,.
I'm trying to validate data in tabular form using a page-level validation.
There are 2 places, I'm trying to catch any exception found data but when I run the present I get the error:DECLARE stock_count number; stock_exist boolean:= true; qty_actual NUMBER; qty_difference NUMBER; BEGIN FOR i in 1..apex_application.g_f02.count LOOP SELECT quantity into qty_actual from lm_order_items where ORDER_ID = :P21_ORDER_ID and product_id = apex_application.g_f02(i); EXCEPTION WHEN no_data_found then qty_actual:=0; SELECT product_quantity into stock_count FROM LM_STOCK WHERE product_id = apex_application.g_f02(i) and apex_application.g_f08(i) <= product_quantity and site_id=:P21_SITE_ID; EXCEPTION WHEN no_data_found then stock_count:=0; CASE when qty_actual > 0 and apex_application.g_f08(i) < qty_actual then -- reducing products from order stock_exist:= true; when qty_actual > 0 and apex_application.g_f08(i) > qty_actual then -- adding products to existing order if (apex_application.g_f08(i) - qty_actual) > stock_count then stock_exist:= false; :P21_PRODUCT_ERR:= 'insufficient stock to add to existing product'; else stock_exist:= true; end if; else null; end case; END LOOP; return stock_exist; END;
ORA-06550: line 13, column 3: PLS-00103: encountered the symbol "EXCEPTION" when expecting one of the following numbers: (begin case declare end exit for goto rise back loop mod null pragma select update while < ID > < a between double quote delimited identifiers of > < a variable binding > < < continue the current closing delete fetch locking insert opening rollback to savepoint sql set run commit forall fusion piping purification ORA-06550) : line 18, column 3: PLS-00103: encountered the symbol "EXCEPTION" when expected
Y at - he of the caveats on the use of the statements in a loop FOR EXCEPTION management? I need to use a loop FOR as I check against tabular form. If the syntax and everything looks right, bit at loss where I'm wrong.
Any help/suggestion appreciated.
ENVIRONMENT
APEX 4.1.1 to apex.oracle.com
THEME 13Hello
Exceptions should go at the end of the block, just before the END; He says in the docs somewhere - maybe here? http://docs.Oracle.com/CD/B10501_01/AppDev.920/a96624/07_errs.htm edit: updated documents: http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/overview.htm#i8859
The latest publication on select in I have seen is from Martins blog: http://www.talkapex.com/2012/06/select-into-techinques.html
There are also a few oramag PLSQL 101 articles lately. You would like to have a read of the article of error handling? http://www.Oracle.com/technetwork/issue-archive/2012/12-Mar/o22plsql-1518275.html
in any case, I think that martins blog will give you some ideas on how to approach this problem :)
-
Hello
As I'm pretty good with the concept of loop... Here are the spec & requirement...
Main objective: find all these identifications that took all the tests in a 45-day rolling window.
I have a 'MBS_FIRST_DATE' table with the following data:
This table has patients who have the test as well as the date of first... This table is derived such that she doesn't have that one record with the first date of the test, regardless of the test.
We have another table with all tests for patients that precedescreate table MBS_FIRST_DATE ( medical_record_number VARCHAR2(600), requested_test_name VARCHAR2(39), result_date DATE ); create index MBS_FIRST_DATE_MRN_IDX on MBS_FIRST_DATE (MEDICAL_RECORD_NUMBER); INSERT INTO MBS_FIRST_DATE (MEDICAL_RECORD_NUMBER,REQUESTED_TEST_NAME,RESULT_DATE) VALUES ('1001274','SBP',to_date('08/07/2008 04:46:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO MBS_FIRST_DATE (MEDICAL_RECORD_NUMBER,REQUESTED_TEST_NAME,RESULT_DATE) VALUES ('1001363','DBP',to_date('02/05/2008 09:37:00', 'dd/mm/rrrr hh:mi:ss')); commit;
including the above documents as well as the table above are based on the first patients regardless of test date.
Process:INSERT INTO all_recs VALUES ('1001274','SBP',to_date('08/07/2008 04:46:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO all_recs VALUES ('1001274','SBP',to_date('11/05/2009 04:46:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO all_recs VALUES ('1001274','DBP',to_date('08/07/2008 04:46:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO all_recs VALUES ('1001274','DBP',to_date('10/05/2009 04:46:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO all_recs VALUES ('1001274','CHL',to_date('08/05/2009 04:46:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO all_recs VALUES ('1001274','CHL',to_date('09/05/2009 04:46:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO all_recs VALUES ('1001274','CHL',to_date('10/05/2011 04:46:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO all_recs VALUES ('1001363','DBP',to_date('02/05/2008 09:37:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO all_recs VALUES ('1001363','DBP',to_date('11/05/2008 04:46:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO all_recs VALUES ('1001363','SBP',to_date('20/05/2008 04:46:00', 'dd/mm/rrrr hh:mi:ss')); INSERT INTO all_recs VALUES ('1001363','CHL',to_date('08/05/2008 04:46:00', 'dd/mm/rrrr hh:mi:ss')); commit;
be explained with an id of patients:
(1) examine the patient 1001274 table mbs_first_date.
(2) this patient has a test first table SBP & date of July 8, 2008. (keep this test an anchor point).
(3) for the patient over loop through the table all_recs with date of test & ordered outcome for the patient. (excluding the SBP)
(4) the first mention we have is CHL with 05/08/2009 (May 8, 2009)...
(5) given that this record is not within 45 days after date SBP for the patient... We go to the next record in the patient's spontaneous bacterial peritonitis.
(6) registration for SBP is 05/11/2009 (May 11, 2009).
(7) to consider the date of the CHL again who is with the 05/08/2009 (May 8, 2009)...
8) given that the two are within 45 days... store the values keeping date SBP as an anchor as is the criterion that is to have the minimum date in table 1. Although there is a single date CHL more who is within 45 days of SBP we don't care in this regard.
9) go to the next test for the same patient who is BPD...
(10) the SPD the first date is July 8, 2008...
(11) because it is not within 45 days of the date previously stored SBP (05/11/2009) ignore the record.
(12) GO to the next record which is 10/05/2009..as that is within 45 days of SBP & CHL (stored date) is already within 45 days...
Take all 3 dates are all within 45 days of date of (SBP) anchor.
SO the o/p will be
The code I wrote:1001274 SBP 11/05/2009 1001274 CHL 08/05/2009 1001274 DBP 10/05/2009
I know somewhere that I'm missing the loop
declare V_ID1 VARCHAR2(200) := ''; V_TEST1 VARCHAR2(200) := ''; V_DATE1 DATE := NULL; V_ID2 VARCHAR2(200) := ''; V_TEST2 VARCHAR2(200) := ''; V_DATE2 DATE := NULL; V_ID3 VARCHAR2(200) := ''; V_TEST3 VARCHAR2(200) := ''; V_DATE3 DATE := NULL; V_ID VARCHAR2(200) := ''; V_TEST VARCHAR2(200) := ''; V_DATE DATE := NULL; V_COUNT NUMBER := 0; V_TEST_COUNT NUMBER := 0; cursor c1 is Select medical_record_number, requested_test_name, trunc(result_date) result_date from mbs_first_date where medical_record_number = '1001274'; cursor c2(p_id varchar2) is Select --+ parallel ( m 256) distinct requested_test_name, trunc(result_date) result_date from all_recs m where medical_record_number = p_id order by requested_test_name, result_date; TYPE V_TT IS TABLE OF C2%ROWTYPE INDEX BY PLS_INTEGER; L_TT V_TT; BEGIN -- DBMS_OUTPUT.put_line('BEFORE LOOP'); FOR L1 IN C1 LOOP V_ID1 := L1.medical_record_number; V_TEST1 := L1.requested_test_name; V_DATE1 := L1.result_date; OPEN C2(L1.medical_record_number); LOOP FETCH C2 BULK COLLECT INTO L_TT LIMIT 1000; FOR indx IN 1 .. L_TT.COUNT LOOP IF L_TT(indx).requested_test_name != V_TEST1 THEN IF ABS(L_TT(indx).RESULT_DATE - V_DATE1) < 45 THEN DBMS_OUTPUT.PUT_LINE(V_ID1 || ' ' || L_TT(indx) .requested_test_name || ' ' || L_TT(indx) .RESULT_DATE); END IF; END IF; NULL; END LOOP; EXIT WHEN L_TT.COUNT = 0; END LOOP; CLOSE C2; END LOOP; END;
Hello
Interesting problem!
You can do it in pure SQL. If you need to use the PL/SQL, you may want to even a single SELECT statement allows you to actually do the work.If the all_recs table is needed for this problem, remember to post a CREATE TABLE statement for her.
It would be much easier if you could use analytics COUNT (DISTINCT...) with a FORK.
Because that is not allowed, this is something you can do:WITH pivoted_data AS ( SELECT medical_record_number , LAST_VALUE (CASE WHEN test_abbr = 'CHL' THEN test_date END IGNORE NULLS) OVER ( PARTITION BY medical_record_number ORDER BY test_date RANGE BETWEEN 45 PRECEDING AND CURRENT ROW ) AS chl_date , LAST_VALUE (CASE WHEN test_abbr = 'DBP' THEN test_date END IGNORE NULLS) OVER ( PARTITION BY medical_record_number ORDER BY test_date RANGE BETWEEN 45 PRECEDING AND CURRENT ROW ) AS dbp_date , LAST_VALUE (CASE WHEN test_abbr = 'SBP' THEN test_date END IGNORE NULLS) OVER ( PARTITION BY medical_record_number ORDER BY test_date RANGE BETWEEN 45 PRECEDING AND CURRENT ROW ) AS sbp_date FROM all_recs WHERE test_abbr IN ('CHL', 'DBP', 'SBP') ) SELECT * FROM pivoted_data WHERE LEAST (chl_date, dbp_date, sbp_date) IS NOT NULL ORDER BY medical_record_number , test_date ;
Which may cause several production lines for the same patient. If you only want the first time, each patient had 3 tests with a period of 45 days, and then add an another subquery, like this:
WITH pivoted_data AS ( SELECT medical_record_number , test_date , LAST_VALUE (CASE WHEN test_abbr = 'CHL' THEN test_date END IGNORE NULLS) OVER ( PARTITION BY medical_record_number ORDER BY test_date RANGE BETWEEN 45 PRECEDING AND CURRENT ROW ) AS chl_date , LAST_VALUE (CASE WHEN test_abbr = 'DBP' THEN test_date END IGNORE NULLS) OVER ( PARTITION BY medical_record_number ORDER BY test_date RANGE BETWEEN 45 PRECEDING AND CURRENT ROW ) AS dbp_date , LAST_VALUE (CASE WHEN test_abbr = 'SBP' THEN test_date END IGNORE NULLS) OVER ( PARTITION BY medical_record_number ORDER BY test_date RANGE BETWEEN 45 PRECEDING AND CURRENT ROW ) AS sbp_date FROM all_recs WHERE test_abbr IN ('CHL', 'DBP', 'SBP') ) , got_r_num AS ( SELECT p.* , ROW_NUMBER () OVER ( PARTITION BY medical_record_number ORDER BY test_date ) AS r_num FROM pivoted_data p WHERE LEAST (chl_date, dbp_date, sbp_date) IS NOT NULL ) SELECT medical_record_number, chl_date, dbp_date, sbp_date FROM got_r_num WHERE r_num = 1 ORDER BY medical_record_number , test_date ;
This puts all 3 dates to rank 1. If you want to display them on 3 separate lines, use the select... UNPIVOT functionality in Oracle 11, or join of a table of 3 rows in any version of Oracle. If you do this in PL/SQL, you can only use 3 separate instructions to show 3 dates.
-
a problem in passing multiple values in the loop settings for
Hi all
I am facing a problem in passing multiple values in the loop settings for.
EX:
CREATE or REPLACE PROCEDURE (pr_id OUT NUMBER) HAVE
tab type is table of NUMBER;
TEMP_TAB TAB;
BEGIN
Select the COLLECT LOOSE pr temp_tab pr_id;
I'm in 1.TEMP_TAB. loop of COUNTING
PR_ID: = temp_tab (i);
end loop;
END TEST;
OUTPUT:-
pr_id = 234578
in the example above, I'm only a value as an out parameter. but I send you PR_ID of the loop.
why I don't get all the values that the parameters.please offer a solution for me.
Thank you my friend.More clarification, let's look at your code...
-- create a procedure and have a single numeric out variable CREATE OR REPLACE PROCEDURE TEST ( pr_id OUT NUMBER ) AS -- declare a type as an array of numbers type tab is table of NUMBER; -- declare a varianble of that array type TEMP_TAB TAB; BEGIN -- query all the values from the table into the array select pr_id BULK COLLECT INTO temp_tab from pr; -- loop through each value in the array for i in 1..TEMP_TAB.COUNT loop -- set the value of the single OUT parameter, OVERWRITING any previous value it has PR_ID := temp_tab(i); -- loop around to the next value end loop; -- end the procedure with the final value of PR_ID END TEST;
-
After select stmt. why the count value of variable column, nested table is zero.
CREATE OR REPLACE TYPE numbers_type
ARRAY OF INTEGER
/
CREATE OR REPLACE PROCEDURE p(i) in FULL IS
numbers1 numbers_type: = numbers_type (1,2,3,4,5);
BEGIN
DBMS_OUTPUT. Put_line ("exposed before SELECTING");
DBMS_OUTPUT. Put_line('numbers1.) COUNT() = ' | numbers1. COUNT());
FOR j IN 1.numbers1. COUNT() LOOP
DBMS_OUTPUT. Put_line ('numbers1 (' | j |)) ') = ' || numbers1 (j));
END LOOP;
-Auto selection clause to COLLECT LOOSE:
SELECT a.COLUMN_VALUE
LOOSE COLLECTION numbers1
TABLE (numbers1) one
WHERE a.COLUMN_VALUE > p.i
ORDER BY a.COLUMN_VALUE;
DBMS_OUTPUT. Put_line ("presentation and SELECT '");
DBMS_OUTPUT. Put_line('numbers1.) COUNT() = ' | numbers1. COUNT());
END p;
/
Call p:
BEGIN
p (2);
END;
/Hello
Before taking in the collection variable, the values of the variables are fushed. So in this case the numbers1 is empty so it becomes zero and trying to read values from this collection which is already empty.
That's why you get the number zero
PRABHU
-
In a table - looping through the rows and the stored procedure call
APEX version: 3.2.0.00.27
Hello
I searched the forum and tried a few things but could not make it work.
I have a tabular presentation, developed with the help of the ATD ( )
What I'm trying to do now:
-After submit and validations, loop through all the lines and
-call a stored procedure passing 3 parameters obtained from each of the lines on the form of tables. This procedure will be an update of a database table.
On the forum, I found that I could do the loop "* FOR i IN 1..." APEX_APPLICATION.g_f03. "LOOP COUNT *" syntax.
Only for testing purposes, I tried just to view information with the following (On Load - after a footer) process (example of Denes Kubicek == > http://deneskubicek.blogspot.com/2009/05/execute-javascript-throuhg-plsql.html):
The foregoing would give me a ' * ORA-01403: no data found * ' message. I tried through various variants of APEX_APPLICATION.g_f0* #*, but still can't get anything to display correctly. In commenting on all the lines referring to APEX_APPLICATION.g_f0x above, the date would be are they displayed fine.declare v_today varchar2 (200); begin -- :P40_test := APEX_APPLICATION.g_f03(1); -- :P40_test2 := APEX_APPLICATION.g_f04.COUNT; :P40_test2 := 100; v_today := to_char (sysdate, 'dd.mm.yyyy'); --FOR i IN 1.. APEX_APPLICATION.g_f03.COUNT LOOP :P40_test := APEX_APPLICATION.g_f02(2); HTP.p ('<script type="text/javascript">'); HTP.p ( 'alert(''Today is ' || v_today -- || APEX_APPLICATION.g_f04(APEX_APPLICATION.g_f03(i)) || '.\n' || 'end!'');' ); HTP.p ('</script>'); -- :P40_test := APEX_APPLICATION.g_f02(APEX_APPLICATION.g_f02(i)); --END LOOP; end;
I tried uncomment the FOR... LOOP and play with the code (defining the process runs "On submit - after calculations" and Validations), I got was a ' * ORA-06502: PL/SQL: digital error or value: character conversion number error * "message.
Here is the script of the form in a table:
Regarding the parameters for the stored procedure, it would the MSLINK, VALVE_NUMBER and the VALVES_STYLE. FEATURE.select "V"."MSLINK", -- hidden (number) "V"."INSTALLATION_DATE", -- editable date picker "V"."MANUFACTURER_INDICATOR", -- editable (cascading LOV -- text) "V"."MODEL_INDICATOR", -- editable (cascading LOV -- text) "V"."DIAMETER_INDICATOR", -- editable (LOV -- number) "V"."PURPOSE_INDICATOR", -- editable (LOV -- text) "V"."VALVE_NUMBER", -- shown but not editable -- number "V"."MODIFY_DATE", -- shown but not editable "V"."MODIFY_USER", -- shown but not editable "V"."VALVES_STYLE"."FEATURE" -- shown but not editable -- number from "#OWNER#"."VALVES" "V" Where "V"."PROJECT_ID" = :P1_PROJECT_NUMBER AND "V"."VALVES_DFLAG" = 0
Help, please!
(Sorry for the long post).
Thank you
TanHi, Tan,
I have not seen that type of object - I've only used custom types for purposes of test years ago and have never used their within Apex!
One possibility is that the value of checksum being is based on all of the content of these fields, rather than only the part of the FEATURE. If there are other parts of the object, you could include those items as well.
Otherwise, as you f01 KP for a record, you will need to retrieve the values of the FUNCTION in your PL/SQL code directly from the table (because the user cannot modify these fields, you can be sure that the values in the table will be still valid).
Andy
Maybe you are looking for
-
I checked the registry with CCleaner.I ran Malwarebytes and Spybot.
-
An extension has changed my got 'search engine '.
Normally if I waive the search bar and type in a word like dog, I'm going to be busy IEEE.org or results from google for dog. Some add on interferes with this redirection of queries to somoto.com. I disabled addons, and the question is still persiste
-
URgent: How to install Skype for Windows8.01
I'm using a laptop with Windows8.01 and she has Skype but it says I need to install the new Skype. If I try to install from the official page, but it takes time and no progress instalation. When I search "Skype" on the cell phone to "Seek", I see tha
-
Why don't I have a green exclamation point on one of my vi in the hierarchy of VI?
-
We have two users on our work of his RESUME, but not the other. Diagnostics, say it's well, volume controls work, but no sound on a user