Commit or no commit statement in procedure
Hi all,
i have two version of the same procedure.
procedure A
--loop
---fetch into record
--update a flag as processed
commit;
end loopprocedure A'
-- loop
--fetch into record
--update a flag
end loop In procedure A, i do a commit after every row. In A', i do not issue any commit statement. Will oracle auto commit the changes done in A' after the procedure finishes?
Because i realise in procedure A, it takes a long time finish. Whereas in A' it takes a relatively less time to finish.
Any harm if i choose procedure A' ?
Any harm if i choose procedure A' ?No.
But this way I prefer to commit.
Commit inside the loop surely slow down the performance.
If it is a huge table, then commit after every few set of trasactions will be advisable.
Procedure A
loop
fetch into record....
update or whatever your task....
end loop;
"commit";
end procedure A.
Similar Messages
-
Commit after alter table statement or not?
Hi,
Is it necessary to put the a commit after the following statement or is it automatically committed:
Alter table tab_name drop column col_name;
ThanksKhurram,
Isnt Eric you are , i mean isnt yours synonym :)Erm...simple answer. No. We are not the same person. I just know that Eric, like yourself, makes good contributions to these threads and then someone like that is coming on the forums and trying to make himself look better and put down the regular contributors which isn't really on is it, I think you'll agree.
CREATE PUBLIC SYNONYM Eric FOR Blushadow;
hehe. -
Differences between commit work and commit work & wait
Hi people,
I have a theory question:
What differences are there between commit work and commit work & wait?
ThxHi,
<b>COMMIT WORK:</b>
This statement will apply any outstanding database updates and wait until they have actually been put on the database before proceeding to the next statement.
An ordinary commit work will initiate the process to update the databases in a separate task and will press on in your abap.
COMMIT WORK: ( Asynchronous)
Your program does not wait for any acknowledgement. it just start executing the next statment after COMMIT WORK.
<b>COMMIT WORK and WAIT</b>: (Synchronous)
Whereas For <b>COMMIT WORK and WAIT</b>, the system waits for the acknowledgment, and then moves to the next statement.
Hope this resolves your query.
Reward all the helpful answers.
Regards -
Can we use return statement in procedure?
Can we use return statement in procedure or we can use more than one return statement in procedure?
HamidHelal wrote:
NOReally? Did you at least test it? You can use RETURN in procedure or in anonymous PL/SQL block. The only restriction is you can't specify return value:
SQL> begin
2 dbms_output.put_line('Before return');
3 return;
4 dbms_output.put_line('After return');
5 end;
6 /
Before return
PL/SQL procedure successfully completed.
SQL> create or replace
2 procedure p1
3 is
4 begin
5 dbms_output.put_line('Before return');
6 return;
7 dbms_output.put_line('After return');
8 end;
9 /
Procedure created.
SQL> exec p1;
Before return
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_output.put_line('Before return');
3 return 99;
4 dbms_output.put_line('After return');
5 end;
6 /
return 99;
ERROR at line 3:
ORA-06550: line 3, column 5:
PLS-00372: In a procedure, RETURN statement cannot contain an expression
ORA-06550: line 3, column 5:
PL/SQL: Statement ignored
SQL> create or replace
2 procedure p1
3 is
4 begin
5 dbms_output.put_line('Before return');
6 return 99;
7 dbms_output.put_line('After return');
8 end;
9 /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE P1:
LINE/COL ERROR
5/9 PL/SQL: Statement ignored
5/9 PLS-00372: In a procedure, RETURN statement cannot contain an
expression
SQL> SY. -
Current running sql statement in procedure?
How to identify the current running sql statement in procedure or package? From the v$sqlarea, i can see the only procedure name with parameters, but not current execution statement? is there any dba view to know the current execution statement in 9i & 10g ?
hi
u can also use dba_source view to know which sql statement issued by which user -
I am using SQL server 2008 R1 SP3. And when we are doing back up operations we are facing the below error
Msg 2601, Level 14, State 1, Procedure sp_flush_commit_table, Line 15
Cannot insert duplicate key row in object 'sys.syscommittab' with unique index 'si_xdes_id'. The
duplicate key value is (2238926153).
The statement has been terminated.
Please assist me with your inputs.
Thanks,
Rakesh.Hello,
Did you enable change tracking on the database? If so, please try to disable and re-enable the change tracking.
The following thread is about the similar issue, please refer to:
http://social.msdn.microsoft.com/forums/sqlserver/en-US/c2294c73-4fdf-46e9-be97-8fade702e331/backup-fails-after-installing-sql2012-sp1-cu1-build-3321
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support -
Create user statement on Procedures
Hi,
How to use create user command in oracle procedure.
Whenever I am using the statemet create user <username> identified by <password> it gives me the error. But whenever I am removing this statement the procedure is compiling successfully.
Is there anyway to use create user statement inside procedure?
Regards,
IndraneelYou have to use dynamic sql :
SQL> begin
2 execute immediate ('create user test_user identified by test_user');
3 end;
4 /
PL/SQL procedure successfully completed.
SQL>Of course the command should be completed with other information (e.g. default tablespace, temporary tablespace, and so on).
Paul -
Using comma seperated String in a Stored Procedure, in a "IN" keyword
Hello,
I am stuck trying to figure out the best way to pass an array of Ids into a stored procedure, and evaluate then in a SELECT WHERE statement. e.g. I have:
possibleIds VARCHAR2(50);
BEGIN
SELECT blah FROM foobar
WHERE foobar.id IN (possibleIds);
Where possibleIds looks like "10,11,12,30,101"...
Is this possible somehow? The above fails because possibleIds is evaluated as a VARCHAR2, and is not "concatenated" to the SQL statement.
Thanks for the help!The split function Scott used is some variant on one of the solutions posted in the Ask Tom link I posted. More specifically, it is probably a variant on either one of the pipelined function solutions, or one based on splitting the string into a SQL table of objects.
Look at Tom's original response to the question for a working solution. If you have a reasonably new version of Oracle, then you may also want to look at the modificataion/modernization later in the thread which can be found here
HTH
John -
Hi,
I'm having trouble getting my SP to work. I've searched this forum for a similar post, but haven't found it.
Can anyone please let me know what I'm doing wrong here?
Thanks!
CREATE OR REPLACE PROCEDURE updadminproc
(pdate IN CHANGE_CONTROL_ADMIN.CLOSEDATE%TYPE,
pact IN CHANGE_CONTROL_ADMIN.ACTIVE%TYPE,
pstat1 IN CHANGE_CONTROL_ADMIN.STATUS1%TYPE,
pstat2 IN CHANGE_CONTROL_ADMIN.STATUS2%TYPE,
padmcomm IN CHANGE_CONTROL_ADMIN.ADM_NOAPROVE%TYPE)
(cctrlid IN NUMBER)
IS
BEGIN
-- UPDATE STATEMENT
UPDATE CHANGE_CONTROL_ADMIN
SET CLOSEDATE = pdate, ACTIVE = pact, STATUS1 = pstat1, STATUS2 = pstat2, ADM_NOAPROVE = padmcomm
WHERE CHANGE_CTRL_ID = cctrlid;
COMMIT;
END updadminproc;
/Here are the errors I get that it's showing:
LINE/COL ERROR
7/2 PLS-00103: Encountered the symbol "(" when expecting one of the
following:
; is with authid as cluster order using external
deterministic parallel_enable pipelined
8/2 PLS-00103: Encountered the symbol "IS" when expecting one of the
following:
returnMessage was edited by:
user515689when I change it accordingly as to how you suggest, the procedure (in SQL Plus) gets created just fine, but then I get an Oracle error when calling the SP.
PLS-00306: wrong number or types of arguments in call to 'UPDADMINPROC'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)Any ideas? Since it reads wrong no. of arguments?
My Java call statement looks like the following:
CallableStatement cstmt = connection.prepareCall("{call updadminproc (?,?,?,?,?)}");
cstmt.setDate(1,cldt);
cstmt.setInt(2,actboxval);
cstmt.setString(3,status1);
cstmt.setString(4,status2);
cstmt.setString(5,fincomments);
cstmt.executeUpdate();I mean, I'm not trying to update the ID no., just associate the record with the ID number (cctrlid).
Thanks.
Ok, I got it....even though not updating the ID # itself, I had to add it to the cstmt object.
As in ....
cstmt.setString(5,fincomments);
cstmt.setInt(6,ctid2);
cstmt.executeUpdate();
Message was edited by:
user515689 -
Problem with print statements in procedure
We have a stored procedure version that looks the same as this. My problem is that at the beginning of this routine, there's a print statement (right after the BEGIN keyword), and that prints out to the screen only if the print statement inside the loop is uncommented. Why is this? Does it have something with the buffer not flushing to the screen until it gets a certain amount of output. I tried copying that first statement over and over half a dozen times, but it didn't seem to help. I've tried
set serveroutput on
and
set serveroutput on 2000
and
set serveroutput on 200000
but no matter what, whether in this version or the procedure version, that first statement only prints if the second one is also in there!
declare
l_cnt integer;
l_day_num integer;
CURSOR CUR1 is
select ACCTNUMBER,
FNBR,
REP
FROM FSUMMARY;
BEGIN
DBMS_OUTPUT.put_line('Beginning daily_total and deleting CMHISTORYINDEXWORK');
delete CMHISTORYINDEXWORK;
commit;
update FSUMMARY set FNBR='999999999' where FNBR is NULL;
COMMIT;
update FSUMMARY set REP='99' where REP is NULL;
commit;
FOR C in CUR1 LOOP
select count(ACCOUNTNBR) into l_cnt from CMHISTORYINDEXWORK where FNBR=C.FNBR AND REP=C.REP AND ACCOUNTNBR=C.ACCTNUMBER;
DBMS_OUTPUT.put_line('Count: ' || l_cnt || ' for rep ' || C.REP);The output from DBMS_OUTPUT is not displayed until the procedure completes, so your first call will not show until after all the work is done.
Assuming that you actually have an END LOOP; and a final END; in the block, I see no reason why there would be any connection between the calls to DBMS_OUTPUT.
Doing SET SERVEROUTPUT on SIZE just sets the maximum number of characters that can be stored in the outout buffer before it overflows. It has no bearing on whether or when anything gets printed. If the buffer is too small, you will get partial output and an error:
ORA-20000: ORU-10027: buffer overflow, limit of 2000 bytes
ORA-06512: at "SYS.DBMS_OUTPUT", line 35
ORA-06512: at "SYS.DBMS_OUTPUT", line 198
ORA-06512: at "SYS.DBMS_OUTPUT", line 139John -
Missing privilege - DELETE statement in procedure
Hello experts,
I am facing a problem for my procedure. I am not able to active the procedure if I use DELETE statement in the produce. When I use only selects, it is working fine. The SYSTEM user has access to the schema with full rights, including DELETE.
PROCEDURE "SYSTEM"."DEV_COL.procedures::FI" ( )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
DEFAULT SCHEMA UXX790
AS
BEGIN
Write your procedure logic
-- SELECT vbeln
--count(*)
DELETE
from vbapold
where erdat < ADD_days(now(), -1700);
END;
Did anybody had the same issue? I run HANA rev70.
BR
TamasHi Tamas
if this is a repository procedure user _SYS_REPO has to have the DELETE privilege with grant option as well.
- Lars -
Execute Dynamic SQL statement using procedure builder
i want to execute a dynamic SQL statment using procedure builder not using forms
because my statement depending on a variable table name
i know that i can do that from forms using
FORMS_DDL('SQL_STAT');
but i wanna to use the procedure builder
which function i should use and how?
please explain in example if you don't mind.
thanksHi,
You can very well use DBMS_SQL Package supplied by Oracle for doing this.
Search for DBMS_SQL in OTN. You will get all info regarding this.
Regards.
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by itslul:
i want to execute a dynamic SQL statment using procedure builder not using forms
because my statement depending on a variable table name
i know that i can do that from forms using
FORMS_DDL('SQL_STAT');
but i wanna to use the procedure builder
which function i should use and how?
please explain in example if you don't mind.
thanks<HR></BLOCKQUOTE>
null -
Sender JDBC adapter : Update SQL Statement : stored procedure
Hi,
Can we use a stored procedure in the sender jdbc adapter in 'Update SQL Statement'.
The problem i am facing is like, we are selecting data from two tables in 'SQL statement for query' and then in 'Update SQL Statement' , we need to delete that data from these two tables.
Please let me know if it is possible.
Thanks,
Rohityou can use a Stored procedure in the
Query SQL Statement
You have the following options:
· Specify a valid SQL SELECT statement to select the data to be sent from the specified database.
· Specify an SQL EXECUTE statement to execute a stored procedure, which contains exactly one SELECT statement.
The expression must correspond to the SQL variant supported by the relevant JDBC driver. It can also contain table JOINs.
so have your whole select and update as part of this single Stored procedure -
Hi experts,
I have to run the report every week
In my sample data endreportafter column determines how many times the report runs
run_sunday.... determines which day of the week the reportshould run (1 means reports runs on that day)
startreportdate is the day the report should run.
can any one help me to get the result by using select statement or using procedure
thanks in advance846773 wrote:
My first query is regular base table and my second query is the my expected result with just two columns(i excluded all the columns from first query )
second query is nothing but for each id what is my report expiredateI think I may have understood something your requirement but WTF, make an effort to be clear!!!
Let's suppose:
* for ID=1*
Your query is starting on '06/14/2012 10:41:40' (which is thursday).
It has to run 4 times and it runs only on Mon, Tue and Fri.
Then it will run on 06/15/2012, 06/18/2012, 06/19/2012 and 06/22/2012 (4 times). Expire date = 06/22/2012. Got it!! :-)
* for ID=2*
Your query is starting on '06/15/2012 10:41:40' (which is friday).
It has to run 1 time and it runs only on Mon, Tue and Fri.
Then it will run on 06/15/2012 and it's finished (1 time). Expire date = 06/15/2012. Got it!! :-)
* for ID=3*
Your query is starting on '06/16/2012 10:41:40' (which is saturday).
It has to run 2 times and it runs only on Mon, Tue and Fri.
Then it will run on 06/18/2012 and 06/19/2012 and it's finished (2 times). Expire date = 06/19/2012. Got it!! :-)
Please confirm the logic.
Regards.
Al
Edited by: Alberto Faenza on Jun 14, 2012 5:35 PM
Understood the logic
Edited by: Alberto Faenza on Jun 14, 2012 5:36 PM -
Tables statement in procedure.
hi experts:
today i get a program:
report ytest_table1.
tables:proj.
form frm_f1.
proj-pspnr = '12345678'.
endform.
report ytest_table.
form frm_f.
tables:proj.
if proj is initial.
endif. "breakpoint1
clear proj-pspnr.
if proj is initial.
endif. "breakpoint2
endform.
start-of-selection.
perform frm_f1 in program ytest_table1.
perform frm_f.
write: 1. "breakpoint3
when i run ytest_table and found:
the value is 12345678 when break1
the value is initial when break2
the value is 12345678 when break3
break 1 and break 2 i can understand that is a table work area,
but why break 3 is still 12345678?Hi,
please read the follwing note from the keyword help for TABLES:
Table work areas declared with TABLES can be declared in subroutines and function modules. However, this is not recommended. A table work area declared in a procedure is not local but belongs to the context of a framework program. The table work area can be viewed starting from the declaration in the framework program and lives as long as the framework program. In contrast to normal program-global data, the content of the table work areas declared in subroutines and function modules is stored temporarily when these subroutines and function modules are called. Value assignments that were made during runtime of the procedure are preserved until the procedure is completed. When exiting the procedure, the table work areas are filled with the contents that they contained when the procedure was called. Table work areas declared in procedures behave like global data to which the statement LOCAL is applied in the procedure.
Regards,
Klaus
Maybe you are looking for
-
Saving a PDF file when printing is not supported.
Hi Guys, I upgrade from leopard to snow and now I don't have the possibility anymore to to print PDF as a PDF. Before I was going to print and then choose save as a pdf and everything ok. Now after the upgrade to snow every time that I am going to pr
-
when I try to connect to the "http://localhost:8080/ReportServer " I get this error. The permissions granted to user 'DOMAIN/USERNAME' are insufficient for performing this operation. (rsAccessDenied). I have configered the Reporting services Configur
-
TS4083 I delete a message on my mac book, but it doesn't delete on my iPad
I delete a message on my mac book, but it doesn't delete on my iPad
-
Differences between being an Oracle and SQL DBA?
Sorry to post this here, but I need so insight and don't know any Oracle DBA's. As posted here before, Ive been a MSSQL DBA for about 6 years and want to broaden my skill set. One of my ideas is to learn Oracle. For the record, I do realize that my t
-
Where is the "Manage Pre-Orders" option?
Where is the "Manage Pre-Orders" option?