After executing sql from batch, its disconnecting
Hello All,
I have written a batch program to execute a pl/sql procedure. But after execution, it disconnects.
But i want to continue in the same session
echo exec tracer.trace_pck.start_('alter session set sql_trace=true') | sqlplus hr/hr
Output:
Press any key to Enable Tracing
SQL*Plus: Release 11.2.0.2.0 Production on Thu Oct 10 15:59:56 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
SQL>
PL/SQL procedure successfully completed.
SQL> Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 -
Production
Trace Enabled Successfully. Press any key to input you sql
If you are using a batch file I assume you are using the windows OS.
Essentially what you need to do is to call a sql file from the batch file and then get the sql file to call all the other files.
Batchfile test.bat calls sql file test.sql
sqlplus <username>/password @test.sql
test.sql calls test1.sql and test2.sql and then exits
@test1.sql;
@test2.sql;
exit;
test1.sql shows the current sid, and serial# fro our session and our filename
select 'test1',sid,serial# from v$session
where audsid=userenv('sessionid');
test2.sql shows the current sid, and serial# for our session and our filename
select 'test2',sid,serial# from v$session
where audsid=userenv('sessionid');
When you run this you get t output similar to the following: (Your SID and Serial# will be different )
'TEST SID SERIAL#
test1 771 97
'TEST SID SERIAL#
test2 771 97
This shows that two separate sql files were called but are still in the same session
Similar Messages
-
Checkboxes don't update after executing SQL query
I have a table bound to data from a database.
in order to fill the data, i execute the RowSet after setting several required parameters (WHERE foo = ?).
I use
try {
getSessionBean1().getModule_has_featureRowSet().setInt(1,userID);
getSessionBean1().getModule_has_featureRowSet().setInt(2,submoduleID);
getSessionBean1().getModule_has_featureRowSet().execute();
module_has_featureDataProvider.refresh();
} catch (SQLException ex) {
ex.printStackTrace();
}This works, but when I want to change to other parameter userID and submoduleID the checkbox (boolean values) do not update after calling the DataProvider to refresh.
Anyone understands what I would like to know and can help me?
Thanks.I still struggle with this problem.
Ok, what I do is the following. I have one table (tbl1), where you can select a row. according to the row, another table (tbl2) is filled with data from a dataprovider and information from the row selected in tbl1.
i do this using
public void radioButton1_processValueChange(ValueChangeEvent event) {
// ;) Ugly, I know.
int submoduleID = Integer.parseInt((String) RadioButton.getSelected("buttonGroup")) + 1;
try {
getSessionBean1().getModule_has_featureRowSet().setInt(1,userID);
getSessionBean1().getModule_has_featureRowSet().setInt(2,submoduleID);
getSessionBean1().getModule_has_featureRowSet().execute();
module_has_featureDataProvider.commitChanges();
module_has_featureDataProvider.refresh();
} catch (SQLException ex) {
ex.printStackTrace();
}This should change the content of tbl2. And it does most of it. It retrieves the correct amount of rows and display a correct string field. The boolean entries, represented by text boxes, are not changed.
I was checking, if there is something like 'refresh' or 'rerender' or similar in order to refresh the table with the information from the dataprovider. I think hte problem is that the checkboxes are not rerendered correctly after executing DataProvider.refresh().
Can anyone help me on this?
thanks! -
Executing sql from table with in plsql procedure
I wonder if anyone can help.
I have a table that stores sql statements. They are actually a set of rules that I want to apply to my application. My intention is to execute the statement in plsql.
EG a sql statment held in the table might be:
'select count(id) from item where item_id = ' || constants_pkg.c_test_item || ' and client_id = ' || client_id_in
I am trying to call this from a plsql procedure, Ive CUT OUT some of the procedure task_rec.rule holds the statement above. The procedure is failing invalid SQL statement, I think the client_id_in may not be evaluating as the variable, passed into the procedure and constants_pkg.c_test_item not being taken from the constants pkg.
EG.
PROCEDURE create_additional_info_list(
client_id_in IN client.id%TYPE,
IS
result VARCHAR2(100);
BEGIN
EXECUTE IMMEDIATE
task_rec.rule
INTO result;
END;
If I was to do below the code would work ok. However I require the rule to come from the table.
EXECUTE IMMEDIATE
'select count(id) from item where item_id = ' || constants_pkg.c_test_item || ' and client_id = ' || client_id_in
INTO result;
Is there anyway constants_pkg.c_test_item and client_id_in can be evaluated as variables?Not that I've tried this but, if possible, change the SQL in the table to have bind variable; e.g.,
'select count(id) from item where item_id = :1 and client_id = :2 ';
Then in the procedure
execute immediate task
INTO result
USING constants_pkg.c_test_item ,
client_id_in ; -
Solution to execute sql from mysql application logs
We have some custom mysql application, which generate logs that are stored on common location on open linux box which has below format
$ cat minor20100809.log
20100809001^Aselect count(prod_id) from product_logs;
20100809002^Aselect count(order_id) from order_logs;
ID and the SQL statement with control A as seperater and daily 1000 logs files are generated
Now we have one oracle DWH, where we import all the mysql data and we need to test these counts on daily basis.
Could you please suggest a solution in oracle for this?
at high level we need to follow below steps
a) Import these logs in a table --> which is better way sqlldr, impdp, or plsql read file ?
b) execute these sql statement one by one
c) store the counts in log table on daily basisHi,
It is a simple two step process.
Step 1. Convert your log files statements to meaningful oracle statements. like removing prefixes 20100809001^A from each line.
This can be done in two ways.
(a). Using OS editors OR
(b). Following PL/SQL code...
-- Connect as sysdba
create or replace directory dir_tmp as '/tmp'; -- If oracle server is on Unix
create or replace directory dir_tmp as 'C:\your_folder'; -- If oracle server is on Windows
-- Grant permission to your_schema
grant read, write on directory dir_tmp to your_schema; Removing prefixes using:
SELECT regexp_replace (vNewLine, '([[:alnum:]]{1,})\^A', '\2')
INTO vStmt
FROM DUAL;
CREATE OR REPLACE PROCEDURE convert_to_sql_stmts
( input_file in varchar2,
output_file in varchar2
AUTHID CURRENT_USER
IS
InFile utl_file.file_type;
OutFile utl_file.file_type;
vNewLine VARCHAR2(4000);
vStmt VARCHAR2(4000);
i PLS_INTEGER;
j PLS_INTEGER := 0;
SeekFlag BOOLEAN := TRUE;
BEGIN
-- open a file to read
InFile := utl_file.fopen(dir_tmp, input_file,'r');
-- open a file to write
OutFile := utl_file.fopen(dir_tmp, output_file, 'w');
-- if the file to read was successfully opened
IF utl_file.is_open(InFile) THEN
-- loop through each line in the file
LOOP
BEGIN
utl_file.get_line(InFile, vNewLine);
i := utl_file.fgetpos(InFile);
dbms_output.put_line(TO_CHAR(i));
SELECT regexp_replace (vNewLine, '([[:alnum:]]{1,})\^A', '\2')
INTO vStmt
FROM DUAL;
utl_file.put_line(OutFile, vStmt, FALSE);
utl_file.fflush(OutFile);
IF SeekFlag = TRUE THEN
utl_file.fseek(InFile, NULL, -30);
SeekFlag := FALSE;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
END LOOP;
COMMIT;
END IF;
utl_file.fclose(InFile);
utl_file.fclose(OutFile);
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
END convert_to_sql_stmts;
Step 2. Directly executing above output log file
Use spool to generate the count....
set termout off
set feedback off
set trimspool on
set pagesize 0
set timing OFF
spool count.log
@new_file.log
spool off;Hope this helps... -
For a migration I have created a sql script that puts the full statement to be executed in a specific table column
I'm now looking for a way how to execute those statements.
Table structure like: oldName, newName, sqlStatement, id, otherField, otherField2
Instead of the full statement(sqlStatement) it would also be possible to use the oldName, newName and id field if that simplifies the problem.
The reason for building the statement and running that one is a) to validate upfront b) a self join is applied to the query result table to prevent some items for update.
The initial idea was to take the sql statements and execute them as a sql script but that process is pretty slow.user2833655 wrote:
For a migration I have created a sql script that puts the full statement to be executed in a specific table column
I'm now looking for a way how to execute those statements.That is wrong, tables are for data not executable code
Re: ref cursor - result set not known
http://en.wikipedia.org/wiki/Data_%28computing%29
>
Data is often distinguished from programs. A program is a sequence of instructions that detail a task for the computer to perform. In this sense, data is thus everything that is not program code.
>
user2833655 wrote:
The initial idea was to take the sql statements and execute them as a sql script but that process is pretty slow.This alternative will just make it difficult, complicated and unreliable as well. -
Help! Executing SQL from ASP
This is my Code..
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.DbOpenDatabase(strDB, strID & "/" &
strPASS, 0)
OraDatabase.DbExecuteSQL("DELETE tmp_clean;")
It then runs a SQL statement which populates the table
tmp_clean. I don't really want to have to write a procedure to
do this. It seems not to like the semi colon, but with out it
it doesn't execute the SQL. Please Help.It's okay, I worked it out. I hadn't done a COMMIT from my SQL
Plus session, so the table was still empty, and it musn't like
that. -
Executing SQL From A Forms Procedure
I am looking to execute a composed SQL command (ALTER USER ***** IDENTIFIED BY ****). The old execute immediate command in forms 5 would be the one I would have used, does any know the Forms 6i equivalent.
Regards
StephenHi John,
What I was having a problem with is that the following code from a Forms 5 procedure isn't working with Forms 6i :
Procedure dropSynonyms ()
sql_stmt carchar2(2000);
BEGIN
sql_stmt := 'drop synonym RT_'| |rec.runtime_table_name;
execute immediate sql_stmt;
END;
The method of executing the sql_stmt sees to have changed with Forms 6i but the help documentation isn't clear on the new syntax.
Any help appreciated.
Regards
Stephen -
Urg:Executing SQL From Java App using Jdbc Driver
Hi
I am using JDBC Driver version 9.0.1.1.0.
I am running this in Thin Client Mode
My Code Snippet Looks Like This:=
==========================================================
String url = "jdbc:oracle:thin:@localhost:1521:VpDb";
String userName = "scott";
String password = "tiger";
Connection conn = null ;
Statement st = null ;
ResultSet rs = null ;
String categoryCode="ABC";
try
conn = DriverManager.getConnection (url, userName, password);
st = conn.createStatement ();
String sqlStatement = "Select Count(*) From News Where CategoryCode=" +"\'" + categoryCode + "\'" + ";";
System.out.println(sqlStatement);
rs = st.executeQuery ( sqlStatement );
if( rs.next() )
System.out.println("Headline Exists");
else
System.out.println("No Headline Exists");
catch (SQLException e )
System.out.println();
System.out.println (" SQL ERROR IN IS_NEWS_EMPTY: " + e) ;
=========================================================
I have added the classes12.zip and nls_charset12.zip in the classpath.
Now when i run this it gives me an error saying the following error message:-
SQL ERROR IN IS_NEWS_EMPTY: java.sql.SQLException: ORA-00911: invalid character
Can anyone help me with this as to whats going wrong because the exact equivalent of my sqlStamenet runs on SQL command line but not from java code.Why??
Any Help appreciated
Thanks
MumI think it is complaining about the ";" that you add at the end of your string. You don't need to add that to the query.
-
Help and Exit button appears after upgradation from External ITS to Integra
Hi All,
Though there some threads with similar problem but still I am not able to fix the problem.
After we upgraded from external ITS to Intergrated ITS some of the application started displaying "Exit" and "Help" buttons. Please note that most of the application are working fine though.
Kindly suggest.Hi Edgar,
Thanks for the reply. Do I need to maintain this parameter from SE80 or from SICF? I had read in SE80 but it not help. I do not have authorization in SICF.
If it is to be done from SICF , please let me know.
Warm regards,
Aditya -
I'm trying to execute Excel from a ITS transaction using the GUI_EXEC, GUI_RUN or WS_EXECUTE functions I get a 'Select Program' dialog box from windows. I then have to find and select 'excel.exe' for it to work. Is there anyway to avoid the windows dialog box? It works find from SAPGUI.
Here's my code:
data: PATHNAME LIKE SOXPC-PATH.
Check where the Excel is
CALL FUNCTION 'SO_PROGNAME_GET_WITH_PATH'
EXPORTING
DOCTYPE = 'XLS'
IMPORTING
PATHNAME = PATHNAME
EXCEPTIONS
OTHERS = 1.
Call Excel
CALL FUNCTION 'WS_EXECUTE'
EXPORTING
PROGRAM = PATHNAME
COMMANDLINE = 'S:\0004.xls'
INFORM = 'X'
EXCEPTIONS
OTHERS = 1.
Thanks,
JaedIf you wanted to role the execookie.txt file out to your user community, assuming they all use Internet Explorer, you could role a file which lets IE determine which application to launch. The following file worked for me:
TXT
c:\Program Files\Internet Explorer\iexplore.exe
JPG
c:\Program Files\Internet Explorer\iexplore.exe
JPEG
c:\Program Files\Internet Explorer\iexplore.exe
GIF
c:\Program Files\Internet Explorer\iexplore.exe
DOC
c:\Program Files\Internet Explorer\iexplore.exe
BMP
c:\Program Files\Internet Explorer\iexplore.exe
PDF
c:\Program Files\Internet Explorer\iexplore.exe
TIF
c:\Program Files\Internet Explorer\iexplore.exe
PPT
c:\Program Files\Internet Explorer\iexplore.exe
PPS
c:\Program Files\Internet Explorer\iexplore.exe
XLS
c:\Program Files\Internet Explorer\iexplore.exe -
Parsing giving different SQL ID from actually executing SQL?
I think this is worth a thread on its own.
Env: 11.2.0.3 on HP-UX Itanium
Scenario:
1. parse a sql statement using the following
c := dbms_sql.open_cursor;
dbms_sql.parse(c, v_sql, dbms_sql.NATIVE);
dbms_sql.close_cursor(c);2. Row appears in v$SQL with expected SQL_ID and plan_hash_value of 0.
3. In Toad, actually execute the <sql statement>
3. Second row appears in V$SQL with different SQL_ID and plan_hash_value non 0.
What's going on? Why do we get two different SQL_IDs for the same sql text executed by the same user?
Edited by: Dropbear67 on Feb 13, 2013 6:23 PM>
I think SB is right, it's in the translation.
As for why it's important.. Well I am being given SQL_ID's by the dev team and being asked to go create and fix baseline plans for them. I can get the SQL from V$SQL from the SQL_ID provided, but when I go to run the query myself, I end up with a different SQL ID (and different PLAN_HASH_VALUE because I'm running it in a different optimizer env, but thats irrelevant for here). This causes more work for me to then go search the v$SQL views to try and find the SQL I just ran.
Why do I need to find my new SQL_ID? Because I then use it to lock in the baseline plan which I just created by running the query. I need to know it's SQL_ID and the PLAN_HASH_VALUE.
One would have thought you could just run
select * from table (dbms_xplan.display_cursor()); but that doesn't seem to always play ball - why? maybe a matter for another thread one day
>
Well now, after a day and a half, that we know what it is you are really trying to do you might want to look through this 4 part article: SQL Plan Management - Creating SQL Plan baselines.
It is written by Maria Colgan, a developer on Oracle's Optimizer development team. - can't get a better source of info than that.
Sounds like you already have significant experience with baselines so you may already be familiar with most of this. But it will certainlly be useful to others.
https://blogs.oracle.com/optimizer/entry/sql_plan_management_part_1_of_4_creating_sql_plan_baselines
>
This first post in our series, describes the concepts of SQL Plan Management and how to create SQL plan baselines. The second part will describe how and when these SQL plan baselines are used. The third part will discuss evolution, the process of adding new and improved plans to SQL plan baselines. Finally, the fourth part will describe user interfaces and interactions with other Oracle objects (like stored outlines).
You can create a SQL plan baseline in several ways: using a SQL Tuning Set (STS); from the cursor cache; exporting from one database and importing into another; and automatically for every statement. Let's look at each in turn. The examples in this blog entry use the Oracle Database Sample Schemas so you can try them yourself
>
And Tanel Poder's article 'SQL_ID is just a fancy representation of hash value might be of interest.
http://blog.tanelpoder.com/2009/02/22/sql_id-is-just-a-fancy-representation-of-hash-value/ -
Execute SQL Task with Parameter - from DB2 to SQL Server
I am pulling data from DB2 to SQL Server.
1st Execute SQL task runs the following against DB2:
SELECT TIMESTAMP(CHAR(CURRENT_DATE - (DAY(CURRENT_DATE)-1) DAYS - 1 MONTH)) as START_MONTH
FROM SYSIBM.SYSDUMMY1;
I'm storing it as a Result Set.
Next I have a Data Flow Task. This pulls data from DB2 where the date matches the parameter.
FROM SCHEMA.TABLE t
WHERE DATE_TIME_COLUMN= ?
This works fine. Guessing, because the parameter source is DB2 and the Data Flow source is DB2.
The problem is, I want to remove existing data for the same date in the SQL table. IE, if I'm pulling March 2014 data from DB2, I want to be sure there is no March 2014 data in the SQL table. The main use is for re-runs.
So, I added another Execute SQL task after the first one that assigns the variable, and before the Data Flow Task. This runs the following statement against SQL Server:
DELETE FROM
database.dbo.table
WHERE DATE_TIME_FIELD >= ?
The package fails at the new Execute SQL Task with the following error message:
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "DELETE FROM
SBO.dbo.tblHE_MSP_FEE_BUCKETS
WHERE T..." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
correctly.
Task failed: Execute SQL Task
SSIS package "Load_MSP_Fee_Buckets_SQL.dtsx" finished: Success.
The program '[14240] Load_MSP_Fee_Buckets_SQL.dtsx: DTS' has exited with code 0 (0x0).
I am assuming this is something to do with the Parameter source being DB2, and trying to use against SQL?
Any suggestions on how to make this work??
Thanks,
-Al HParameter name is unrecognized
is the key, how come DB2 is related if it runs against SQL Server
What I think is happening you do not use the OLEDB connection to SQL Server.
Likewise, if it is ADO then the query needs to be
DELETE FROM
database.dbo.table
WHERE DATE_TIME_FIELD >= @MyDate
Arthur My Blog -
Executing sql query(not through sqlfile) from batchfile
Hi,
I have written a batchfile below which should execute the sql query. Can someone please help me in modifying the below code. I know we can make use of sql file ,but wanted it to be more robust and hence everything in a single batch file instead of having combination of sqlfile and batchfile.
@echo off
set ORACLE_HOME=%RAMBOH%
set ORACLE_SID=%RAMBSID%
set path=%RAMBOH%\bin;%RAMBOH%\admin\Ramb_Scripts;%path%
sqlplus sys/XXX as sysdba
@echo SET SERVEROUTPUT ON;
@echo DECLARE
@echo v1 DATE;
@echo BEGIN
@echo SELECT SYSDATE INTO V1 FROM DUAL;
@echo DBMS_OUTPUT.PUT_LINE(v1);
@echo END;
@echo /I used the below syntax to execute a procedure
set ORACLE_SID=orcl
echo exec MyProcedure;
echo exit
)|sqlplus system/manager >MyProcedure.log
Try making modifications to this and see if this helps you in executing the SQL from the batch file -
RFBIBL00 No Batch Input Created after Executing
Hello,
After Executing SAP standard report - RFBIBL00, no batch input session has been created in SM35 in ECC 6.0 version. There is no error message but one message displayed as 'PRODPER not transferred.'First the issue was in the input file.
Second Number of lines was more and in the report it was set less.
Third in check only there will no Batch Input session generates.
Fourth to create input file use SAP standard procedure i.e sxda_tools.
Note : From ECC, SAP not supporting Batch Input Method. -
I have a script task written in C# that creates an array of strings "arrayFields" after parsing a text file. It saves the array of strings in a DTS variable.
Each row in array represents a row is comma separated and is a row that must be inserted into a table. For example,
X and Z are fields in the table
X1, X2,....Xn
Z1,Z2,...Zn
I am using a Foreach Loop to grab each row and then Execute SQL Task to take each row from the array and insert each field per row in a table,
The SQL is something like,
INSERT dbo.table values(field1, field2,...fieldn) arrayFields?
What should this this INSERT look like?I guess you implemented
Shredding a Recordset
Based on what I understood (correct me if I am wrong) you have difficulties mapping the input parameters, if so here is the guide
http://www.sqlis.com/sqlis/post/The-Execute-SQL-Task.aspx
In short it might look like
INSERT dbo.table (ColumnA, ColumnB,...) VALUES (?,?...)
The syntax for the T-SQL INSERT is http://technet.microsoft.com/en-us/library/dd776381%28v=sql.105%29.aspx
Arthur
MyBlog
Twitter
Maybe you are looking for
-
Save As Dialog default Replace
Hello all, Trying to find out a keyboard shortcut so i can select replace instead of the default Cancel. With leopard it used to be the space bar would swap the selection from cancel to replace. Now the only option is to grab your mouse and click on
-
Create Screen Capture / Video Capture / Screencast using Flex?
Hi there, Has there been any update to this conversation: http://forums.adobe.com/thread/420807 That is, is there any way to record the desktop using Flex? Thanks, Mike
-
PKI-02002: Unable to open the wallet. Check password.
I am getting the following error: And I am unable to start IntegratedWeblogic Server. oracle.security.jps.service.credstore.CredStoreException: JPS-01050: Opening of wallet based credential store failed. Reason java.io.IOException: PKI-02002: Unable
-
as per the question above. youtube videos, whether on youtube or on FB, do not show, just a black unmoving screen. When i disable all (just some does not work, it appears) the addons the problem is solved. Issue is, i would like to keep the addons an
-
Adobe Reader no internet access
How do I instal Adobe Reader on a computer that does not have access to the internet. The computer does have winows xp pro but its a 2002 version.