AUTO-COMMIT when passing sql scripts to sqlplus possible ?
I am not sure but I think I have read somewhere that there is an AUTO-COMMIT feature in sqlplus. When I enter some SQL statements in sqlplus and forget the COMMIT; statement at the end then sqplplus will do it for me.
How do I enable this in sqlplus ?
Assume I enter a couple of individual SQL statements.
With AUTO-COMMIT enabled is then a COMMIT done at the end of ALL statements (just before the "exit") or after each individual SQL statement ?
You might also look at SQL*Plus EXIT command:
»EXIT with no clauses commits and exits with a value of SUCCESS.«
Similar Messages
-
Promt from user to proceed in case of error in sql script in sqlplus
I am using Oracle 10g on Linux platform. I am executing a control.sql script from sqlplus from where i cam calling three *.sql scripts:
control.sql
SPOOL test.log
SELECT 'Start of Control File at:'||systimestamp from dual;
@00_create_table_scripts.sql
@01_alter_table_scripts.sql
@02_insert_scripts.sql
SELECT 'End of Control File at:'||systimestamp from dual;
SPOOL OFFI want that whenver there is an error in any of the three sql scripts, a prompt should be displayed asking the user if he wants to continue or not(Y/N). If he presses Y, then the remaining script shall be executed, otherwise execution should be stopped there.
Can any body guide me how can i do this?
Thanks.I want that whenver there is an error in any of the three sql scripts, a prompt should be displayed asking the user if he wants to continue or not(Y/N). If he presses Y, then the remaining script shall be executed, otherwise execution should be stopped there.If you have toad installed on your machine ,please run control.sql file from your machine .Toad will prompt an alert message saying that so and so error occurred and do you want to continue with that exception or not .
Thanks,
Prakash -
ORA-27369 Exit-Code: 255 when executing sql script as job
Dear all
I'd like to find and compile all invalid objects in an instance. This should be done every day as a scheduled job with the use of DBMS_SCHEDULER.
For this, I set up the following sql-script:
---------start script--------------
set heading off;
set feedback off;
set echo off;
Set lines 999;
Spool /tmp/run_invalid.sql
select
'ALTER ' || OBJECT_TYPE || ' ' ||
OWNER || '.' || OBJECT_NAME || ' COMPILE;'
from
dba_objects
where
status = 'INVALID'
spool off;
set heading on;
set feedback on;
set echo on;
@/tmp/run_invalid.sql
exit
------ end script ----
The script ist working well when executed manualy via sqlplus. As you can see, it spools the commands to a second file (run_invalid.sql) which is the beeing executed to compile the invalid objects found.
I now want to schedule this script via DBMS_SCHEDULER (running the job every day at 7AM). Creation of the job:
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'compile_invalid_objects',
job_type => 'EXECUTABLE',
job_action => '/home/oracle/scripts/sql/compile_invalid_objects.sql',
start_date => trunc(sysdate)+1+7/24,
repeat_interval => 'trunc(sysdate)+1+7/24',
enabled => TRUE,
comments => 'SQL-Script, und invalid objects zu finden und zu kompilieren'
END;
Manualy execute and error message:
BEGIN
DBMS_SCHEDULER.RUN_JOB (job_name => 'compile_invalid_objects',
use_current_session => true);
END;
FEHLER in Zeile 1:
ORA-27369: Job vom Typ EXECUTABLE nicht erfolgreich mit Exit-Code: 255
ORA-06512: in "SYS.DBMS_ISCHED", Zeile 150
ORA-06512: in "SYS.DBMS_SCHEDULER", Zeile 441
ORA-06512: in Zeile 2
--> Sorry for this, I'm using german localized oracle.
Unfortunately, it seems that only Shell-Scripts can be scheduled when using job_type='EXECUTABLE'. Can you confirm this?
BTW: The script is chmoded to 777, therefore it can't be a permission problem.
Is there maybe another solution with one single script using dbms_output functionality and run the script in a loop?
To complete my post, here are the commands used to create and test the job:
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'compile_invalid_objects',
job_type => 'EXECUTABLE',
job_action => '/tmp/compile_invalid_objects.sql',
start_date => trunc(sysdate)+1+7/24,
repeat_interval => 'trunc(sysdate)+1+7/24',
enabled => TRUE,
comments => 'SQL-Script, und invalid objects zu finden und kompilieren'
END;
Thanks for your help
CasiYou could more simply use $ORACLE_HOME/dbms/admin/utlrp.sql
-
Hello All,
Is this possible to set Auto Commit on/off
between DM statements in a PL/SQL block
Please suggest me.
Thanks in advance.No, you will have to explicitly issue a COMMIT or ROLLBACK when it makes sense to do it.
The autocommit feature of SQL*Plus (a client application) is not available inside PL/SQL.
However, an entire PL/SQL block when run from SQL*Plus would be considered as one statement (unit) and autocomit (if enabled) will commit all DML statements performed inside the PL/SQL block (and any blocks called from it).
Generally, its not a good idea to use this autocommit feature (even if available) since you lose all the control over your transactions. Your transaction never spans one single statement at a time. -
How to auto commit in pl/sql
Hello,
I am calling a PL/SQL procedure from a JDeveloper program. My connection is an "auto-commit" connection, but still, the PL/SQL is not committed until the procedure returns. Is it possible to avoid this, so that every single statement in the PL/SQL is committed immediately?
Regards
JakobA PL/SQL block reprsents a single unit of work that either commits or rollbacks. In that sense, that is how it is designed to behave. If you need otherwise, you would have to explicitly place COMMIT statements at appropriate locations.
-
The error message when wrapping sql scripts
the following is my code for testing the function of wrapper:
CREATE OR REPLACE PROCEDURE testproc
p_gydm varchar2,
p_ret out number,
p_msg out varchar2
IS
BEGIN
p_ret := 10;
p_msg := 'testing code completed';
END TESTPROC;
SHOW ERROR;
i save it as test.sql,when i wrapped it like that:
wrap iname=c:\test
the error message is:
kgepop:no error frame to pop to for error 1801.
what's the problem.Thanks.
dart leeYou need to run it from the operating system prompt, not the SQL prompt, and you need to specify the full path. For example, I saved your script to a file named test.sql in my c:\oracle81\bin directory, then successfully ran the following from the c:\> DOS prompt:
C:\>wrap iname=c:\oracle81\bin\test
Alternatively, you can run it from the SQL prompt, using the HOST command. I also tested this succesfully:
SQL> HOST wrap iname=c:\oracle81\bin\test
Using either method above, it produced the following wrapped file, in the following directory, by default, because I did not specify an output file:
c:\oracle81\bin\test.plb -
Unable to COMMIT when using SQL Developer 4
Hello guys,
I was wondering if any of you have an issue like mine? Whenever I try to commit to SVN, I get the following exception:
{quote} svn: E170001: Commit failed (details follow): svn: E170001: HTTP proxy authorization failed {quote}
Thanks,
{code}
Java(TM) Platform
1.7.0_25
Oracle IDE
4.0.0.13.80
Versioning Support
4.0.0.13.80
{code}It sounds like network problem (such of firewall, NAT...) Can you open a sqlplus connection? Fine work.
Please check in this order, to localize the problem
ping <to_ip_machine>
tnsping <connnect_string>
sqlplus <connect_string>
HTH - Antonio NAVARRO
sql1.wordpress.com -
Auto commit in JDeveloper SQL Worksheet
Can anybody tell me how to turn OFF the autocommit in SQL Worksheet withing JDeveloper,
Many Thanks in advance,
IanI'm afraid you can't - That's just the way it works at the moment.
-
Passing parameters to SQL Script
I'm trying to pass a parameter to SQL Script like
sqlplus hr/my_password @myscript.sql King
but everytime sqlplus is started the system is asking me for this parameter.
I would like too use this principe in combination with forms. (host user/passwrd@test @test.sql King)
kind regards,
MenkYour variable name in SQL script must be called &1.
Eg. SELECT value FROM table WHERE name = '&1.' ;
So, if you have more than one argument, the followed must be &2. &3. ...
If you use another name, Oracle always requests the value.
I hope help you -
Use SQL Workshop SQL Scripts function
When I tried the following 5 steps,
I cannot enter the ddl in the SQL editor window.
The fact is that I cannot enter anything.
Anyone can point out what is wrong with my procedure??????
Thanks!
Create the HT_EMP Table
To create the HT_EMP table and the appropriate associated objects:
1. Click SQL Workshop on the Workspace home page.
2. Click SQL Scripts.
3. When the SQL Scripts Repository appears, click Create.
The Script Editor appears.
4. In Script Name, enter HT_EMP
5. In the Script Editor, enter the following DDL:
CREATE TABLE ht_emp (
emp_id NUMBER primary key,
emp_first_name VARCHAR2(30) not null,
emp_middle_initial VARCHAR2(1),
emp_last_name VARCHAR2(45) not null,
emp_part_or_full_time VARCHAR2(1) not null check (emp_part_or_full_time in
('P','F')),
emp_salary NUMBER,
emp_dept VARCHAR2(20) check (emp_dept in
('SALES','ACCOUNTING',
'MANUFACTURING','HR')),
emp_hiredate DATE,
emp_manager NUMBER references ht_emp,
emp_special_info VARCHAR2(2000),
emp_telecommute VARCHAR2(1) check (emp_telecommute in ('Y')),
rec_create_date DATE not null,
rec_update_date date)
/You need to upload the file to the SQL scripts area of ApEx. If you upload it to the static files area it's not going to be treated as a SQL script.
Barring that as the problem - did you verify the contents of the script file on your workstation before you uploaded it - to make sure that the script actually contained the correct contents of the script?
I've never had any significant problems with script uploads and running scripts in ApEx that couldn't be traced back to operator error. :>)
Try explaining in detail the steps that you took to try to make this work - then we'll know where to start.
Earl
Message was edited by:
Earl -
Execute .sql scripts from a remote login
Hello,
1) How do I execute a remote sql script from sqlplus?
SQL>@remote_server:$HOME/test_sql.sql ...this did not work, which would work?
2) Another question, in sqlplus I can do...! echo testing123>$HOME/test123.txt.
How do I do this within a store procedure?
This does not work, which would work?
declare
v_test varchar2(300) := '! echo testing123>$HOME/test123.txt';
begin
execute immediate v_test;
end;
/Re Q2.
I take it that's an sqlplus feature on unix as it doesn't work on windows:
SQL> ! echo testing123>$HOME/test123.txt
SP2-0734: unknown command beginning "! echo tes..." - rest of line ignored.
SQL>Also the reason this isn't working from within PL/SQL is that the execute immediate statement is used to send SQL statements to the SQL engine. What you are attempting to do is to send sqlplus commands to the SQL engine which obviously knows nothing about sqlplus commands. Those commands are very specific to the sqlplus executable and will only work in that environment.
;) -
Get ALWAYS result of syntax check of sqlplus possible ?
When I pass an sql script to sqlplus as parameter then syntax errors may occur.
It could happen that I type e.g.
SELECT * from mytable
without trailing semicolon.
In this case sqlplus stops processing and waits forever without informing the
user about the problems.
Can I force sqlplus to send syntax check and error results in every case back to the user ?Until you tell SQL*Plus that you've completed the statement by adding the semicolon, though, it has no idea when to do the syntax check. It has no idea whether you're in the middle of typing in a query that is going to span multiple lines, whether you've stopped typing to talk to someone in the hall, or whether you intended to submit a query but forgot the semicolon.
Realistically, this is just part of debugging a script.
Justin -
Script fails when passing values from pl/sql to unix variable
Script fails when passing values from pl/sql to unix variable
Dear All,
I am Automating STATSPACK reporting by modifying the sprepins.sql script.
Using DBMS_JOB I take the snap of the database and at the end of the day the cron job creates the statspack report and emails it to me.
I am storing the snapshot ids in the database and when running the report picking up the recent ids(begin snap and end snap).
From the sprepins.sql script
variable bid number;
variable eid number;
begin
select begin_snap into :bid from db_snap;
select end_snap into :eid from db_snap;
end;
This fails with the following error:
DB Name DB Id Instance Inst Num Release Cluster Host
RDMDEVL 3576140228 RDMDEVL 1 9.2.0.4.0 NO ibm-rdm
:ela := ;
ERROR at line 4:
ORA-06550: line 4, column 17:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
The symbol "null" was substituted for ";" to continue.
ORA-06550: line 6, column 16:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev su
But when I change the select statements below the report runs successfully.
variable bid number;
variable eid number;
begin
select '46' into :bid from db_snap;
select '47' into :eid from db_snap;
end;
Even changing the select statements to:
select TO_CHAR(begin_snap) into :bid from db_snap;
select TO_CHAR(end_snap) into :eid from db_snap;
Does not help.
Please Help.
TIA,
NischalHi,
could it be the begin_ and end_ Colums of your query?
Seems SQL*PLUS hs parsing problems?
try to fetch another column from that table
and see if the error raises again.
Karl -
Auto run sql script when DB opens
Is it possible to configure a DB so a given SQL script is run each time the database opens?
Thanks a lot in advance.rafadc wrote:
Is it possible to configure a DB so a given SQL script is run each time the database opens?
Thanks a lot in advance.Either include the script in a startup script for the database, dbstart on *nix you'd need to write your own on windows, or else move the code into a startup trigger.
Niall Litchfield
http://www.orawin.info/ -
How to pass a variable into sqlplus script from file
here is my problem :
I have plenty of sql scripts to run. So every time I need to run sqlplus /nolog @scriptxx.name<enter> and then type login<enter>, password<enter>, second login<enter> , second password<enter> - and when it finishes again from the beggining with next one...
I am fed up with passing these parameters every time. I would like to create a file (files?) with these logins and passwords (located f.ex. in directory where I run the script) then tells, in some way, to my scripts that answers for their questions is inside this file(s).
Is there any way to do it in such a way ?
something like: accept DataUser char %read from file user1.txt without my inerteraction%
ps.
I cannot add directly these parameters to script because I need to run them on different servers (DEVs and PRODs) and every server has different users and passwords
KP>Actually the START command would resolve the issue, in conjunction with passing parameters and DEFINEs in a sensible manner.
DEFINE dathasb = '&1'
ACCEPT dathasb char prompt 'etc...'
When dathasb already has a value, ACCEPT won't prompt.
Too many people start hacking and don't use the power of Oracle because they don't the needful : Reading the documentation.
Other than that obviously the series of scripts needs of course to be re-engineered.
Asking interactively for a password .... even 20 years back we already didn't do this anymore.
Of course that was the time when exporting anything beyond the VAX 11/750 to Eastern Europe was prohibited because of US export regulations ;)
You could store the passwords in Oracle Wallet and be done with it.
You could use OS authenticated accounts and be done with it.
But then you still didn't post a version, even not when requested.
Sybrand Bakker
Senior Oracle DBA
Maybe you are looking for
-
Macbook Pro 2,2 ghz intel, black screen at startup
Hi I have a problem with my Macbook Pro.. It was hooked up to my TV through DVI, and after turning it off, the screen went black. I know the computer turns on, since I can log on to it from my other mac through screen sharing. Through the screen shar
-
Re: My Macbook 2009 model was recently upgraded with a new hard drive and upgraded to Mountain Lion OS. I am battling to retrieve all my photos that were ''saved'' in iCloud. Can someone help?
-
Report displaying Arabic characters in output as junk characters
Hi We have few Arabic reports which are giving output as junk characters. Below are version details EBS Version : 11.5.10 Reports : Oracle 6i Database : 10g Any pointers how to resolve this issue Thank You Arjun
-
Page copy error in 4.2.1
Hi all, just upgraded our Apex server to 4.2.1.00.08 and are now getting the following error when trying to copy a page from development server to production server: Execution of the statement was unsuccessful. ORA-20001: Error creating page name="Re
-
Change of LDB from PNP to PNPCE
HI All, I have a HR program where LDB PNP is used. Now I need to change the LDB from PNP to PNPCE. Can any one please tell me what are the mandatory change I need to do in the program after changing the LDB. Thanks & Regards, Arnab