An update of LOOP in a PL/SQL block
Every afternoon.I have a chart of accounts. Some of these accounts will have several numbers associated to them - other accounts will have just the number of accounts. The initial sequence number for each account is already set by another piece of code. There is a column in the table that details the next number in the sequence - so by joining the table to itself and from sequence number one - account I managed to create an exact sequence of account numbers, for each account we have.
The question I have is that the script is long enough, and new account numbers can be added all the time. If the script must be maintained and added if necessary. There are currently 65 steps in the update below script.
-UPDATED 2ND SEQUENCE NUMBER
UPDATE ACCOUNT_LIFECYCLE
GAME SEQUENCE = 2 WHERE ACCOUNT_NUMBER IN (SELECT B.ACCOUNT_NUMBER FROM ACCOUNT_LIFECYCLE A, ACCOUNT_LIFECYCLE B WHERE A.SEQUENCE = 1 AND A.NEXT_ACC_NO = B.ACCOUNT_NUMBER)
/
-UPDATED 3RD SEQUENCE NUMBER
UPDATE ACCOUNT_LIFECYCLE
GAME SEQUENCE = 3 WHERE ACCOUNT_NUMBER IN (SELECT B.ACCOUNT_NUMBER FROM ACCOUNT_LIFECYCLE A, ACCOUNT_LIFECYCLE B WHERE A.SEQUENCE = 2 AND A.NEXT_ACC_NO = B.ACCOUNT_NUMBER)
/
-UPDATED 4TH SEQUENCE NUMBER
UPDATE ACCOUNT_LIFECYCLE
GAME SEQUENCE = 4 WHERE ACCOUNT_NUMBER IN (SELECT B.ACCOUNT_NUMBER FROM ACCOUNT_LIFECYCLE A, ACCOUNT_LIFECYCLE B WHERE A.SEQUENCE = 3 & A.NEXT_ACC_NO = B.ACCOUNT_NUMBER)
/
think that this can be achieved in a small PL/SQL block, which would be effectively loop through iterations. I currently run the following query to verify the number of account numbers (to establish if I need to add more steps) - this could be defined as a variable binding?
Select max (count (original_account_number)) of the ACCOUNT_LIFECYCLE group by original_account_number;
Anyone has stumbled across any material on the web that may be able to help me in this task, or anyone could possibly give me a hint?
Thanks in advance
Hello
You are absolutely right to avoid any code that must be changed simply because the changed data in a regular and predictable way. It is also a good idea to think of streamline something that has 65 almost identical copies of the same code.
I think you can do what you want without PL/SQL, using a CONNECTION request BY:
MERGE INTO account_lifecycle dst
USING ( SELECT account_number
, LEVEL AS seq
FROM account_lifecycle
WHERE LEVEL > 1
START WITH seq = 1
CONNECT BY account_number = PRIOR next_acc_no
) src
ON (src.account_number = dst.account_number)
WHEN MATCHED THEN
UPDATE SET dst.seq = src.seq;
Of course, you can place the MERGE statement above in a PL/SQL procedure, if you want to.
If CONNECT BY does not work, then you could do what you do now in a loop, where the numbers are variables that is incremented with each pass through the loop. At the end of the loop, check if whatever it is actually got updated and LEAVE the loop if he doesn't.
If post you a small example of data (CREATE TABLE and INSERT statements) and desired outcomes from these data (i.e., the State of the table once the UPDATE is all done), then I could test it.
Tags: Database
Similar Questions
-
My first while loop inside the PL/SQL block does not, please help
Hello
I'm new to PL/sql and struck PL SQL blocks, please help solve this problem.
declare
constant v_A number: = 10;
constant number j: = 3;
BEGIN
WHILE j < v_A
LOOP
DBMS_OUTPUT. Put_line ('Hai');
END LOOP;
END;
Please help as how to solve this problem.
Thanks in advance.You cannot declare j as in 'permanent' If you want to increment its value. better go to another variable if you intentionally want constant j.
Something like this:
declare v_A number constant:=10 ; j number constant := 3 ; i number; BEGIN i := j; WHILE i < v_A LOOP i := i + 1; DBMS_OUTPUT.PUT_LINE('Hai'); END LOOP; END;
... Vivek
Published by: Vivek 21 Sep, 2010 02:54
-
update happens inside the anonymous PL/SQL block
Hello
I use oracle 10g 3.2.
I'll have a report with checkbox (separate column) so that only certain lines that I chose, I am able to update db.
At the click of a button following the anonymous PL/SQL block, I'll call you.
I use the "anonymous PL/SQL block following. The update happens.
F112_CHECKBOX is a level applocation element
Start
: F112_CHECKBOX: = HTMLDB_UTIL. TABLE_TO_STRING (HTMLDB_APPLICATION. G_F01, ",");
Insert into dumy values(:F112_CHECKBOX);
commit;
update set patient_id_code = '123' exp where f_id = 1 and patient_id_code = '12345' and method_internal_index in (: F112_CHECKBOX);
end;
The problem is with F112_CHECKBOX. The values I get in F112_Checkbox properly (in the dumy table I checked it shows) but by updating its not taking.
Can someone tell me something wrong with the syntax of update? method_internal_index column is varchar2 (100).
Thank you
OlivierThe problem is that: F112_CHECKBOX is a string that contains a list of values that you want to update.
You cannot use it in an IN clause because in doing so, you are running something like:update exp set patient_id_code='123' where f_id=1 and patient_id_code='12345' and method_internal_index in ('111,222,333,444');
This is equivalent to:
update exp set patient_id_code='123' where f_id=1 and patient_id_code='12345' and method_internal_index = '111,222,333,444';
And cannot find any line to be updated.
You can change your update in this way:
update exp set patient_id_code='123' where f_id=1 and patient_id_code='12345' and ','||:F112_CHECKBOX||',' like '%,'||method_internal_index||',%' ;
Ensure that: F112_CHECKBOX contains no spaces...
Max
http://oracleitalia.WordPress.com -
change a pl/sql block using "bulk collect.
Hello
I have a pl/sql block, short it slows...
DECLARE
CURSOR CURUPDATE1 IS
SELECT MF_TJ. UID_LO
OF MF_TJ
WHERE MF_TJ. DTYP (SELECT CD
OF MF_DOC_TYPE
WHERE MF_DOC_TYPE. DTYP_CAT = 'xx')
AND MF_TJ. LINE_TYP IS SET TO NULL;
BEGIN
FOR T IN CURUPDATE1
LOOP
UPDATE MF_TJ
THE MF_TJ VALUE. LINE_TYP = "NR."
WHERE MF_TJ. UID_LO = T.UID_LO;
UPDATE MF_AJ
THE MF_AJ VALUE. LINE_TYP = "NR."
WHERE MF_AJ. TJ_UID_LO = T.UID_LO;
END LOOP;
END;
/
now I change to use bulk collect, but I split it into two pl/sql blocks (each for an update)
DECLARE
CURSOR CURUPDATE1 IS
SELECT MF_TJ. UID_LO
OF MF_TJ
WHERE MF_TJ. DTYP (SELECT CD
OF MF_DOC_TYPE
WHERE MF_DOC_TYPE. DTYP_CAT = 'xx')
AND MF_TJ. LINE_TYP IS SET TO NULL;
TYPE of recs_type IS the TABLE OF CURUPDATE1% ROWTYPE directory INDEX;
REB recs_type;
BEGIN
CURUPDATE1 OPEN;
Go SEARCH the CURUPDATE1 COLLECT in BULK IN REB 8000 limit;
CLOSE CURUPDATE1;
FORALL i IN 1.recs. COUNTY
UPDATE MF_TJ
THE MF_TJ VALUE. LINE_TYP = "NR."
WHERE MF_TJ. UID_LO = (i) recs. UID_LO;-END;
/
DECLARE
CURSOR CURUPDATE1 IS
SELECT MF_TJ. UID_LO
OF MF_TJ
WHERE MF_TJ. DTYP (SELECT CD
OF MF_DOC_TYPE
WHERE MF_DOC_TYPE. DTYP_CAT = 'xx')
AND MF_TJ. LINE_TYP IS SET TO NULL;
TYPE of recs_type IS the TABLE OF CURUPDATE1% ROWTYPE directory INDEX;
REB recs_type;
BEGIN
CURUPDATE1 OPEN;
Go SEARCH the CURUPDATE1 COLLECT in BULK IN REB 8000 limit;
CLOSE CURUPDATE1;
FORALL i IN 1.recs. COUNTY
UPDATE MF_AJ
THE MF_AJ VALUE. LINE_TYP = "NR."
WHERE MF_AJ. TJ_UID_LO = (i) recs. UID_LO;-
END;
/Is there a way I can just use pl/sql block using bulk collect?
Thank you very much
Hi 5181139
As Paulzip and Jarkko Turpeinen have pointed out, you could do it using only SQL...
This is a course using COLLECT in BULK:
DECLARE blimit CONSTANT PLS_INTEGER := 500; CURSOR curupdate1 IS SELECT MF_TJ.UID_LO FROM MF_TJ WHERE MF_TJ.DTYP IN (SELECT CD FROM MF_DOC_TYPE WHERE MF_DOC_TYPE.DTYP_CAT = 'xx') AND MF_TJ.LINE_TYP IS NULL; TYPE c_arr IS TABLE OF curupdate1%ROWTYPE; c_rows c_arr; BEGIN OPEN curupdate1; LOOP FETCH curupdate1 BULK COLLECT INTO c_rows LIMIT blimit; FORALL i IN c_rows.FIRST..c_rows.LAST UPDATE MF_TJ SET MF_TJ.LINE_TYP = 'NR' WHERE MF_TJ.UID_LO = c_rows(i).uid_lo; FORALL i IN c_rows.FIRST..c_rows.LAST UPDATE MF_AJ SET MF_AJ.LINE_TYP = 'NR' WHERE MF_AJ.TJ_UID_LO = c_rows(i).uid_lo; EXIT WHEN c_rows.COUNT < blimit; END LOOP; CLOSE curupdate1; END;
See you soon,.
Gas
-
How to simplify my PL/SQL block?
Hello
I have a table such as
create table MY_TABLE
(NUMBER OF MY_ID,
INSERT_DATE NUMBER, - months when I inserted this line
MONTH_01 DAY,
SUM_01 NUMBER,
MONTH_02 DAY,
SUM_02 NUMBER,
MONTH_03 DAY,
SUM_03 NUMBER,
MONTH_04 DAY,
NUMBER OF SUM_04);
Each month, I add and update the rows in this table to:
-first month I add update and N lines fields month_01, sum_01
-second month I add M lines, update for this month_01 of fields of lines, the sum_01and fields month_02 update, the sum_02 for the previous lines of N
.. and so on...
Every month so I need to decide which fields should I update by knowing the number of months between trunc(sysdate,'mm') and INSERT_DATE. Then I write
If months_between = 0 then update my_table set month_01 = trunc (sysdate, 'mm'), sum_01 =... where...
end if;
If months_between = 1 then update my_table set month_02 = trunc (sysdate, 'mm'), sum_02 =... where...
end if;
If months_between = 0 then update my_table set month_03 = trunc (sysdate, 'mm'), sum_03 =... where...
end if;
If months_between = 0 then update my_table set month_04 = trunc (sysdate, 'mm'), sum_04 =... where...
end if;
I can simplify my pl/sql block by writing some type of dynamic sql where I can define the field name: < variable_name >, < variable_name > sum_ month_?
Thank you very much!something like that?
(even if you update in a loop that might be a bad idea if you have a large table if you do it this way)begin for c in ( select distinct 'months_'||lpad(abs(extract(month from sysdate) - (insert_date + 1) ),2,0) mon_col, 'sum_'||lpad(abs(extract(month from sysdate) - (insert_date + 1) ),2,0) sum_col from my_table ) loop execute immediate ('update my_table set '||c.mon_col||'=trunc(sysdate,''mm''), '||c.sum_col||' =... where..'); end loop; end;
Published by: pollywog on May 28, 2010 05:52
-
to change the pl/sql block to get the value of the user
In this code rather than affect the value of the SID in the block, I want to get the sid of the user.
Help, please.
Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product PL/SQL Release 10.2.0.1.0 - Production CORE 10.2.0.1.0 Production AMT for 32-bit Windows: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production declare
v_sname t1.sname%type;
v_issue_date t3.issue_date%type;
v_book_title t2.book_title%type;
v_book_id t2.book_id%type;
cursor c1 is
Select t1.sname, t3.issue_date, t2.book_title, book_id
join T1 T3
using (SID)
Join t2
using (book_id)
where sid = 1;
Start
Open c1
loop
dbms_output.put_line (v_sname |) » ' || v_issue_date | » ' || v_book_title | ' ' || v_book_id);
extract the c1 in v_sname, v_issue_date, v_book_title, v_book_id;
When exit c1% notfound;
end loop;
Close c1;
end;
/
Thank you
If I set up a script that I want to pass a value, I just a configuration variable and name it and use it very similar to a procedure or function. Makes it easy to implement a procedure/function, or to convert a function/procedure in a PL/SQL block for test/debugging with relatively few changes to the code inside:
declare in_sid number := to_number('&1'); v_sname t1.sname%type; v_issue_date t3.issue_date%type; v_book_title t2.book_title%type; v_book_id t2.book_id%type; cursor c1 is select t1.sname, t3.issue_date, t2.book_title, book_id from t1 join t3 using(sid) join t2 using(book_id) where sid=in_sid; begin open c1 loop dbms_output.put_line( v_sname ||' ' || v_issue_date ||' ' || v_book_title || ' ' || v_book_id); fetch c1 into v_sname, v_issue_date, v_book_title, v_book_id; exit when c1%notfound; end loop; close c1; end; /
-
Ignore the error and continue the pl/sql block
Dear all,
Please help me to fix the script below.
I had an obligation to write a pl/sql that will handle the update instructions.
For example:
A table that contains 10 rows of data. Through pl/SQL block, I update the 10 rows (or a smaller number of lines).
Now, the scenario is by updating registration / line 4, oracle has met an error and then oracle leave pl/sql block and cancel the transaction.
My requirement here is, by updating the records, if oracle encounters an error, it must raise an error or ignore the record and continue to process records. Oracle wouldn't pl/sql block.
We are using oracle 10g.
Thank you
KODSAs has already been suggested, you might check DML ERROR LOGGING
-
SQL logical support for pl/sql block
Hi all
I have need of your suggestions and comments for the below question:
I have two tables: table A and table b.
Table has two columns as id and charges:
Counties of ID
-------------------------
99 10
13 999
9999 7
Table B has two columns Id and stopped:
Order of identification
_______________
99 1
2 999
3 9999
We need update of the order in the Table B such that Id with the highest number in table A stopped as 1 in the table B and it continue to increase enforcement for other Ids based on reducing the counts in table A. It will be like a job serving daily and search counts in table A and update the order in table B, according to her.
It seems simple, but I don't get it. Please help me on this by writing a PL/SQL block.
I'd really appreciate all your comments and your responses.
Concerning
DevHello
Here's a way to do it:
MERGE INTO stat dst USING ( SELECT s.id , ROW_NUMBER () OVER ( ORDER BY SUM (m.counts) DESC NULLS LAST ) AS orders FROM stat s LEFT OUTER JOIN main m ON s.id = m.id GROUP BY s.id ) src ON (src.id = dst.id) WHEN MATCHED THEN UPDATE SET dst.orders = src.orders ;
As you can see, it is similar to the solution to your original problem.
In the original problem, id in the table (primary) source was unique; now, it is not, and we are interested in the SUM of all values of counts, so we can use GROUP BY and the SUM aggregate function. When used in the same query, aggregation (such as the SUM above) functions are calculated before analytical functions (for example, ROW_NUMBER), so the aggregate functions can be nested within analytical functions.
The big change is that now the subquery source produces a line for each stat line, or not this ID exists in the hand, and he ignores any ID at hand which does not exist in stat, using an outer join. "stat LEFT OUTER JOIN main" means that all ranks of stat will appear in the results, even if there is no game in hand, but the bottom lines will be in the results only if they have a match in the stat.
ROW_NUMBER assigns unique, coinsectuive whole, exactly as you requested. If there is a tie (two or more ID having exactly the same SUM (account)) then ROW_NUMBER will assign numbers separate, consecutive lines. It will be arbitrary in what id receives the lower number. -
What's not in the pl/sql block
Hi, I am unable to pass the parameter of a cursor to other cursors.
create table temp3 as select * from dept; create table temp4 as select * from emp; create or replace procedure xx_rep is cursor xx_dep_cur is select deptno from dept; cursor xx_emp_cur(p_dept number) is select sal,comm from temp4 where deptno =p_dept; TYPE idt_cur_dep2 IS TABLE OF xx_dep_cur%ROWTYPE INDEX BY PLS_INTEGER; t_idt_cur_dep2 idt_cur_dep2; TYPE idt_cur_emp2 IS TABLE OF xx_emp_cur(p_dept number)%ROWTYPE INDEX BY PLS_INTEGER; t_idt_cur_emp2 idt_cur_emp2; BEGIN OPEN xx_dep_cur; LOOP FETCH xx_dep_cur BULK COLLECT INTO t_idt_cur_dep2 LIMIT 1000; EXIT WHEN t_idt_cur_dep2.count<=0; FOR indx in t_idt_cur_dep2.first .. t_idt_cur_dep2.last LOOP DELETE from temp3 where deptno=t_idt_cur_dep2(indx).deptno; --main update BEGIN OPEN xx_emp_cur(t_idt_cur_dep2(indx).deptno); LOOP FETCH xx_emp_cur BULK COLLECT INTO t_idt_cur_emp2 LIMIT 1000; EXIT WHEN t_idt_cur_emp2.count<=0; FOR indx in t_idt_cur_emp2.first .. t_idt_cur_emp2.last LOOP UPDATE temp4 set comm=10 , sal =100 where deptno=t_idt_cur_dep2(indx).deptno; END LOOP; END LOOP; close xx_emp_cur(t_idt_cur_dep2(indx).deptno); EXCEPTION WHEN OTHERS THEN dbms_output.put_line('Exception' || SQLCODE||' '|| SQLERRM); END; --end of main update END LOOP; END LOOP; COMMIT; Close xx_dep_cur; EXCEPTION WHEN OTHERS THEN dbms_output.put_line('Exception'|| SQLCODE||' '|| SQLERRM); END;
You have syntax errors and when you set the couple noticed that you will find a little more.
First place a
/
display errors;at the end of your code. This will display your mistakes you don't have query user_errors. When you close a cursor set you just use the name of cursor with no parameters, or the parameter list appears in the reference cursor in the Type statement on line 13.
The rest is up to you.
HTH - Mark D Powell.
-
HII All,
I am facing the following error
Version detailsERROR at line 66: ORA-06550: line 66, column 20: PLS-00306: wrong number or types of arguments in call to '||' ORA-06550: line 66, column 11: PL/SQL: Statement ignored
My pl sql blockSQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production PL/SQL Release 11.1.0.7.0 - Production CORE 11.1.0.7.0 Production TNS for Solaris: Version 11.1.0.7.0 - Production NLSRTL Version 11.1.0.7.0 - Production
Even if I am not able to print the l_column_name_tab (i) using the dbms_output.Declare p_table_name clob := 'CP_CA_DTLS' ; Type t_column_name_tab is table of varchar2(4000) index by binary_integer; l_table_tab t_column_name_tab; l_file_name constant varchar2(5000) := 'column_counts'; l_count number; l_tab_count number; l_str varchar2(32000); l_tbl_str varchar2(32000); Cursor c_table_columns(c_table_name user_tables.table_name%type) Is Select column_name from user_tab_cols where table_name = upper(c_table_name); Type t_table_columns is table of c_table_columns%rowtype; l_column_name_tab t_table_columns; Begin --Splitting comma seperated data Select regexp_substr(p_table_name,'[^,]+{1}',1,level) bulk collect into l_table_tab from dual connect by level <= length(regexp_replace(p_table_name,'[^,]*'))+1; for k in 1..l_table_tab.count loop -- dbg_print(l_file_name,'***'||l_table_tab(k)||'***'); Begin l_tbl_str := 'Select count(*) from '||l_table_tab(k); execute immediate l_tbl_str into l_tab_count; -- dbg_print(l_file_name,'Overall Count of table '||l_table_tab(k)||' is '||l_tab_count); End; -- dbg_print(l_file_name,'Column Name '||','||'Count'); Open c_table_columns(l_table_tab(k)); loop Fetch c_table_columns bulk collect into l_column_name_tab limit 50; exit when l_column_name_tab.count = 0; dbms_output.put_line('l_column_name_tab.count count is : '||l_column_name_tab.count); for i in 1..l_column_name_tab.count loop Begin l_str := 'Select count(*) ' ; l_str := l_str||' from '||l_table_tab(k) ; l_str := l_str||' where '||l_column_name_tab(i); l_str := l_str||' is null' ; Execute Immediate l_str into l_count; End; --dbg_print(l_file_name,l_column_name_tab(i)||','||l_count); end loop; end loop; Close c_table_columns; end loop; dbms_output.put_line('l_column_name_tab.count count is : '||l_column_name_tab.count); End;
(Later I came to know that this information can be done by using the user_tab_col_statistics table)
But I would like to know what's wrong with my code. ???
Please help me.
Published by: 792353 on December 3, 2010 01:26Hello
l_column_name_tab is a collection of records, even if there is only one field in it.
For example, to access the value, you would do:
l_column_name_tab(i).column_name
-
pl/sql block, reading the reading of data from the table to a single point in time
I'm trying to figure out if several cursors in a PL/SQL block are executed inside a single Point in time, and so don't see no updates of paintings by other processes or procedures running at the same time.
The reason why I ask is I have a block of code as an initial extraction of data, with some Sanity Check before the code runs. However, if another procedure might modify the data between the two, then the mental health check is not valid. So I am essentially trying to know if there is consistency read in a PL/SQL, preventing updates to other processes to be seen.
Anyone who has an idea?
BR,
ChambazGoogle SET Transaction.
or
Follow this link
http://download-West.Oracle.com/docs/CD/B12037_01/server.101/b10759/statements_10005.htm
Kind regards
Prazy -
A question about the count of several lines of table in a PL/SQL block
Hi all
I have a problem on counting the rows from several tables in a PL/SQL block, and I would be grateful if you could kindly give me a helping hand. Here's my problem: file in Microsoft Excel (one column) I have a list of several names of tables. For each table, when the number of rows is equal to 10000 I have to call a procedure. Here's how I tried to do:
I already checked this code with tables inividual and it works. The only problem isDECLARE CURSOR tb_cursor IS WITH my_table_names AS ( SELECT 'table1' AS tbname FROM DUAL UNION SELECT 'table2' AS tbname FROM DUAL UNION SELECT 'table3' AS tbname FROM DUAL UNION SELECT 'table4' AS tbname FROM DUAL UNION . . Here I continue writing one line for each table in order . to have the table names stored in my Excel file as a table to be queried by SELECT statement . ) SELECT * FROM my_table_names; BEGIN -- Here I verify that for each table having more than 10000 lines -- I call the specified procedure which is needed FOR I IN tb_cursor LOOP DECLARE -- Here I declare a cursor for counting the number of rows CURSOR currentTableRowCounter IS SELECT COUNT(*) AS rowsNum FROM I.tbname; numberOfRows currentTableRowCounter%ROWTYPE; BEGIN OPEN currentTableRowCounter; FETCH numberOfRows INTO numberOfRows; CLOSE currentTableRowCounter; IF (numberOfRows.rowsNum > 10000) THEN -- And here I will call the procedure which has to be run END IF; END; END LOOP; END; /
Indeed, oracle considers "I.tbname" as an unknown table name (although he refers to by its exact name).. . . SELECT COUNT(*) AS rowsNum FROM I.tbname; . . .
How can I solve this problem? I mean, how to use a variable (in my example, I.tbname) as the table name in the FROM clause to query a table instead of explicitly write the name of the table?SQL> @script.sql FROM I.tbname; * ERROR at line 99: ORA-06550: line 99, column 12: PL/SQL: ORA-00942: table or view does not exist
Thanks in advance,
DariyooshReplace the following code:
DECLARE -- Here I declare a cursor for counting the number of rows CURSOR currentTableRowCounter IS SELECT COUNT(*) AS rowsNum FROM I.tbname; numberOfRows currentTableRowCounter%ROWTYPE; BEGIN OPEN currentTableRowCounter; FETCH numberOfRows INTO numberOfRows; CLOSE currentTableRowCounter; IF (numberOfRows.rowsNum > 10000) THEN -- And here I will call the procedure which has to be run END IF; END;
By the following:
Declare numberOfRows number; begin EXECUTE IMMEDIATE 'select count(*) from '||I.tbname into numberOfRows; IF (numberOfRows.rowsNum > 10000) THEN -- And here I will call the procedure which has to be run END IF; end;
Max
[My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/01/10/crittografia-in-plsql-utilizzando-dbms_crypto/]Published by: Massimo Ruocchio, January 12, 2010 15:25
Added Variable Declaration -
I want to start a process of transformation of automatic line (DML) as well as a custom PL/SQL (stored procedure) block. How can I do this? The ARP process is also triggered by another button in the page, but without the PL/SQL block.
Both in concrete: I have a 'save changes' button and a button "save changes and perform necessary tasks. For the first button, the ARP has fired, to the other, the ARP has triggered + a PL/SQL block that calls a stored procedure that is extra. How can I do this?Tom,
And the ARP has a sequence number that is less than the OTHER_PROC? You can change the status of the ARP, rather than be triggered by your request to SAVE button, it runs when:
Request is contained in the Expression 1
where 1 Expression has the value:
ECONOMY, APPLY_OTHER_CHANGES
Or ask your shipment of buttons.
It should run any process with a matching condition, even after the ARP. OTHER_PROC should get run thereafter, based on the corresponding application.
Thought, have another you noticed this info on the form of editing process?
Update validates the values of request: SAVE, APPLY the CHANGES, UPDATE, UPDATE, MODIFY, APPLY, APPLY LINE of CHANGES %, GET_NEXT %, GET_PREV %
So the query of your button name must match one of the people. I guess that the last 3 will match AS expressions, so your OTHER request button could be APPLY_OTHER_CHANGES.
I hope that does it for you, otherwise I feel really stupid! :-/
Stew
-
Hi guys,.
I would like to know, how can I stop an anonymous pl/sql block (what is the command, what rights will I have to run the command, etc.). We use the TOAD to PL/SQL programming and I know that administrators can stop processes of Enterprise Manager.
But yesterday, I started a block that is in an infinite loop and the admin is on vacation, and the table grows big and bigger and the tablespace will be full sooner or later.
So help pls.
Thank you
GaborThen you should find the sid, session id and the serial(serial#) of the view v$ session_longops... for your anonymous block...
Then, run the command:
alter system kill session ', ' Greetings,
SIM -
DB procedure / function can return multiple values in a PL/SQL block
Hi all
I have a problem returning to the exit procedure following in PL/SQL because I have SELECT INTO variable but with no output back in my PL/SQL block even if I turned it into a function.
. pls suggest.
CREATE OR REPLACE PROCEDURE nominations (p_start_date AS, p_end_date IN DATE)
IS
v_day_id PLS_INTEGER;
v_day_name VARCHAR2 (33);
v_day_date DATE;
BEGIN
SELECT (2 + (p_start_date + (LEVEL - 1) + LEVEL - 1 - TRUNK (LEVEL - 1 + 1, "IW" + p_start_date)) AS day_id
, TO_CHAR (LEVEL - 1, 'Day' + p_start_date) AS day_name
, TO_CHAR (LEVEL - 1, "DD-MM-RRRR" + p_start_date) AS day_date
IN v_day_id, v_day_name, v_day_date
OF THE DOUBLE
CONNECTION OF LEVEL < = 1 + p_end_date - p_start_date;
END;
/
Your insert would be something like this:
INSERT INTO PR_OPS_APPOINT_SETS (SPEC_CODE1, SPEC_CODE2, CLINIC_NO, SECTOR_ID, USER_ID, APPOINT_DATE)
SELECT r.SPEC_CODE1, r.SPEC_CODE2, r.CLINIC_NO, r.SECTOR_ID, USER, d.APPOINT_DATE
PR_OPS_CLINIC_RECS r
CROSS JOIN)
SELECT TO_DATE (TO_CHAR (LEVEL - 1, "MM/DD/RRRR" + p_start_date), "MM/DD/RRRR") AS APPOINT_DATE
OF THE DOUBLE
CONNECT BY LEVEL<= p_end_date="" -="" p_start_date="" +="">=>
) d
WHERE SPEC_CODE1 = p_SPEC_CODE1
AND SPEC_CODE2 = p_SPEC_CODE2
AND CLINIC_NO = p_CLINIC_NO
AND SECTOR_ID = P_SECTOR_ID;
In terms of getting the parameters p_SPEC_CODE1, p_SPEC_CODE2, p_CLINIC_NO, P_SECTOR_ID...? I don't have enough information on your part.
Maybe you are looking for
-
JJust brought a new MacBook from the store, and the trackpad scrolls. Someone at - it see or heard of this happening? Y at - it software solutions n? Leaving town tomorrow and here really this operational b
-
Is the advanced program of RegClean Pro of Systweak (e Cleverbridge) safe? I bought this program, struggled to save, got help from systweak, always had hurt, and since installing I can not change the browser and get a lot unwanted ads. I wonder if th
-
Can you tell me what causes this?
-
I bought the printer, put in place and it works very well with respect to printing, scanning and copying - except that he falls asleep or turns off completely... Also, the touchscreen doesn't seem to work... It beeps from time to time, but it's almos
-
the library exposed interface. Expert Java please help.
Hi all. Excuse my noobishness once more, but I have a design-oriented question. I want to offer some features of other applications via library. But want to restrict the user from this library to only a set limited features. (1) is there a way of onl