SQL script error
Hi allI create a sql script. I am getting an error on an IF clause and I can not find the reason for this is the script:
command prompt
prompt QUIN CANVI FLIGHT REALITZAR TIPUS?
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
command prompt
prompt CANVIAR has RO (PULSA 1)
prompt CANVIAR has RW (PULSA 2)
command prompt
Guest Introdueix el canvi tipus a realitzar: & & tipus
variable number of tipus_canvi;
variable tipus_antic char (10);
Start
tipus_canvi: = & tipus.
If type = 1 then tipus_antic: = "ONLINE";
ElseIf type = 2 then tipus_antic: = 'READ ONLY ';
of another raise_application_error (-20200, 'Not valor of United Nations are valid per aquesta operacio Aquest.');
end if;
end;
/
And this is the error:
ElseIf (type = 2) then tipus_antic: = 'READ ONLY ';
*
ERROR on line 4:
ORA-06550: line 4, column 25:
PLS-00103: encountered the symbol "THEN" when expecting one of the following conditions:
:= . ( % ;
ORA-06550: line 5, column 6:
PLS-00103: encountered the symbol "ELSE" when expecting one of the following conditions:
(begin case declare end exit for goto if loop mod null
pragma raise return select update when all with
< an ID > < a double quote delimited id
ORA-06550: line 7, column 1:
PLS-00103: encountered the symbol "END".
Please, can you help me?
Concerning
dbajug
Hello
Your if syntax is incorrect.
Please find below syntax
IF condition THEN
{...statements...}
ELSIF condition THEN
{...statements...}
ELSE
{...statements...}
END IF;
It's ELSIF not ELSEIF.
Twinkle
Tags: Database
Similar Questions
-
Access 2003->; Oracle 10 g: fixed error of migration, SQL script
I recently migrated an Access 2003 to SQL using Oracle SQL developer Oracle database, and the process went well, with the exception of some migration errors.
The errors I had have largely brought on 3 main groups:
(i) "doesn't have to convert' errors:
Failed to convert view Q345_Delete_NR > filename. Q345 - Delete NR: unexpected node in the AST: EXEC_PARAM_LIST: column of the row-1-1
(II) 'limitation of translation mistakes:
Limitation of the translation "cannot convert to display" met on view filename. Q326 - update column of NA column_name line 0 0
(III) "parse errors":
oracle.dbtools.migration.parser.ext.ExtStringTemplate.setValue(ExtStringTemplate.java:106)
I know that these can be fixed, but I'm unable to understand what they mean. I would be grateful for some advice on what this means and how do I address to them.
Finally, I would like to watch the complete SQL script for the database migrated - please someone let me know how to consider this in a single sheet? I would like to create a stored procedure from this one.
Thank you.
Published by: 803242 on October 19, 2010 16:23As you have an Oracle database you currently have support for this database and this is quite enough to save a service request for the SQL Migration Workbench developer.
Saving a service request will allow us to examine the migration of more detailed SQL Dev and then we can improve the product.(The stored procedures, you need to manually extract the instructions in the script generated) that you intend to do) and then put it in a procedure.
-
On Windows 7, I created a Script DBCA to automate the creation of databases identicall DB.
I've run the cmd.exe bat I started as an administrator
The xdb_protocol.sql script when catqm.sql is called, the cmd collapsed
it asks for a value of ' give a value for 4 a: ' (In German, in fact ' as you are a f³r Wert ein 4: ")
http://img62.imageshack.us/img62/1145/tempin.jpg
Sound for *: user_opt_secfiles: = ' and 4' *; " must be YES or NO is not auto-ensemble. What I wear?
---------------------------------------------------------------------------------------------------------------------------------
SQL > set xdb_pass = & 1
SQL > set res_tbs = & 2
SQL > set temp_tbs = & 3
SQL >
SQL > user_opt_secfiles variable varchar2 (30);
SQL > variable usesecfiles VARCHAR2 (3);
SQL >
SQL > Rem determine if safe files will be used for xdb.xdb$ resource
SQL > Rem
SQL >
SQL > declare
+ checkcompat 2 Boolean: = FALSE; +
start + 3 +.
+ 4: usesecfiles: = 'NO '; +
+ 5: user_opt_secfiles: = 'and 4'; +
+ 6 +
+ 7 If no option has been passed, try to use secure files +.
+ 8 if (nvl(:user_opt_secfiles,'YES')! = 'NO') then +.
+ 9 checkcompat: = TRUE; +
+ 10 end if; +
+ 11 +.
+ 12 secure files can only be used for 11.0.0.0 less compatibility level.
+ if 13 (checkcompat) then +.
+ if ((dbms_metadata_util.get_canonical_vsn (dbms_metadata_util.get_compat+) 14))
_vsn()) > = +.
(+ 15 dbms_metadata_util.get_canonical_vsn ('11.0.0.0'))) then +.
+ 16: usesecfiles: = 'YES '; +
+ 17 end if; +
+ 18 end if; +
+ 19 +.
+ exception 20 +.
+ 21 then than others then +.
+ 22 return; +
+ 23 end; +
+ 24 / +.
As you are a f³r Wert ein 4:
---------------------------------------------------------------------------------------------------------------------------------
The following scripts should be run from the shell, BOOL where it is blocked scored
@D:\app\admin\DBNAME\scripts\CreateDB.sql
@D:\app\admin\DBNAME\scripts\CreateDBFiles.sql
@D:\app\admin\DBNAME\scripts\CreateDBCatalog.sql
@D:\app\admin\DBNAME\scripts\JServer.sql
* @D:\app\admin\DBNAME\scripts\xdb_protocol. SQL *.
@D:\app\admin\DBNAME\scripts\ordinst.sql
@D:\app\admin\DBNAME\scripts\interMedia.sql
@D:\app\admin\DBNAME\scripts\emRepository.sql
@D:\app\admin\DBNAME\scripts\apex.sql
@D:\app\admin\DBNAME\scripts\lockAccount.sql
@D:\app\admin\DBNAME\scripts\postDBCreation.sql
call the xdb_protocol. SQL cells line of BOOL
SET VERIFY OFF
Connect "SYS" / "' & & sysPassword ' as SYSDBA"
set echo on
coil D:\app\admin\DBNAME\scripts\xdb_protocol.log append
* @D:\app\product\11.2.0\dbhome_1\rdbms\admin\catqm. SQL * change_on_install SYSAUX TEMP;
Connect "SYS" / "' & & sysPassword ' as SYSDBA"
@D:\app\product\11.2.0\dbhome_1\rdbms\admin\catxdbj.sql;
@D:\app\product\11.2.0\dbhome_1\rdbms\admin\catrul.sql;
I HOPE I CAN DO THAT I HAVE NOT DESTROYED THE INSTALLATION. I'VE BEEN SED IT WOULD ALL AUTOMATICALLY THE SAME MAKE :(
The configuration for my new DB* was simple
Create the database-> custom database
File server
Configure Enterprise Manager
No notification
File system
Locations of files of database model + Execute an empy Script
No Flash Recovery-no-no archiving Oracle JVM - N ° Oracle XML DB
Only the Enterprise Manager (SYSAUX) repository
Memory typical < 1 GB
Automatic memory management
Standard sizing 8192 etc..
Selected character set AL32UTF8
Dedicated server mode
Leave the default settings 11g s
Published by: Goodfire on May 17, 2013 13:55
Published by: Goodfire on May 17, 2013 15:55Hello
You must add a setting to YES in the end, it will work
as@D:\app\product\11.2.0\dbhome_1\rdbms\admin\catqm.sql change_on_install SYSAUX TEMP YES;
-
Hi friends,
I started this thread yesterday, but for some reason that I'm not able to answer/continue on this old thread. Here are the details from the old thread
I need help with a sql script to update sid_no_new column with values based on sid_no for about 6000 + records.
Here is an example below...
SQL > select * from test1;
SID_NO SID_NO_NEW UNIT_NO
-------------------- -------------------- --------------------
2000 unit1
2000 unit3
2000 unit4
2002 unit16
4500 unit22
In the example above, there are 3 sid_no consecutive '2000'. Sid_no_new must be 2000_1, 2000_2, 2000_3, respectively.
It should be like:
SQL > select * from test1;
SID_NO SID_NO_NEW UNIT_NO
-------------------- -------------------- --------------------
2000 2000_1 unit1
2000 2000_2 unit3
unit4 2000_3 2000
2002 2002 unit16
4500 4500 unit22
I ran the script (thanks to the experts who have contributed to) below, it works very well for the above documents, but I get ORA-30926 error when I run on the table with 6000 records...
Fusion IN test1 tgt USING
(SELECT sid_no,
sid_no_new,
unit_no,
Count (sid_no) over (partition BY sid_no) cnt,
ROW_NUMBER() over (partition BY order of sid_no to unit_no) rn
OF test1
) CBC ON(tgt.sid_no=src.sid_no AND tgt.unit_no=src.unit_no)
WHEN matched THEN
UPDATE SET Sid_no_new = CASE WHEN cnt > 1 THEN sid_no |' _'. RN ELSE sid_no END;
ERROR on line 1:
ORA-30926: failed to get a stable set of rows in the source tables
Please give your suggestions... Thank you very much
In fact, this could be done easier:
SQL > select *.
test1 2
3.
SID_ SID_NO UNIT_N
---- ------ ------
2000 2000_1 unit1
2000 2000_2 unit3
unit4 2000_3 2000
2002 2002 unit16
4500 4500 unit22
SQL > select *.
2 of test4
3.
UID_NO TYP RULE_DUE
---------- --- ----------
RAF 2000 90
3140 TH 100
6712 JUL 21
233 12 H6
SQL > fusion
2 in d of test4
3 use)
4 with as t4)
5. Select uid_no,
6 type,
7 rule_due,
8 rowid RID,
9 uid_no || '_' || ROW_NUMBER() over (partition by uid_no by 1 order) sid_no_new
10 of test4
11 )
12. Select t1.sid_no_new,
T4.type 13,
T4.rule_due 14,
15 cases
16 when t1.sid_no = t1.sid_no_new then t4.rid
17 when t4.sid_no_new = t1.sid_no_new then t4.rid
18 end rid
19 of t4,
Test1 20 t1
21 where t1.sid_no = t4.uid_no
22 ) s
23 on)
24 d.rowid = s.rid
25 )
26 when matched
27 then
Update 28
29 set d.uid_no = s.sid_no_new
30 when no match
31 then
32 insert
33 values)
s.sid_no_new 34,
s.type 35,
36 s.rule_due
37 )
38.
3 lines merged.
SQL > select *.
2 of test4
3.
UID_NO TYP RULE_DUE
---------- --- ----------
2000_1 RAF 90
3140 TH 100
6712 JUL 21
233 12 H6
2000_3 RAF 90
2000_2 RAF 90
6 selected lines.
SQL >
SY.
-
Call of from.mxl under linux .sql script file
Hello Experts,
I have a requirement to call the sql script in the maxl file in the linux server. I get EOF file error.
Could you please say how to achieve this requirement.
MAXL Script:
Reel to ' / / essbase02//MaxL//Test_MR.log ';
the value of message level.
Set timestamp
echo 'start logging ';
login "admin", "password" on 'server '.
echo "beginning of sh execution."
MSH ' / / essbase02//MaxL//Test_MR.sh';
/ * Create label * /.
echo "Completed";
disconnection;
spool off;
Contents of the Test_MR.sh file:
sqlplus-s user@orcl/password @"' / / essbase02//MaxL//TEST.sql '"
Journal for the maxl:
essmsh timestamp: Wed Aug 5 23:17:35 2015
'Start of logging.
essmsh timestamp: Wed Aug 5 23:17:35 2015
MAXL > login "admin" "admin" on "server1.hq.emirates.com";
OK/INFO - 1051034 - [admin@Native Directory] user connection.
OK/INFO - 1241001 - connected to Essbase.
essmsh timestamp: Wed Aug 5 23:17:35 2015
"Beginning of HS performance."
essmsh timestamp: Wed Aug 5 23:17:35 2015
MAXL > sqlplus-s user@orcl/password @ "/ essbase02/MaxL/TEST." SQL ".
2 >
3 >
4 >
essmsh error: end of file breaks the statement
essmsh timestamp: Wed Aug 5 23:17:35 2015
essmsh timestamp: Wed Aug 5 23:17:35 2015
"Completed".
essmsh timestamp: Wed Aug 5 23:17:35 2015
MAXL > disconnect;
The user admin is offline
essmsh timestamp: Wed Aug 5 23:17:35 2015
Thank you
RM
If you want to execute operating system commands you use Shell, not "msh". MSH is to call an additional MaxL script with MaxL orders only.
Optionally, there should be no need to store the command shell in a separate file, that is, it should be possible to place the command sqlplus directly inside the MaxL script when you use the Shell.
-
Hello
I'm trying to run a script sql in Toad and I feel say syntax error:
ORA-00907: lack of right parenthesis
I tried different ways to solve this problem, but can't. Here is the sql script I'm running and get the result. Please any help would be appreciated.
SELECT Metric_Name,
DECODE (Metric_run_mode, 1, ' on)
Ask ', 2, 'Regular') Run_Mode, Max_Run,Min_Run,
Avg_Run,
number_of_runs,
Max_Run-Avg_Run,
Avg_Run-Min_Run,
Avg_Run * number_of_runs,.
NUM_RECORDS
)
(SELECT Metric_Name, Metric_run_mode, )
MAX (Runtime_In_Seconds) Max_Run,
MIN (Runtime_In_Seconds) Min_Run,
Round (AVG (Runtime_In_Seconds), 2) AS Avg_Run,
Count (*) AS number_of_runs,Max (NUM_RECORDS) NUM_RECORDS
OF
(SELECT DISTINCT
B.Metric_Name,
B.Metric_run_mode,
ROUND ((A.Result_Stored-A.Request_To_Run) * 24 * 60 * 602) AS
Runtime_In_Seconds,
Success_code,
A.NUM_RECORDSOf
SI_INFOLET_RUN_STATISTICS has,
Si_Metrics_T BWHERE
a.INFOLET_ID = B.METRIC_ID and (select in b.metric_id
separate input_metric_id of si_metric_columns where metric_id = (select
metric_id si_metrics where metric_name =' REM MS REPAIR ACTION
PLAN ");"Thanks in advance.
See in this query, you have a group by clause.
-
Backingup database using SQL script
Hello
Let me start by saying I am new to Oracle and I'm learning how to do a project where I have to write a SQL script that allows you to back up all data files (i.e. control, redo log and data files). Assuming that all the files are stored in a folder, the source locations and the destination of these files must be provided as 'substitution variables. The script must implement the following tasks (directions)
- Log in as the SYS user with SYSDBA role
- Closing the database
- Copy the files to the location of the source database and store it in the destination location
- Restart the database
- Log in the user SCOTT
In addition, the script must use the "HOST" command to publish the operating system command to perform the copy task.
* Since this is just a learning project and not a real scenario, I can't run my script in SQLplus to verify if it is correct. That's why I ask for professional advice. I am currently working with Oracle 11 g Enterprise running on a client Windows XP OS.
Here's what I decided, it's a cold backup, please let me know if what I do is correct so far, and if not can you please steer me in the right direction.
connect SYS / < password > have SYSDBA
Shutdown;
Copy of HOST of & source_file to & destination_file; -It is the line that confuses me.
connect SYS / < password > have SYSDBA
start-up;
Connect scott/tiger
Thanks in advance for your time and input.
I currently have the free version of 11g Oracle Enterprise downloaded on my computer, running on VB with the client Windows XP OS. But being new to this that I find myself afraid of bad script execution that can break my DB. I know that I can just reload and try again, but I try to approach the question as carefully as possible. Although the error codes help me understand what I am doing wrong much of the time.
Break things (and their fixation) is how to learn. Because you are running in VBox, simply take a snapshot of vbox system before testing. So if it is irrevocably broken, you just restore the snapshot system.
But give what you're trying to do, what do you think might happen this may break your db? As far as the db is concerned, everything you do connect, stop and commissioning. Nothing can go off of the truth of that.
-
BeanShell script error: Parse error
Hi all
I'm dropping database objects by using the ODI process and keep the tech like JAVA Shellbean
Below is the code I use:
< @.
import java. IO;
import java.sql. *;
import java.lang. *;
String url="jdbc:oracle:thin:@dummy:1521:Test; »
String ID = "Test1";
Pass the string = "Test2."
Connection myCon1 = java.sql.DriverManager.getConnection (url, id, pass);
Connection myCon2 = java.sql.DriverManager.getConnection (url, id, pass);
Statement myStmt1 = myCon1.createStatement ();
Statement myStmt2 = myCon2.createStatement ();
String sql1 = "SELECT OBJECT_NAME, OBJECT_TYPE USER_OBJECTS_T";
ResultSet rs = myStmt1.executeQuery (sql1);
String type = null;
String name = null;
Sql2 string = null;
String joins = null;
try {}
While (RS. Next())
{
type = rs.getString (1);
name = rs.getString (2);
SQL2 = 'DROP' + type + "" + name);
myStmt2.executeUpdate (sql2);
}
RS. Close();
myStmt2.close ();
myStmt1.close ();
myCon1.close ();
myCon2.close ();
}
catch (SQLException e)
{
out.println (e.getMessage ());
}
@ >
When I run the above code, he throws below error:
org.apache.bsf.BSFException: BeanShell script error: parse error at line 1, column 36. Met: 950 info OSB: own on line database: column 0: columnNo
at bsh.util.BeanShellBSFEngine.eval (unknown Source)
at bsh.util.BeanShellBSFEngine.exec (unknown Source)
at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.execInBSFEngine(SnpScriptingInterpretor.java:322)
at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.exec(SnpScriptingInterpretor.java:170)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java:2473)
at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:48)
at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:1)
at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:580)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:468)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2128)
to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ 2.doAction(StartSessRequestProcessor.java:366)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$ 0 (StartSessRequestProcessor.java:292)
to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ StartSessTask.doExecute (StartSessRequestProcessor.java:855)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
to oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$ 2.run(DefaultAgentTaskExecutor.java:83)
at java.lang.Thread.run(Thread.java:662)
But when you analyze the root on that cause, I found that the problem the code below
SQL2 = 'DROP' + type + "" + name);
myStmt2.executeUpdate (sql2); get the error at this stage
Let me know, if one aware or how to clear this error.
Thanks in advance!
By Fabien
you have these the wrong way round
type = rs.getString (1);
name = rs.getString (2);
Switch to
type = rs.getString (2);
name = rs.getString (1);
and it should work.
-
Output is not as expected (getting wrapped) for a simple sql script
Hello
I try to run a simple sql script with a few queries including a semi colon output (;) when text file separated that later - I can open in excel.
My SQL file contains in part the code - below
SELECT
"PORTFOLIO" | « ; » ||
"CONTRACT # | « ; » ||
"CONS_INV #" | « ; » ||
"CUSTOMER #" | « ; » ||
"CLIENT_NAME | « ; » ||
'MESSAGE ' | « ; » ||
"REQUEST_ID" | « ; » ||
"BILL_TO_COUNTRY" | « ; » ||
"BILL_TO_ADDRESS1" | « ; » ||
"BILL_TO_ADDRESS2" | « ; » ||
"BILL_TO_ADDRESS3" | « ; » ||
"BILL_TO_ADDRESS4" | « ; » ||
"BILL_TO_CITY" | « ; » ||
"BILL_TO_POSTAL_CODE" | « ; » ||
"BILL_TO_STATE" | « ; » ||
"BILL_TO_PROVINCE" | « ; » ||
"BILL_TO_COUNTY" | « ; » ||
"SHIP_TO_COUNTRY | « ; » ||
"SHIP_TO_ADDRESS1" | « ; » ||
"SHIP_TO_ADDRESS2" | « ; » ||
"SHIP_TO_ADDRESS3" | « ; » ||
"SHIP_TO_ADDRESS4" | « ; » ||
"SHIP_TO_CITY" | « ; » ||
"SHIP_TO_POSTAL_CODE" | « ; » ||
"SHIP_TO_STATE | « ; » ||
"SHIP_TO_PROVINCE" | « ; » ||
"SHIP_TO_COUNTY" | « ; » ||
"INVOICE_DATE | « ; » ||
"INVOICE_CREATION_DATE" | « ; » ||
"PARTIALLY_DROPPED" | « ; » ||
"AMOUNT".
OF the double
/
SELECT "DOUBLE
/
SELECT "error Code" | « ; » ||' Error message "OF the DOUBLE
/
SELECT lookup_code. « ; » || Description
OF fnd_lookup_values
WHERE lookup_type = 'CUST_ERROR. '
/
The issue I'm facing is that the output of the competitive program file comes out bit so enter each line only 132 characters in a line and therefore gets pushed in the next row in excel.
Output-
PORTFOLIO; CONTRACT #; CONS_INV #; CUSTOMER #; CLIENT_NAME; MESSAGE; REQUEST_ID; BILL_TO_COUNTRY; BILL_TO_ADDRESS1; BILL_TO_ADDRESS2; BILL_TO_A
DDRESS3; BILL_TO_ADDRESS4; BILL_TO_CITY; BILL_TO_POSTAL_CODE; BILL_TO_STATE; BILL_TO_PROVINCE; BILL_TO_COUNTY; SHIP_TO_COUNTRY; SHIP_TO_ADDR
ESS1; SHIP_TO_ADDRESS2; SHIP_TO_ADDRESS3; SHIP_TO_ADDRESS4; SHIP_TO_CITY; SHIP_TO_POSTAL_CODE; SHIP_TO_STATE; SHIP_TO_PROVINCE; SHIP_TO_COUN
TY; INVOICE_DATE; INVOICE_CREATION_DATE; PARTIALLY_DROPPED; AMOUNT
Please advice on all of the commands that I can use in the script sql in order to expand the output page or any other workaround solutions!
Please answer as soon as possible if you can help me!
Thank you!SQL * MORE?
SQL> set lin 1000 SQL> spool your_file_out.csv SQL> your_query SQL> spool off
Kind regards
Malakshinov Sayan -
question about pl/sql script
Hi all
I need to manage other tables that will contain as follows:
whenever the user query it will be an insert in this table called mng_rishui_session that contain
track:
NUM of user's session id,
Date and time of execution of the request,
type of query
every 15 minutes, I need to delete the data of the user of some the various tables according to the type of the query.
the tables that contain the data:
mng_rishui_session / / DESC
session_id_num NOT NULL VARCHAR2 (30)
type_query not null number (2)
date of time_query
I want to write a pl/sql script like this:
issues related to the:declare cursor c1 as select session_id_num,type_query from mng_rishui_session where time_query (/*here i need to do the condition that 15 minutes has passed from the time query i don't know how to do this */ begin for e in c1 loop case e.type_query when 1 delete query1_table where session_id_num :=e.session_id_num; when 3 delete query3_table where session_id_num :=e.session_id_num; end end loop; end;
1. how to check if 15 minutes where the past
2. it is good to do with loop for writing valid deletion in the loop
or do I have to do it another way to write this.
Thanks in advance
NaamaHi, Naama,
Naama wrote:
... now my script looks like this:
mng_session. SQLdeclare cursor c1 as select session_id_num,type_query from mng_rishui_session where (sysdate - t_query) * 24 * 60 >= 15; begin for e in c1 loop case e.type_query when 1 then delete query1_table where session_id_num = e.session_id_num; when 3 then delete query3_table where session_id_num =e.session_id_num; end case; end loop; end;
first of all, I want to know where I'm going to do the validation, if I need to do.
In the PL/SQL code (so we won't do it in case of error) but after the LOOP is finished.
In other words, assuming you are using a LOOP. It will be much more effective if you just do a DELETE statement on each table. Think about it: If your mng_rishui_session has 1,000 rows where t_query (or time_query, if the column is always so called) is fortunate to have one of the type_queries you want at least 15 minutes, and 100 of these lines, then you must fetch the 1,000 rows (if not all of the table) , and separate 100 DELETE queries. It is more effective to extract 100 lines (assuming that there is an index composed of type_query and t_query) and to only 2 DELETE statements. See below.Second:
I run this script through linux system, in order to head to sleep.
My problem is that I am trying to append the output of script;
but it won't let mePeople on this site will try to help you. Why not try to help them do it?
Do not say "he won't let me": show all that you know the problem. What exactly have you tried? That's happened? If you got an error, display the full error message, including the line number. If you got the wrong results, describe what happened.My goal is:
a script running the sql scripy called:
CS-mng-session:#!bin/bash sqlplus user/passwd@dbname @mng_session /*mng_session is the script were i declare the cursor etc.*/ in the command line i want to write : (sleep 600; sh cs-mng-session)&
the problem is that if I do not exit. He recorded in sql and the script does not return to the command line.
How do I overcome this problem?Make an EXIT.
Try something like this:
DECLARE cutoff_date DATE := SYSDATE - (15 / (24 * 60)); BEGIN DELETE query1_table WHERE session_id_num IN ( SELECT session_id_num FROM mng_rishui_session WHERE type_query = 1 AND t_query <= cutoff_date ); DELETE query3_table WHERE session_id_num IN ( SELECT session_id_num FROM mng_rishui_session WHERE type_query = 3 AND t_query <= cutoff_date ); COMMIT; -- If desired END; / EXIT;
Is there a reason why query1_table should be different from query3_table? Why can't you have just a query_table, with a column of type_query?
What happens if there is an error? You won't want to know? You must add an EXCEPTION section to write the details about the error in a log table and someone send an email on this subject.
Published by: Frank Kulash, August 31, 2010 09:07
Added / issue; -
I downloaded oracle xe and I tried to enter the page of sql script in sql and the place where you enter sqls was not editable. All of the suggestions.
Also I tried to enter the page of commands sql queries and the query works fine with a comment statement, but if
I comment with '-' or ' / *' and then it gives an error of invalid request.
Any help will be appreciated.Yes if you want to use the script editor (or IE... hmmmm) or upgrade.
New features. Better security. Special limited time offer-press until exhaustion of stocks last ;)
-
ALTER SESSION in sql script produces strange results
Why "alter session set NLS_DATE_FORMAT" would interfere with the operation of a sql script?
First of all, the script without the ALTER SESSION:
And its execution:SQL> !cat doit1.sql --alter session set NLS_DATE_FORMAT = "DD-MON-YYYY" set pagesize 99 set trimspool on col BIRTH_MONTH for a11 break on BIRTH_MONTH skip 1 spo doit.txt prompt My Membership set feedback off heading off select 'As of ' || sysdate from dual; set heading on -- select count(*) from dual; -- spool off
Everything is well with the world. Now let's throw in the ALTER SESSION:SQL> @doit1 My Membership As of 14-JAN-10 COUNT(*) ---------- 1
And its performanceSQL> !cat doit2.sql alter session set NLS_DATE_FORMAT = "DD-MON-YYYY" set pagesize 99 set trimspool on col BIRTH_MONTH for a11 break on BIRTH_MONTH skip 1 spo doit.txt prompt My Membership set feedback off heading off select 'As of ' || sysdate from dual; set heading on -- select count(*) from dual; -- spool off
Don't like the SET commands (I played a bit with many, he does not like one any of them) and does not take account of the order of the opening COILSQL> @doit2 set pagesize 99 * ERROR at line 2: ORA-00922: missing or invalid option COUNT(*) ---------- 1 not spooling currently SQL>
First of all, I've noticed this with a 10.2.0.1 connected to a 10.2.0.4 (windows) client database (HP - UX). Confirmed on my laboratory portable VM, 10.2.0.4 under OEL5, client and db on the same virtual machine.You are missing just the leak ';' at the end of the line to alter session. Add to that, it all works.
-
Other new lines in SQL script file and problem with SQL * more
Hi all
I would like to ask a question on the characters of new line inside files SQL scripts. I have a very long SQL query, stored in a file txt (ANSI encoding). Because query instructions are very long (several table joins and WHERE conditions) tried to separate, WHERE and ORDER BY clauses by inserting several new characters of lines (just hit the entrance) among them in order to improve the clarity of the source code. Now the problem is, whenever these newline characters are inserted in the file, apparently SQL * Plus cannot parse the file properly and gives me the following error message:
The problem is definitely related to these new line because characters that when I remove them, the scripts runs without any problem. I would appreciate that you could kindly guide me how should I deal with this problem. Is there any SQL * Plus command to run to correctly interpret the new line characters?SP2-0042: unknown command "FROM" - rest of line ignored. SP2-0734: unknown command beginning "myenterpri..." - rest of line ignored.
Thanks in advance,
Kind regards
DariyooshHello
In [SQL * Plus 9 | http://download.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1013073] (and), you can tell
SET SQLBLANKLINES ON
allow to completely empty rows in an SQL statement.
-
Job SQL Script using UTL_Mail.send fails
Hello world
It comes to 10.2.0.4 on Windows
I have configured UTL_Mail and it works when I send mails via sqlplus.
Now, just trying to get my work very simple SQL Script to send an email.
That's all that is in the control box (I use control of the database to create the job)
exec UTL_MAIL.send (sender = > '[email protected]',)
recipients = > "[email protected]"
CC = > '[email protected] ',.
BCC = > '[email protected] ',.
subject = > "UTL_MAIL Test."
message = > "Job ULTRAPRD INTEGER BKUP Email on PNCLULTRAPRD has successfully completed");
Natural logarithm of output
SQL * more: Release 10.2.0.4.0 - Production on Fri Jul 17 09:36:32 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL > SQL > SQL > SQL > connect.
SQL > SQL > START UTL_MAIL.send(sender => '[email protected]',;) END;
*
ERROR on line 1:
ORA-06550: line 1, column 53:
PLS-00103: encountered the symbol ";" when expecting one of the following values:
(- + new case mod not null other < an ID >)
< between double quote delimited identifiers of > < a variable binding > avg
current account is min max sql stddev sum variance prior
execute forall time timestamp interval date fusion
< a literal string with character set specification >
< a > < a SQL string between single quotes > hose
< a literal character in string quoted also defined specifications >
< an alternatively-q
SQL > SP2-0734: order unknown beginning "recipients...". "- rest of the ignored line.
SQL > SP2-0734: order unknown beginning 'cc... '. "- rest of line is ignored.
SQL > SP2-0734: order unknown beginning «bcc...» "- rest of line is ignored.
SQL > SP2-0734: beginning of unknown command "subject...". "- rest of the ignored line.
SP2-0044: for a list of known commands type HELP
and to let EXIT.
SQL > SP2-0734: order unknown start "message...". »
Thanks for all the ideas. John
Published by: user629010 on July 17, 2009 17:11
Published by: user629010 on July 17, 2009 17:13Why the output does not say:
Procedure completed successfully
????
What about -
END;
/as the last 2 lines.
-
ORA-06502: PL/SQL: digital error or value, ORA-06512: online
I'm trying to do something like that. The application works well and returns a few rows when run independently. But the script gives error:
ORA-06502: PL/SQL: digital error or value
ORA-06512: at line 108
DECLARE
QCURSOR SYS_REFCURSOR;
QUERYCONTEXT DBMS_XMLGEN. CTXHANDLE;
RESULT CLOB.
RXML XMLType.
BEGIN
OPEN QCURSOR TO SELECT
SOMECOLUMN1 "Label1"
.
.
.
.
FROM SOMETABLE;
queryContext: = DBMS_XMLGEN.newContext (qcursor);
DBMS_XMLGEN.setRowSetTag (queryContext, 'Message');
DBMS_XMLGEN.setRowTag (queryContext, 'Record');
DBMS_XMLGEN.setNullHandling (queryContext DBMS_XMLGEN. EMPTY_TAG);
-To get the result
result: = DBMS_XMLGEN.getXML (queryContext);
-Narrow context
DBMS_XMLGEN.closeContext (queryContext);
NARROW Qcursor;
Train IS NULL THEN
DBMS_OUTPUT. PUT_LINE ('(NULL)');
ON THE OTHER
DBMS_OUTPUT. Put_line (result); -Line 108
END IF;
END;
Could not understand what the problem is? Any ideas?
OmerThe result is CLOB, I remember that they must be treated differently (not via dbms_output.put_line).
Something like:
dbms_output.put_line (DBMS_LOB. GetLength (l_xmlclob));
-display the content of CLOB
LOOP
l_loc: = dbms_lob.instr (l_xmlclob, Chr (10), l_anc);
l_text: = dbms_lob.substr (l_xmlclob, l_loc - l_anc, l_anc);
l_anc: = l_loc + 1;
dbms_output.put_line (l_text);
WHEN OUTPUT l_loc = 0;
END LOOP;
Maybe you are looking for
-
Skype stopped responding whenever I try to call someone, or to join a group call. This problem has occurred while I was in a call with a friend, and it has just stopped responding out of nowhere. It also crashed when I tried to change my camera setti
-
How to check the level of ink on MG6320
I'm trying to understand how do I check my ink jet on my Canon MG6320 directly on the window of the printer rather than having to go into the PC Board and utilities, etc. Is this possible?
-
FAQ section for formatter.iso does not exist!
I can't find a way to access your formatter.iso, as on the old site in the FAQ section.
-
WRT150N suddenly does not work
Until midnight tonight, my router, which is connected to a cable modem, works very well for years, the two cables and wireless. Suddenly, however, I went to log on my desktop PC (wired connection; Windows 7), and I had no network connection. ipconf
-
Driver IDT audio in Windows 8.1 for DV6-6140us
Hi brothers! i cant find IDT audio driver Windows 8.1 for DV6-6140us in the website of hp, I'm from Argentina. all solutions? I have no sound in my laptop.