Where does a PL/SQL block? PGA or CMS?
Hi all11g
I'm not familiar with the structure of oracle memory, if I have a pl/sql block like below
DECLARE
v1 number;
BEGIN
v1:=100;
DBMS_OUTPUT.PUT_LINE(v1);
END;
in my mind, even if it's a small block, when I run it, it would also consume little memory, this memory whence, pga or CMS?in other words, when "pl/sql engine" needs little memory, for example, for local variables, this memory whence?
Thank you very much.
I would say that the PL/SQL variables are distributed in the PGA for dedicated server sessions:
>
The PGA is a memory segment that contains session-dependent variables required by a dedicated or shared server process. The server process allocates memory structures that it needs in the PGA.
>
11.2 Guide of http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/memory.htm#CNCPT803 Concepts.
What is certain, is that PL/SQL collections are allocated from PGA depending on "PGA memory Automatic Allocation" in http://www.oracle.com/technetwork/issue-archive/2007/07-mar/o27asktom-084983.html
Tags: Database
Similar Questions
-
I have a pl/sql block and it does nothing why?
The code is as follows:
DECLARE @day varchar (10)
BEGIN
Set @day =' select to_char ('sysdate', 'DAY') of double;
IMPRESSION @day
END;
Any ideas would be very appreciated.
Thank you!The minimum code required to do this is:
set serveroutput on SQL> set serveroutput on SQL> begin 2 dbms_output.put_line ( to_char ( sysdate, 'DAY' ) ); 3 end; 4 / FRIDAY PL/SQL procedure successfully completed.
If you do not use a variable instead, you do not need to make a selection in this case, standard SQL features available in PL/SQL
Note that:
(i) ' set serveroutput we ' must be defined once per session.
(II) semicolon ";" at the end of each statement, and
(III) "/" tells SQLPlus "I'm done, please compile and run.SQL> declare d varchar2(10); 2 begin 3 d := to_char ( sysdate, 'DAY' ); 4 dbms_output.put_line ( d ); 5 end; 6 / FRIDAY PL/SQL procedure successfully completed.
You have already shown a version using the ' select... in... from double '-that was the only way to do this in earlier versions, and of course, is how to get real data from real tables.
T/SQL and PL/SQL are very different... you have been pointed out the docs, go read and keep reading and reading, reading and...
-
Where the conditional, or PL/SQL block as a source for an interactive report?
I have this situation: my app's main screen displays a list of documents. For now, there must be a quick way to 'security' integrated, so that administrators can see all documents, but only other users can see what documents, they created (connection of the creator is stored in the table of documents). In the future we will use probably VPD to enforce certain rules, but for the moment we need a quick solution.
So I stored administrators in a separate table. Now I want the interactive Act report on the homepage as follows:
-If an admin is connected, it must have this query: select field 1, 2, 3 area in documents
-For all other users: select the field 1, 2, area 3 documents where creator =: app_user
Is this possible in a single interactive report? I could do two reports with different queries, and make conditional depending on who is connected, but this gives me two interactive reports to maintain. Is it possible to use a PL/SQL block as a source for the report? I tried, but I get a syntax error. Is it possible to do where proviso on somehow?Hello
Install the demo application to your workspace:
Home > create an Application and select Demo Application.Check page 1 interactive report. This should give idea how.
BR, Jari
-
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
-
Huge performance difference between stored proc and anonymous PL/SQL block. Why?
Hello! I searched various online resources and have been unable to find those who have addressed this problem, so I hope that someone here may be able to offer advice.
I have a stored procedure that is approximately 300 lines long, takes no parameters, and sets a record and a few types of internal tables. When I run it on a particular data set, it takes about 50 seconds at the end of my environment. Unfortunately, it will have to be performed as a block anonymous PL/SQL instead of a stored procedure, because of the policies that exist about the environment which I deployment. However, when I converted it to an anonymous PL/SQL block, make no other code changes whatsoever and it connecting the same schema that belongs to the stored procedure, it takes about 6.5 minutes (nearly 8 times as long) to complete. Aside from the burden of analysis and validation, which could add a fraction of a second, can someone please suggest some possible reasons for the large performance difference and offer advice on what I can do about it? In which case it is important, the procedure uses in bulk binds (for example, in bulk collect, forall) where it makes sense and doesn't call other objects in PL/SQL. Thanks in advance.
Without seeing your code, it is difficult for me to contribute more.
Note also that...
1 roles are turned on in the anonymous blocks but not (at least not by default) in the stored procedures. This is why the anonymous block could have MORE rights (those granted through roles) probability that you can get more items through anonymous block.
2. ensure that, in both cases, it does reference the same target tables.
Debug by calculating the difference of time after certain steps in your code. Who should get an idea on this or activate the trace.
-
Error when you try to create a region of the page generated by the anonymous pl/sql block
Hi guys I tried to create a region of the page which is the source and anonymous pl/sql block and I have been making a few mistakes. Basically what I want this region to do, is to give the current user of the application one summarized data compared to there user name which is: app_user the code I used was
declare
ven_ret varchar2 (15);
BEGIN
ven_ret: = (select u.vendor of USERS4ARCHITEC u )
where
u.e_mail = V ('APP_USER')
and not exists (select null from arch_tbl I where u.vendor = i.vendor and user_id = V ('APP_USER'))
order u.vendor in ven_ret);
END;
/
the structure of the table to the USERS4ARCHITEC table is
User varchar2 (15) vendor2 (20)
----------------------------------------------------------------------------------
user@1 sap
user@1 oracle
user@1 IBM <---------sample data
user@2 Oracle
user@2 cisco
the structure of the table to the arch_tbl table is
user vendor
--------------------------------------------------------------
user@1 sap
So if user@1 logs in the application of the region using the pl/sql code code above should display oracle and IBM, because these two sellers are always under his username that he has already used a form to insert the sap into the arch_tbl table. Please tell me what I'm doing wrong here. Thank you guys
Why would you build a type psedu at APEX report MANUALLY when you can just build a relationship with the same selection you use now for your pl/sql dynamic region? What is the purpose of building your own report when the tool made for you?
Thank you
Tony Miller
Software LuvMuffin
Ruckersville, WILL -
Hi all. I'm on oracle 9i.
I have a problem: I start my sql file, which has a share of some SQL commands and in it there is a part which is a PL/SQL block.
What I want is that if a certain if the condition is verified, he must get out of the PL/SQL block and also he must leave all files!
Here is a part of the code:
drop table test1;
create table test1
in select * from test2;
create the table prova_test1
in select * from test_1
where 1 = 2;
DECLARE
number of account: = 0;
Valore number: = 0;
contap number: = 0;
valorep number: = 0;
Stop varchar2 (2000): = null;
BEGIN
Select count (1), sum (val) contap, valorep
of prova_test1;
Select count (1), sum (val) in conta, valore
of test_1;
If conta <>contap or valore <>valorep then
Training: = "exit";
run immediately stop;
on the other
other sql statements.
....
....
end if;
end;
/
So what I want is that if the condition is true, he must get out of pl/sql block and the entire process.
How can I achieve that?
Thank you for the collaboration,
FabrizioSimply - what you want to do is not easy to do because you mix server with client code code and wait for the two to work in perfect harmony as if it were a single whole. It is not the case.
PL/SQL code is sent to Oracle and PL/SQL anonymous blocks. They are analysed. Executed. Then, control is returned to SQL * more. SQL * more is do not have a "programming language" - it has a few macro commands. It does not support conditional processing logic (there is no IF command in SQL * more).
To achieve what you want, you need to tell SQL * over how to respond to the mistakes of the Oracle server. Should continue despite the error? Should it end?
For example
-- // client call whenever sqlerror continue -- // server call: should this result in an error, continue processing drop table foo; -- // client call whenever sqlerror exit failure -- // server call: should this result in an error (exception), terminate processing begin .. pl/sql code.. end; / ..etc..
Very sure that you do not confuse the side Server and client - side you need to know exactly what is running on the server (SQL and PL/SQL) and how the client makes the call to the server, and how he responds after the call to the server is made.
-
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 -
How to test different Select into a PL/SQL block?
Hello
I'm relatively new to PL/SQL and I'm doing several int selects only one PL/SQL block. I am faced with the fact that if a single select statement returns no data, I have to go to the when exception DATA_NOT_FOUND.
Or, I would test selects different.
In an authentication script, I'm looking for a table for a USER ID (USERID) and an ID application, to check if a user is registered under this username for this APPLICATION.
There are different possibilities: 4 possibilities:
-Existing USER name or do not exist and
-Aplication ID found or not found for this particular USER ID.
I would test teas 4 possibilities to obtain the status of this user do regardin this application.
The problem is that if a select returns no rows, I'll not found exception data.
In the example below you can see that if no line is returned, with the exception
I would like to first of all make this statement:DECLARE P_USERID VARCHAR2(400) DEFAULT NULL; P_APPLICATION_ID NUMBER DEFAULT NULL; P_REGISTERED VARCHAR2(400) DEFAULT NULL; BEGIN SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES WHERE USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ; :P39_TYPE_UTILISATEUR := 'USER_REGISTERED'; EXCEPTION WHEN NO_DATA_FOUND THEN :P39_TYPE_UTILISATEUR := 'USER_NOT_FOUND'; END;
Do this if the user is found:SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES WHERE USERID = :P39_USERID
etc...SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES WHERE USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;
Basically, I don't want to go to the not found exception before you have tested the 4 possibilities.
Do you have a suggestion?
Thank you very much for your help!
ChristianIf you I had to check several conditions, this is how I would do:
DECLARE P_USERID VARCHAR2(400) DEFAULT NULL; P_APPLICATION_ID NUMBER DEFAULT NULL; P_REGISTERED VARCHAR2(400) DEFAULT NULL; BEGIN SELECT USERID , MAX(DECODE(application_id, :APP_ID, :APP_ID)) app_id_valid INTO P_USERID , P_APPLICATION_ID FROM ACL_EMPLOYEES WHERE USERID = :P39_USERID GROUP BY USERID IF P_APPLICATION_ID IS NULL THEN :P39_TYPE_UTILISATEUR := 'NOT REGISTERED TO APPLICATION_ID'; ELSE :P39_TYPE_UTILISATEUR := 'USER_REGISTERED'; END IF; EXCEPTION WHEN NO_DATA_FOUND THEN :P39_TYPE_UTILISATEUR := 'USER_NOT_FOUND'; END; /
not tested
C.
-
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
-
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 advanceHello
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.
-
Hi Experts,
I have a DB table has columns of more than 50.
I question this table, it should only return one line at any time. as sqldeveloper below image.
here, I need to build block pl/sql-query, Discover the column in the table as a key and query result as values.
Eg: Key - Value
TASK_EVENT_ID - 1765
EVENT_TYPE - ASR_UPDATE
... etc until all of the columns in my table.
Experts please comment on that point, appreciate your help on this.
Thank you
-Vincent.
Here is an approach using DBMS_SQL to iterate over the columns of key / value to assign... (Little code snipped for brevity)
create or replace procedure (task_expired)
v_store_id in full,
v_task_action_id in full,
v_job_id in full
)
as
-[SNIP code...]
v_sql VARCHAR2 (4000): = ' select * from my_table where PK = 123'; -Your SQL here!
v_v_val VARCHAR2 (4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER.
f BOOLEAN;
rec_tab DBMS_SQL. DESC_TAB;
col_num NUMBER;
vAsString VARCHAR2 (4000);
BEGIN
-[SNIP code...]
Message_properties. CORRELATION: = "EDF_EVENT";
MSG: = SYS. AQ$ _JMS_BYTES_MESSAGE. Construct();
Msg.set_string_property ('queueName', ' shipping/csi_cth');
Msg.set_string_property ('MODE', 'CR8');
c: = DBMS_SQL. OPEN_CURSOR;
DBMS_SQL. PARSE (c, v_sql, DBMS_SQL. NATIVE);
d: = DBMS_SQL. Execute (c);
DBMS_SQL. DESCRIBE_COLUMNS (c, col_cnt, rec_tab);
1.col_cnt J
LOOP
CASE rec_tab (j) .col_type
WHEN 2 THEN
DBMS_SQL. DEFINE_COLUMN (c, j, v_n_val); -Number
WHEN 12 CAN
DBMS_SQL. DEFINE_COLUMN (c, j, v_d_val); -Date
ON THE OTHER
DBMS_SQL. DEFINE_COLUMN (c, j, v_v_val, 2000); -Else treat as varchar2
END CASE;
END LOOP;
LOOP
v_ret: = DBMS_SQL. FETCH_ROWS (c);
WHEN OUTPUT v_ret = 0;
1.col_cnt J
LOOP
-Fetch each column to the correct data type based on coltype
CASE rec_tab (j) .col_type
WHEN 2 THEN
DBMS_SQL. COLUMN_VALUE (c, j, v_n_val);
vAsString: = to_char (v_n_val);
WHEN 12 CAN
DBMS_SQL. COLUMN_VALUE (c, j, v_d_val);
vAsString: = to_char (v_d_val, ' DD/MM/YYYY HH24:MI:SS');
ON THE OTHER
DBMS_SQL. COLUMN_VALUE (c, j, v_v_val);
vAsString: = v_v_val;
END CASE;
Msg.set_string_property (rec_tab (j) .col_name, vAsString);
END LOOP;
END LOOP;
DBMS_SQL. CLOSE_CURSOR (c);
DBMS_AQ. ENQUEUE (queue_name-online 'cbus.aqjms_common',
Enqueue_options => Enqueue_options,
Message_properties => Message_properties,
Payload-online msg,
Msgid => Message_handle);
dbms_output.put_line ('00 Msgid =' |) Message_handle);
dbms_output.put_line('===Done=');
-[SNIP code...]
END;
/
-
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.
-
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
-
"Declaration of execution" and anonymous PL/SQL blocks
I often use control - enter to execute the statement that the cursor is currently over. Normally, this works very well. But it's a little twisted once I added an anonymous PL/SQL block to the worksheet. As long as the anonymous block is the last thing on the spreadsheet, I can "run statement" as usual. But if I add a SQL queries after an anonymous block and try to run the statement, rather than just the running query, SQL Developer aims apparently to compile everything since the beginning of the first anonymous block until the current as a block statement.
For example, if I have a spreadsheet as follows:
SELECT 1 FROM DUAL; --run statement on this line works as expected, running just this query BEGIN --run statement anywhere within this block works as expected, running just this block DBMS_OUTPUT.PUT_LINE('X'); END; SELECT 1 FROM DUAL; --run statement on this line goes back to the "BEGIN" on line 3 and gives a compilation error
It is a nuisance major for me, as I have often a mixture of SQL and anonymous blocks on a worksheet. I know that I can point out that the code I want and execute statement in this way, but I'd rather not have to do. I was expecting that developer SQL would be smart enough to know where each block begins / ends and realize my current statement is not part of the block above him. Is there a setting that can change this behavior? Or is it the way it is supposed to work?
Whatever it is, thanks for the excellent tool.
Add a ' / ' at line 5 and line 5 to line 6 bump
Maybe you are looking for
-
What working hours on Sunday?
Hey, I have a pretty long investigation that I started to converse with you all at the end of last week. Due to bad timing, it was never a good time for us to do away with what is happening with me and my accounts and what you will do in this regard.
-
How can I identify the version of the operating system preinstalled?
Hello Sorry for the stupid question, how can I identify my girlfriends preinstalled the operating system?
-
InstallShield Setup Launcher does not
Hello I am trying to install a program of "Trader Zerodha" and the above message appears. And, when I tried to install Mozillaa Firefox, it says: "this program is blocked by group policy. How can I get these things sorted. Thank you! My system is 64
-
I go give the situation leading to this problem in aid of casemit t. My computer started to slow down a lot, the computer crashed quite often in 2 different ways 1 the computer could hang with a message from windows saying that my computer ran into p
-
Disconnect tones FXO GW recorded at end of virtual machines.
We have a system of sr 1 unit 4.0 (4) integrated with CCM 3.3. SR2 (4), with an IOS MGCP gateway with PSTN FXO ports. We ve had to use a custom on the MGCP gateway cptone to overcome a FXO disconnect problem and have set the time of disconnection on