How to execute multiple sql statements
hi all
i am wondering if i can execute multiple sql statements in one shot with >> execute immediate command
for example:
i define the variable as X := sql statement
Y := sql statement
z := sql statement
can i do execute immediate (X,Y, Z);
if yes how ?? and if not any possible alternate
thanks
Starting with Ganesh's code
DECLARE
l_statement VARCHAR2 (2000);
v_passwd VARCHAR2 (200);
v_username VARCHAR2 (200) := 'test';
v_pwd_key VARCHAR2 (200) := 'lwty23';
v_dblink_name VARCHAR2 (2000);
v_dblink_drop VARCHAR2 (2000);
v_dblink_create VARCHAR2 (2000);
v_dblink_check_connection VARCHAR2 (2000);
l_number NUMBER;
BEGIN
--<<c_instance>>
FOR c_instance IN (SELECT *
FROM v_oracle_instances
WHERE environment = 'Developement')
LOOP
SELECT encpwd_owner.display_db_encpwd (v_username,
c_instance.host_name,
c_instance.instance_name,
v_pwd_key)
INTO v_passwd
FROM DUAL;
v_dblink_name := c_instance.host_name || '_' || c_instance.instance_name;
v_dblink_create :=
' CREATE DATABASE LINK '
|| v_dblink_name
|| ' CONNECT TO '
|| v_username
|| ' '
|| 'IDENTIFIED BY '
|| v_passwd
|| ' USING'
|| ' ''(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST= '
|| c_instance.host_name
|| ')(PORT='
|| c_instance.LISTENER_PORT
|| '))(CONNECT_DATA=(SID='
|| c_instance.instance_name
|| ')))''';
v_dblink_check_connection := 'select 1 from global_name@' || v_dblink_name || '.QCM'; --- Notice this change. I am simply selecting 1. That should be enough to test the database link.
v_dblink_drop := 'drop database link ' || v_dblink_name || '.QCMTLAF';
-- l_statement := 'BEGIN ' || v_dblink_create ';' || v_dblink_check_connection ';' || v_dblink_drop '; END ;'
BEGIN
EXECUTE IMMEDIATE (v_dblink_create);
DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Created');
EXCEPTION
WHEN others THEN
dbms_output.put_line( 'Failed to create the database link ' || v_dblink_name );
dbms_output.put_line( dbms_utility.format_error_backtrace() );
INSERT INTO error_table( column_list )
VALUES( <<list of values>> );
END;
EXECUTE IMMEDIATE (v_dblink_check_connection) INTO l_number; --- Notice this.
DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Tested');
BEGIN
EXECUTE IMMEDIATE (v_dblink_drop);
DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Dropped');
EXCEPTION
WHEN others THEN
dbms_output.put_line( 'Failed to drop the database link ' || v_dblink_name );
dbms_output.put_line( dbms_utility.format_error_backtrace() );
INSERT INTO error_table( column_list )
VALUES( <<list of values>> );
END;
END LOOP;
END;But I agree with the point that others have brought up that it really doesn't make sense to create and drop a database link like this.
Justin
Similar Messages
-
How to execute multiple SQL statements thru frontend?
With SQL Server database, you can execute multiple SQL statements.
Ex.
SQLCommand cmd = new SQLCommand();
cmd.CommandText = "SELECT * FROM EMP; SELECT * FROM DEPT";
cmd.ExecuteXXX();
Note that for SQL Server, ";" (semocolon) is used as a separator.
What separator is required for Oracle ? Or rather, can I execute multiple SQL statements against Oracle database (10g) ?
(Why I want to do it is a totally diff. subject !)
Thanks,
Ami.Hello,
You could use an anonymous PL/SQL block to batch multiple statements.
If you want to use SELECT statements, you would open a REF CURSOR for each SELECT and return the REF CURSOR to your application. INSERT, UPDATE, and DELETE statements can just be passed as is.
A simple REF CURSOR example might look like:
begin
open :v_refcursor1 for select * from emp;
open :v_refcursor2 for select * from dept;
end;Where v_refcursor1 and v_refcursor2 are parameters defined as a REF CURSOR type.
Hope that helps a bit...
- Mark -
How to execute multiple sql statements in oracle?
I want to execute multiple statements in a single transaction in oracle. Following are my queries:
Create table temp_table as Select * from table;
SELECT * FROM temp_table d;
drop table temp_table ;
I am using sql comment text in asp.net
I am using executenonquery command in asp.net.
Thanks,
DivyaSigCle ,
Here's an example that executes 3 statements;
begin insert into foo values(1); insert into foo values(2); insert into foo values(3); end;
923354,
The block doesn't compile because temp_table doesn't exist at the point you're trying to compile the anonymous block. I'd recommend re-reading the doc link and forum link provided to get a better understanding of how temp tables work, as it's simply different with Oracle. You don't create Oracle temporary tables on the fly; you create them ahead of time and then just use them. The data itself is already specific to a particular session; you don't create and drop the table each time.
Also, you can't just "select * from table" in plsql. The results have to GO SOMEWHERE. Usually you'd either open a cursor and process it in the block, or send out a ref cursor if you want to send the data to a client side app. The ref cursor data wouldn't actually be fetched until the block completes though, so you'd need to use ON COMMIT PRESERVE ROWS, which would also mean you'd need to clean up the data yourself (delete the data from the table when you're done with it).
Corrections/comments welcome.
Greg -
How to execute multiple sql statement?
In an single transaction I want to execute two update statements. I don't know how to break those statements and send to oracle from Asp.Net to execute.
I tried go and ; .
Below is myQuery string*
update abc set One = 10 where Two = 3 ; update xyz set Three = 10 where Four = 3 ;
Additional info
I am using sql comment text in asp.net
I am using executenonquery command in asp.net.Hi,
If you want to execute multiple statements in a single transaction, you could either:
a) create a local transaction (via an OracleTransaction object), then call executenonquery multiple times within that transaction, or
b) pass them all in an anonymous block for a single round trip.. ie, begin update abc set One = 10 where Two = 3 ; update xyz set Three = 10 where Four = 3 ;end;
The database doesn't permit multiple statements passed at once (other than in a plsql block).
Hope it helps, corrections/comments welcome
Greg
PS, questions such as this would be better posted in the ODP.NET forum; this forum is for issues regarding ODT.NET (a VS plugin)
ODP.NET -
How to execute multiple sql statements in parallel ?
Hi There,
I have 10 stored procedures, each one will take approximately 5 seconds to run individually.
Now I need to combine the results of these 10 stored procedures into single result set.
So I have created one more stored procedure "proc_AllSPs" to get the single result set.
The procedure "proc_AllSPs" is taking one minute to run because all the procedures inside the "proc_AllSPs" are running
one after the other and taking 5 seconds each.
If there is any other way that all the procedures run parallelly, then the procedure "proc_AllSPs" can run in 5 seconds time.
Sorry if I am not being elaborated.
PLease get back to me if any piece of information is needed.
Any kind of help is truly thankful.
Thanks,
SequelBugCould you tell me how to execute two stored procedures or two sql statements in parallel
For eg:
First procedure name is proc_sp1 which takes 1 minute to run
Second procedure name is proc_sp2 which takes 1 minute to run
I want to accomplish the below query in 1 minute by executing statement1 and statement2 parallelly.
go
select * from openrowswt('sqloledb','server','exec proc_sp1') --statement1
union
select * from openrowset('sqloledb','server','exec proc_sp2') --statement2
go
OR
go
Select * into #Temp1 from openrowswt('sqloledb','server','exec proc_sp1') --statement1
select * into #Temp2 from openrowset('sqloledb','server','exec proc_sp2') --statement2
Select * from #Temp1
UNION ALL
Select * from #Temp2
go
Thanks,
SequelBug -
Executing multiple SQL statements fails using ODBC
Executing multiple SQL statements will fail with error 'ORA-00911 invalid character' when connecting to an Oracle database using ODBC driver version 8.01.07.00.
When I use either my application or the Oracle ODBC Test client utility connecting using ODBC driver version 8.01.07.00 I can only get a single CALL statement (as shown below) to execute:
CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','
','Event File
Name','\\KILLIANS\BATCHCTL\SampleDemo1\JOURNALS\1.evt','','AREA1','','','','','','1','','','','','',' ','');
When I try to execute the following string with multiple CALL statements (as shown below) it fails with the following error being returned - ORA-00911: invalid character
CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','
','Event File
Name','\\KILLIANS\BATCHCTL\SampleDemo1\JOURNALS\1.evt','','AREA1','','','','','','1','','','','','',' ','');
CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD
HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','Version','Recipe Header','1.0','','AREA1',' ','
','','','','1','','','','','',' ','');
CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD
HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','Version Date','Recipe Header','5/18/2001 1:28:32
PM','','AREA1',' ',' ','','','','1','','','','','',' ','');
CALL BHInsert (TO_DATE('2003.07.23
10:04:28','YYYY.MM.DD HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','Author','Recipe Header','Mark
Shepard','','AREA1',' ',' ','','','','1','','','','','',' ','');
I've tried adding a line feed in addition to the space at the end of each call but that doesn't seem to help. Also have tried unsuccessfully to change the seperator used between each call using various valid continuation characters.
Executing multiple CALL statements from within Oracle's SQL Worksheet connecting as the same user and password, as my application executes successfully. However when I try this from within the Oracle ODBC test client, it fails with the same ORA-00911 error that I'm seeing in my application.
I'm currently trying the more recent ODBC drivers, however any ideas or suggestions would be greatly appreciated.Can you take the begin ... end block and run it using SQL*Plus?
I can't think of any documentation that would specifically answer this question. I'm sure if you read & absorbed the ODBC Programmers Reference (2000+ pages) you'd be able to find out, but I don't know of a quick way to find out.
You can enable SQL*Net tracing. There are a fair number of options for enabling this tracing-- http://tahiti.oracle.com has all the Oracle manuals online, which should give you enough info to configure exactly what you want.
I would suggest, however, that you look into more performant/ scalable alternatives rather than going too far down this path. A block with lots of SQL statements with literals isn't going to make your database happy even if you get it to work.
Justin -
Issue on execute multiple SQL Statement on MySQL
Hi,I plan to execute dozenes of INSERT SQL statement on MySQL by JDBC:org.gjt.mm.mysql.Driver,But it throws the unkown exeption,pls kindly help
The code is like the follwoing
sql="insert into TEST values('100','test') ";
stmt=cnMySQL.createStatement();
stmt.addBatch(sql);
stmt.addBatch(sql);
stmt.executeBatch();
//stmt.executeUpdate(sql);The Exception is very tough,paste for all
javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:497)
at org.apache.jsp.testBean_jsp._jspService(testBean_jsp.java:293)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:484)
I have tried another way to execute multiple SQL.But the same Exception ocurred.
String sql="insert into TEST('100','100V'); "+
"insert into TEST('100','100V') ";
stmt.executeUpdate(sql);
Can't it the jdbc of MM support this kind of operation? And is there any better JDBC for mySQL?
Apprieciated for all!!! -
How to execute multiple sql query in one time?
HI
I'm trying to convert my sql project In Oracle. In sql i could run multiple select statement/query in once and they return in multiple table result respectively. but in oracle its not executed.
like:
sqlQry := "Select * from abc; select * from qwe; select * from kkk; select * from xyz"
its return 4 table abc, qwe,kkk,xyz to my dataset result
how it is possible in oracle 10gSaten Chamoli wrote:
I'm trying to convert my sql project In Oracle. In sql i could run multiple select statement/query in once and they return in multiple table result respectively. but in oracle its not executed.
like:
sqlQry := "Select * from abc; select * from qwe; select * from kkk; select * from xyz"
its return 4 table abc, qwe,kkk,xyz to my dataset result That is pretty much a hack - there are no ANSI SQL standards supporting this syntax. It makes no sense either.
If you want to combine 4 data sets, there are the UNION and UNION ALL set commands.
If you want to create 4 cursors with a single call, then use the following (anonymous PL/SQL block) call:
begin
open :c1 for select * from abc;
open :c2 for select * from qwe;
open :c3 for select * from kkk;
open :c4 for select * from xyz;
end;Bind 4 client cursor variables to the ref cursors c1 to c4 and make the call to Oracle.
And I suggest that you read up on Oracle concepts and fundamentals as your approach with you "sql project" shows ignorance in this regard. -
ADF with JSF: How to execute a Sql statement created in a form
Hello to every body,
I'm working in JDeveloper 11.1.2.1.0, I have to do a development when the user can create a SQL statement and I have execute that before to do commit to the DB(Oracle DB).
Example:
The user create the next query:
"+Select id_boss, boss_name from boss where boss_salary>5000+"
I don't know how to do that with the current persistence and without create a Connection Method.The video tutorial is excellent but I have a problem because I'm working with Release 2 and when I try to do something like the video I had the next error:
FachadaConsultaLocalImp cannot be cast to ApplicationModule
the code to try to create a ViewObject is the next:
DCDataControl dc = this.getBinding().findDataControl("FachadaConsultaLocal");
String dataProvider=dc.getDataProvider().toString();
ApplicationModule appModule = (ApplicationModule)dc.getDataProvider();
Some idea? -
Executing multiple SQL statements
I'm using the SQL worksheet in JDeveloper to run SQL statements. JDeveloper won't run more than one statement at a time. Here's an easy example:
SELECT COUNT(*)
FROM TABLE1
WHERE PRICE IS NULL;
SELECT COUNT(*)
FROM TABLE1
WHERE PRICE > 0;
I get the following error when I submit multiple statements: ORA-00911: invalid character. I'm using the studio edition version 10.1.3.2.0.
Does Anybody know how to go around this or it is just that JDeveloper doesn't handle multiple statements?Hi,
I don't have a 10.1.3 instance to check currently. I suppose there would be an option to run script (along with run option).
Try this.
Open the SQL worksheet.
Type the statements.
SELECT COUNT(*)
FROM TABLE1
WHERE PRICE IS NULL;
SELECT COUNT(*)
FROM TABLE1
WHERE PRICE > 0;Select all (Ctrl+A), right click and see if you have a Run Script option in the context menu. If yes, select and it would work fine.
-Arun -
Wish: Executing multiple SQL statements
I've noticed Raptor, SQL Worksheet, and Toad all execute everything from the beginning even if there was an error. This can be bad if the next statement depended on the first statement being successfull.
Also, when executing a single statement and you get an error, I've seen a message box pop up saying there was an error. This is annoying. Can there be an option to always put the error message in the script output?
Could you also have another option to execute a bunch of sql statements starting where the cursor is located? This way, if you were executing say 5 SQL statements, but it failed on the 3rd. You could correct the 3rd SQL statement, and then continue on starting with the 3rd.I tried preview 2 (0804), and it is awesome. Thank you so much!
This time, I didn't have to do anything. It ran out-of-the-box for me on Windows XP using Oracle 9i. I even still have all my other java runtimes and SDK's in the PATH. Nice work ignoring those. This should make my admins happy. And since we don't need to worry about the Oracle client, it will make the DBAs happy. Yay!
I tried what you mentioned, and it works.
WHENEVER SQLERROR EXIT FAILURE;
SELECT 1 FROM DUAL;
SELECT 2 FROM DUALX;
SELECT 3 FROM DUAL;
It stops executing on the SELECT 2 FROM DUALX; which is what I needed.
1
1
1 rows selected
Error starting at line 4 in command:
SELECT 2 FROM DUALX
Error report:
SQL Error: ORA-00942: table or view does not exist -
How to join multiple SQL statements?
I'm try to combine four of the following SQL statements as one, and I basically want to group by the new combined sql statement by suspension
Using: Oracle 10g
Here's my sql statements/what I've tried but doesn't seem to work:
select *
from
--NBA
select
decode (t.league_id, 1 , 'NBA') as League,
t.moniker as First,
t.Last_name as Last,
(t.To_Team_Name || ' ' || To_Team_Nickname) as Team,
count(*) Suspensions
from customer_data.cd_bk_trans t,
customer_data.cd_bk_roster r
where t.player_id = r.player_id
and t.trans_type_id in (12,13,14)
and r.status = 'Y'
and r.league_id = 01
group by t.league_id,t.last_name, t.moniker, t.to_team_name,t.to_team_nickname
order by Suspensions desc
union
--MLB
select
decode (t.league_id, 7 , 'MLB') as League,
t.moniker as First,
t.Last_name as Last,
(t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
count(*) Suspensions
from customer_data.cd_baseball_trans t,
customer_data.cd_baseball_roster r
where t.player_id = r.player_id
and t.comments like '%Susp%'
and r.status = 'Y'
and r.league_id = 07
group by t.league_id,t.last_name, t.moniker, t.from_team_name,t.from_team_nickname
order by Suspensions desc
union
--NHL
select
decode (r.team_id,18, 'NHL') as League,
t.fn as First,
t.ln as Last,
(t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
count(*) Suspensions
from customer_data.cd_nhl_trans t,
customer_data.cd_nhl_roster r
where t.player_id = r.player_id
and t.trans_type in (10,11,12)
and r.status = 'Y'
and r.league_id = 18
group by r.league_id, t.ln, t.fn, t.from_team_name,t.from_team_nickname
order by Suspensions desc
union
--NFL
select
decode (t.league_id, 8, 'NFL') as League,
t.moniker as First,
t.last_name as Last,
(t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
count(*) Suspensions
from customer_data.cd_football_trans t,
customer_data.cd_football_roster r
where t.player_id = r.player_id
and t.trans_type_id in (24,25)
and r.status = 'Y'
and r.league_id = 8
group by t.league_id, t.last_name, t.moniker, t.from_team_name,t.from_team_nickname
order by Suspensions desc
Order by Suspensions descHi,
Remove the ORDER BY clause in all the queries expcept lastone. Then it will work.
You can have the ORDER BY clause in the last query of the inline view. Otherwise it will give the error.
Run the query given below
SELECT *
FROM (
--NBA
SELECT decode(t.league_id, 1, 'NBA') AS league,
t.moniker AS FIRST,
t.last_name AS LAST,
(t.to_team_name || ' ' || to_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_bk_trans t, customer_data.cd_bk_roster r
WHERE t.player_id = r.player_id
AND t.trans_type_id IN (12, 13, 14)
AND r.status = 'Y'
AND r.league_id = 01
GROUP BY t.league_id,
t.last_name,
t.moniker,
t.to_team_name,
t.to_team_nickname
UNION
--MLB
SELECT decode(t.league_id, 7, 'MLB') AS league,
t.moniker AS FIRST,
t.last_name AS LAST,
(t.from_team_name || ' ' || from_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_baseball_trans t,
customer_data.cd_baseball_roster r
WHERE t.player_id = r.player_id
AND t.comments LIKE '%Susp%'
AND r.status = 'Y'
AND r.league_id = 07
GROUP BY t.league_id,
t.last_name,
t.moniker,
t.from_team_name,
t.from_team_nickname
UNION
--NHL
SELECT decode(r.team_id, 18, 'NHL') AS league,
t.fn AS FIRST,
t.ln AS LAST,
(t.from_team_name || ' ' || from_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_nhl_trans t, customer_data.cd_nhl_roster r
WHERE t.player_id = r.player_id
AND t.trans_type IN (10, 11, 12)
AND r.status = 'Y'
AND r.league_id = 18
GROUP BY r.league_id,
t.ln,
t.fn,
t.from_team_name,
t.from_team_nickname
UNION
--NFL
SELECT decode(t.league_id, 8, 'NFL') AS league,
t.moniker AS FIRST,
t.last_name AS LAST,
(t.from_team_name || ' ' || from_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_football_trans t,
customer_data.cd_football_roster r
WHERE t.player_id = r.player_id
AND t.trans_type_id IN (24, 25)
AND r.status = 'Y'
AND r.league_id = 8
GROUP BY t.league_id,
t.last_name,
t.moniker,
t.from_team_name,
t.from_team_nickname
ORDER BY suspensions DESC)
ORDER BY suspensions DESC -
Executing multiple sql statements from a single sql file
Hi, I am Vijay Krishna.
I want to drop user, drop tablespace, create tablespace and create user from a single executable file or a single sql file. The command should be in sequence. How can we achieve it? Can I anybody help me in this regard. I want this as soon as possible. It's urgent. Kindly post a reply.
Also, how can we know the oracle home directory from a java program? The problem is we should know the Oracle home directory and use it for creating the tablespace. In the userinterface we will give just for a new database user creation. I will be really thankfull if anybody can help me in this regard.It is showing any error messages.
I will diplay the entire batch file which we are using.
sqlplus / as sysdba
drop user examination cascade;
drop tablespace examination;
create tablespace examination
datafile 'C:\oracle\product\10.1.0\oradata\orcl\examination.dbf'
size 500M autoextend on;
create user examination identified by examination
default tablespace examination
quota unlimited on examination;
grant connect, resource to examination;
exit;
when i run the batch file from the DOS prompt it is entering into the sql prompt and coming out in a fraction of a second. We are just seeing a screen coming and going. But no error messages are being displayed.
first we thought that as we are giving the create tablespace and create user in the same file we created another file and tried without having the create commands. Even then the user didn't get dropped. -
JDBC -APPLET executing multiple SQL statements
Hello All,
Can I someone please help with this one.
I get the following error
java.sql.sqlException [Microsoft ODBC Manager] Invalid cursor State
when using
1. an ODBC datasource and connect using JDBC-ODBC
bridge.
2. Is it correct to use executeQuery & executeUpdate functions using the same connection and statement objects.
3. What is meant by the above error? This error occurs
while running the applet in Netscape
4. IE says can't class not found sun/jdbc/odbc
Expecting a useful reply.Dear Friend,
Invalid cursor state error occurs when you try to do something on a position of resultset which does not have any row in it. Example ,when you try to retrieve value from resultset when cursor is at beforefirst or afterlast. So you have to call next() so as to get value if the cursor is at beforefirst.
You can call any number of executexxx methods using a statement.
For free trial versions of JDBC Drivers visit www.Atinav.com -
Multiple SQL statements in Init SQL in WLS 8.1
How to seperate multiple SQL statements in Init SQL text box ?
For example, I want to enter following two SQL statements. How do I seperate them.
I tested with / and ; as seperator, but did not worked..
alter session set nls_date_format = 'MM/DD/YYYY'
set role xxx_role identified by xxxxMahendra wrote:
Thanks Joe.
Following worked for Oracle 8.1.7Good news.
but did not for 8.0.6
SQL BEGIN EXECUTE IMMEDIATE 'ALTER SESSION SET nls_date_format = ''MM/DD/YYYY''';
EXECUTE IMMEDIATE 'SET ROLE xxx identified xxx'; end;
Do you know 8.0.6 syntax ?You might try asking oracle, but note that no one is supporting that old version
of Oracle any longer...
Joe
>
Mahendra
Joe Weinstein <[email protected]> wrote:
Hi.
I found the syntax, I think. Try this:
BEGIN EXECUTE IMMEDIATE 'ALTER SESSION SET nls_date_format = 'MM/DD/YYYY'';
EXECUTE IMMEDIATE 'SET ROLE <<role name>> identified
by <<pwd>>';END;
Joe
Mahendra wrote:
Still getting following exception.
<Feb 19, 2004 1:47:58 PM EST>
<Warning>
<JDBC> <BEA-001164>
<Unable to initialize connection in pool "XXXX".
Initialization
SQL = "BEGIN alter session set nls_date_format = 'MM/DD/YYYY'; setrole xxxx_role
identified by
xxxx; END;".
Received exception: "java.sql.SQLException: ORA-06550: line 1,column7:
PLS-00103: Encountered the symbol "ALTER" when expecting one of thefollowing:
begin declare exit for goto if loop mod null pragma raise
return select update while <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql commit <a single-quoted SQL string>
The symbol "update was inserted before "ALTER" to continue.
ORA-06550: line 1, column 61:
PLS-00103: Encountered the symbol "ROLE" when expecting one of thefollowing:
transaction
".>
<Feb 19, 2004 1:47:59 PM EST> <Notice> <WebLogicServer> <BEA-000355><Thread "Li
Joe Weinstein <[email protected]> wrote:
Mahendra wrote:
Thanks for reply, but that did not worked.
Get following exception
Unable to initialize connection pool "POOL_NAME".
Initialization SQL = "Select count(*) from ""SQL BEGIN alter sessionset nls_date_format
= 'MM/DD/YYYY'; set role xxx_role identified by xxxx; END;"". Receivedexception:
"java.sql.SQLException: ORA-00972: identifier is too long
Since we have not given SQL before that statement, BEA is treating
statment "SQL Begin ....." as a table name.
Then I tried by putting SQL out side quotes, like SQL "Begin .....end;" but the
same error.
Is there any way around it ?
MahendraHi. The full string you should enter into the console when you define
the
initSQL parameter is:
SQL BEGIN alter session set nls_date_format = 'MM/DD/YYYY'; set role
xxx_role identified by xxxx; END;
Let me know...
Joe
Joe Weinstein <[email protected]> wrote:
Mahendra wrote:
How to seperate multiple SQL statements in Init SQL text box ?
For example, I want to enter following two SQL statements. How do
I
seperate them.
I tested with / and ; as seperator, but did not worked..
alter session set nls_date_format = 'MM/DD/YYYY'
set role xxx_role identified by xxxxThis will always be DBMS-specific. If this is for oracle, you can
try:
"SQL BEGIN alter session set nls_date_format = 'MM/DD/YYYY'; setrole
xxx_role identified by xxxx; END;"
Joe
Maybe you are looking for
-
Setting default sound card to card 0
Hi, After following Arch Wiki for configuring Alsa I added the following to my /etc/asound.conf: efaults.pcm.card 0 defaults.pcm.device 0 defaults.ctl.card 0 This works on my current session. However, sometimes when I reboot my computer, my primary s
-
Exception in sunone connector provisioning.
hi friends, i am getting this exception in user provisioning. may be this is a stupic question. what is the jar file for this class. Exception in thread "main" java.lang.NoClassDefFoundError: com/oracle/oim/gcp/re sourceconnection/ResourceConnection
-
Can not find air printer - using epson wf 3520 connected via wifi
Hardware: macbook air Software: Osx 10.9.5 Epson printer wf3520 connected via wifi is working - latest printer software installed -when trying to add an air printer sometimes its showing up under bonjour - usually its not showing as available printer
-
ITunes Store Purchase Corrupted my iPods!
Help! Last night, I purchased a new album (Ben Folds) from iTunes store and loaded it on my 2G and 5G. Last night, I played my 5G and it kept rebooting in the middle of the album. I thought the iPod was defective until I tried to play my 2G this morn
-
Hello guys I am wondering if you help me. I'm a beginner at Flash and not sure if this can be done. Basically. On my stage in have two MovieClips. MC_1 and MC_2. When i put the mouse over MC_1 I want it to play a 'label' that is inside the MC_2 AND a