Validate SQL Script
Hi,
I am working on a perl script to test if the sql script file prepared by the Dev team can be deployed to the DB without any issue or not. My intention is not to run the script but only to check if the script will run properly without any error at the time of actual deploy or not. Is there a way wherein I can mimic the execution of the script?
consider, I has a script file CreateTable.sql which contains CREATE TABLE statement. I dont want the table to be created by mimic actual run of this script against the database. How do I do that?
TIA
-Onkar
onkar.nath wrote:
I am working on a perl script to test if the sql script file prepared by the Dev team can be deployed to the DB without any issue or not. My intention is not to run the script but only to check if the script will run properly without any error at the time of actual deploy or not. Is there a way wherein I can mimic the execution of the script?
consider, I has a script file CreateTable.sql which contains CREATE TABLE statement. I dont want the table to be created by mimic actual run of this script against the database. How do I do that?Do that by being creative? ;-)
Not possible using PL/SQL. PL/SQL has a a very flexible DBMS_SQL cursor interface - that amongst other things allow you to parse a statement into a cursor. However, a parse call also automatically executes if the parsed cursor is a DDL. With DML, you can parse and not execute.
The only other way that comes to mind is using the EXPLAIN PLAN command in the SQL language. E.g.
SQL> explain plan
2 set statement_id = 'ddl.parse.1'
3 for create table testtab2 nologging as select * from user_objects;
Explained.
SQL> --//object not created
SQL> desc testtab2
ERROR:
ORA-04043: object testtab2 does not existThere could perhaps be a method using the OCI (Oracle Call Interface) to parse a DDL without executing it. Are you using Perl-DBI? In that case you may want to look at the OCI and how Perl-DBI exposes that - and whether a DDL can be parsed as cursor without executing it.
Similar Messages
-
Hi,
How to Validate SQL scripts?
I am having set of sql files i wish to run one by one if there is any error at one file i need to notify to the user.I have created Bat file in-order to execute in a sequence.how to validate in bat file
say
01.sql ---Sucess
02.sql --- Fail -- intimate and not to execute rest of sql files
03.sql
04.sql
Thanks!933663 wrote:
I am going to create the database
cloneDBCreation.sql
CloneRmanRestore.sql
init.ora
initEDIDBTemp.ora
lockAccount.sql
postDBCreation.sql
postScripts.sql
rmanRestoreDatafiles.sql
dbname.bat
dbname.sqlSo i need to validate each and every .sql whether it succeed or not. if there is failure then needs to notify the user. Use the SQL*Plus macro/command, WHENEVER SQLERROR EXIT <n>, to terminate a sql script when it hits an error - and have it return a specific exit code to the caller (o/s command line in this case). Note that exit codes are typically defined as a single byte in shells - which means it can only returns 0 to 255.
In the command line shell, check the exit code of the previous command - which would be command than ran sqlplus and the sql script. If the exit code is for example 255, then you know the WHENEVER SQLERROR command was executed. And then you cease processing sql scripts.
Simplistically (I do not do Windows), it will look as follows:
--// sql script
whenever sqlerror exit 255
... rest of the script
@echo off
rem command shell script
prompt executing script 1
sqlplus -s /nolog @sqlscript1.sql
if ERRORLEVEL 255 goto :ScriptFailed
prompt executing script 2
sqlplus -s /nolog @sqlscript2.sql
if ERRORLEVEL 255 goto :ScriptFailed
goto :Success
:ScriptFailed
echo ...
goto :End
:Sucess
echo ..
goto :End
:End -
IF Condition in a PL/SQL Script give a report error.
Hello, Im German and I hope you can unterstand my Question.
First, I work with the HTML DB Version 1.6.0.0.0.87 and the Oracle Version 9.2.0.6.
I create a SQL Report, where a PL/SQL Script return the SQL Statement for the Report. This is my source-code, I have short it...:
Declare
sql_str varchar(2000);
sql_str_select varchar(1000) :=' select dim_sparte ... ';
sql_str_from varchar(1000) := ' from faktentabelle,dim_sparte ';
sql_str_where varchar(1000):= ' where and faktentabelle.zeit_id = :POPUP_ZEIT ';
sql_str_groupby varchar(1000):= ' group by dim_sparte.name, faktentabelle.zeit_id ';
Begin
If ( (V('POPUP_NETZGEBIET') is not NULL) and (V('POPUP_NETZGEBIET') <>
'Alle Netzgebiete')) THEN
sql_str_select := sql_str_select || ' ,dim_organisationseinheit.netzgebiet_name ';
sql_str_from := sql_str_from || ' , dim_organisationseinheit ';
sql_str_where := sql_str_where || ' and faktentabelle ... and
dim_organisationseinheit.netzgebiet_name = :POPUP_NETZGEBIET';
sql_str_groupby := sql_str_groupby || ' , dim_orga .... ';
End IF;
sql_str:= sql_str_select || sql_str_from || sql_str_where || sql_str_groupby;
htp.print(sql_str);
Return sql_str;
End;
This Script include a IF-THEN condition. The Condition is true and the sql-String-Variables are updatet.
I can get the string with htp.print() and the Statement is OK.
The report get a Error report error: ORA-1403: no data found. If I copy the printet sql String in a new Report Region with SQL String, the Report is OK. When I write IF(true) instead of IF( Condition) the Report is OK, too.
I try ist with Varibalen V(name) and with :name. Its always the same problem. I cant use IF-THEN-Else Conditions in a Script.
Please help me and say me what is the problem???
Thanks,
SimonaHi Simona,
In the sql region below the region source see that you have " Use Generic Column Names (parse query at runtime only)" check and not " Use Query-Specific Column Names and Validate Query".
This error you usually get when you have a mismatch in your report heading.
Vivek
[email protected] -
How to test a simple PL SQL function from another PL SQL script
Hi,
I have created a function. Now i need to test that whether it is returning the correct values or not.
For that, i have written anothe pl sql script and trying to call this function. Im passing all the IN parameters in that function. I assume here that OUT parameters will provide me the result. Im trying to display the OUT parameter one by one to see my result.
I'm using toad as sql client here connected with oracle.
pl sql script:-
DECLARE
BEGIN
DBMS_OUTPUT.PUT_LINE('$$$$$$$ VINOD KUMAR NAIR $$$$$$$');
FETCH_ORDER_PRODUCT_DATA(320171302, 1006, 6999,
ODNumber OUT VARCHAR2, Line_Number OUT VARCHAR2,
ServiceID OUT VARCHAR2, BilltoNumber OUT VARCHAR2,
AnnualPrice OUT NUMBER, CoverageCode OUT VARCHAR2)
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ODNumber );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | Line_Number );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ServiceID );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | BilltoNumber );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | AnnualPrice );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | CoverageCode );
END;
Function:-
Program Name : SPOT_Order_Product_Data_For_CFS.sql
Description : Function to Validate parameters from CFS
By : Vinod Kumar
Date : 08/19/2011
Modification History
By When TAR Description
CREATE OR REPLACE FUNCTION FETCH_ORDER_PRODUCT_DATA(orderNumber IN VARCHAR2, customerNumber IN VARCHAR2,
productLine IN VARCHAR2, ODNumber OUT VARCHAR2,
Line_Number OUT VARCHAR2, ServiceID OUT VARCHAR2,
BilltoNumber OUT VARCHAR2, AnnualPrice OUT NUMBER,
CoverageCode OUT VARCHAR2)
RETURN VARCHAR2 IS
lv_err_msg VARCHAR2(100) := '';
lv_bucket_id VARCHAR2(14);
lv_bill_number VARCHAR2(30);
lv_anual_price NUMBER;
lv_coverage_code VARCHAR2(8);
lv_quote_num NUMBER(10) := NULL;
lv_line_num NUMBER(5) := 0;
lv_customer_number VARCHAR2(30) := customerNumber;
lv_product_id VARCHAR2(14) := productLine;
lv_count_quote NUMBER := 0;
lv_quote_status VARCHAR2(5);
lv_quote_version NUMBER(2):=0;
BEGIN
IF INSTR(orderNumber, '-') = 0 THEN
lv_quote_num := orderNumber;
ELSE
lv_quote_num := SPT_Delimiter(orderNumber, 1, '-');
lv_line_num := SPT_Delimiter(orderNumber, 2, '-');
END IF;
--Check status of the quote COM, APP
SELECT COUNT(*) INTO lv_count_quote FROM sot_order_header WHERE ORDER_NUMBER=lv_quote_num
AND ORDER_STATUS IN ('APP', 'COM') AND CUSTOMER_NUMBER = lv_customer_number;
IF lv_count_quote = 0 THEN
lv_err_msg := 'Invalid Order number';
RETURN lv_err_msg;
END IF;
-- Fetch the latest version on SPOT quote
SELECT MAX(VERSION_NUMBER) INTO lv_quote_version FROM SPT_QUOTE_HEADER WHERE QUOTE_NUMBER = lv_quote_num
AND CUSTOMER_NUMBER = lv_customer_number;
-- If quote is valid fetch the data in OUT parameters
IF lv_line_num = 0 THEN
BEGIN
SELECT a.CUSTOMER_BILLTO_NUMBER,
b.LINE_NUMBER, b.BUCKET_ID,
b.ANNUAL_REF_RATE_USD, b.COVERAGE_CODE
INTO lv_bill_number,lv_line_num,lv_bucket_id,lv_anual_price,lv_coverage_code
FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
WHERE a.QUOTE_NUMBER = lv_quote_num
AND a.CUSTOMER_NUMBER = lv_customer_number
AND a.VERSION_NUMBER = lv_quote_version
AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
AND a.VERSION_NUMBER = b.VERSION_NUMBER
AND b.PRODUCT_ID = lv_product_id;
ODNumber := lv_quote_num;
BilltoNumber := lv_bill_number;
Line_Number := lv_line_num;
ServiceID := lv_bucket_id;
AnnualPrice := lv_anual_price;
CoverageCode := lv_coverage_code;
RETURN '';
EXCEPTION WHEN OTHERS THEN
lv_err_msg := 'Multiple PIDs existing in the SPOT order, please provide the SPOT order + line number as input data';
RETURN lv_err_msg;
END;
ELSE
BEGIN
SELECT a.CUSTOMER_BILLTO_NUMBER,
b.BUCKET_ID, b.ANNUAL_REF_RATE_USD,
b.COVERAGE_CODE
INTO lv_bill_number,lv_bucket_id,lv_anual_price,lv_coverage_code
FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
WHERE a.QUOTE_NUMBER = lv_quote_num
AND a.CUSTOMER_NUMBER = lv_customer_number
AND a.VERSION_NUMBER = lv_quote_version
AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
AND a.VERSION_NUMBER = b.VERSION_NUMBER
AND b.PRODUCT_ID = lv_product_id
AND b.LINE_NUMBER = lv_line_num;
ODNumber := lv_quote_num;
BilltoNumber := lv_bill_number;
Line_Number := lv_line_num;
ServiceID := lv_bucket_id;
AnnualPrice := lv_anual_price;
CoverageCode := lv_coverage_code;
RETURN '';
EXCEPTION WHEN OTHERS THEN
lv_err_msg := 'Multiple SPOT lines exist with same parameter';
RETURN lv_err_msg;
END;
END IF;
EXCEPTION
WHEN OTHERS THEN
lv_err_msg := '@@@ EXCEPTION THROWN @@@ '|| SUBSTR(SQLERRM,1,120);
RETURN lv_err_msg ;
END;
Don't look at the function, it might have errors but my primary concern is how to test this function. Once I start doing its testing then only i can understand any bugs(if any).
My pl sql is not so good. Im still learning. I don't understand IN and OUT parameters are.
I just know that IN parameters r those whick we pass in to the function wen we call it and OUT parameters are those through which we get the result.
Thanks in advance
Vinod Kumar Nair20100511 wrote:
I wondered how I could test the output of the function from within TOAD?I usually create the following function in my developer schema:
create or replace function BoolToChar( b boolean ) return varchar2 is
begin
if b then
return( 'TRUE' );
else
return( 'FALSE' );
end if;
end;To test a function like yours, the following will do in SQL*Plus/TOAD/etc:
begin
DBMS_OUTPUT.put_line(
BoolToChar( XCCC_PO_APPROVALLIST_S1.does_cpa_exist(1017934) )
end;
I'm probably doing 101 things wrong here, but thought I'd ask anyway and risk being shouted at.Shout at? You reckon? I thought people risked being beaten with a lead pipe, or pelted with beer cans and stale pretzels - which makes being shouted at a really safe and viable alternative. {noformat};-){noformat} -
Error in SQL script generated from OWB 10.1.0.4.0 Metadata Export Bridge
Hi... maybe i´m abusing this forum .. but .. when you have questions .. you have to look for answers
I use OWB 10.1.0.4 to buid some dimensions and one cube. I validate and generate this object and the result was successful.
I made the deployment and everithing goes OK !!!.
The problem appears when i want to generate metadata over this objects. I use the option Project > Metadata > Export > Gridge and use the option "Oracle 9i OLAP" like the product where i want to transfer the metadata .. and i got the SQL script without any errors. I suppose that i take the sql script i run it into SQL*plus ... so i do it.. and i got this errors:
declare
ERROR at line 1:
ORA-06501: PL/SQL: program error
ORA-06512: at line 119
ORA-06510: PL/SQL: unhandled user-defined exception
The same error for any dimension in script..
Any help .. will be fully valued for me ..
best regards
Lisandro.But how did you identify that there are no runtime records in all_rt_audit_executions for your PL/SQL procedure?
I guess you tried to search by procedure name... (but what column you used for searching)
In my case all_rt_audit_executions and wb_rtv_audit_executions contains the same number of records, so they should be always in sync.
Oleg -
Validate SQL string before executing
I am attempting to find a way to validate an SQL script file before executing against a database. This is to allow any errors within the script to be identified and fixed before running against a pre-live / live database.
These scripts may contain both DDL and DML.
Is there any way to run the script and only have the changes visible to the current user, with all other database users unaffected until the changes have been checked (in a similar way to running an insert / update / delete without committing the changes)? Failing this, are there any tools to check the validity of the statements within an SQL script file?
Any help with these or alternative solutions would be much appreciated.
Cheers,
SteveThis is not sensible.
How can you test a DML that creates a table (that does not create the physical table) and then test a DDL that uses that table that was not created and of which no record exist?
The validity of a SQL statement (DML or DDL) depends on numerous factors, including the state of the database at that specific point in time that it is being run. You may test/check a DML that creates an index and it is fine.. until run on production where it times out as it cannot get a lock on the table in order to create the index.
Or there is insufficient free space in the tablespace to build the index. Or the index is build in parallel and one of the PQs fail because on an Oracle bug, resulting in the complete DDL failing.
Etc. Etc.
If the intention is to be able to test an upgrade/patch/install script for a production database for every single potential problem and error, and then have a 100% guaranteed success rate in running that on production.. er.. excuse me for a moment..
<mad laughter heard from outside>
Er.. okay. Back again.
This will need - no compromises and just for starters - the exact same h/w platform, o/s, Oracle s/w, and duplicated production database (cloned perhaps) as the test platform.
And if this is not possible or feasible then you should forget about having that script tested in such a fashion in order to have a 100% guarantee of a successful production deployment... and investigate the optimum method to test as far as possible, and build a comprehensive plan for change management and dealing with problems out of this upgrade, on production. -
IF statement syntax in SQL script view
I need to include a "IF" condition in the "SELECT" section of my SQL script view.
I tried the following syntax's but I get the error 'Incorrect SQL syntax near 'IF'
1. IF(Revenue <> '0' AND Quantity <> '0', Revenue/Quantity, '0') AS Gross Price
2. IF(Revenue != '0' AND Quantity != '0', Revenue/Quantity, '0') AS Gross Price
3. IF(Revenue <> '0' AND Quantity <> '0' THEN Revenue/Quantity ELSE '0' END) AS Gross Price
4. IF(Revenue != '0' AND Quantity != '0' THEN Revenue/Quantity ELSE '0' END) AS Gross Price
My final SQL would read like follows:
SELECT field1, field2, IF(......) AS field3
FROM table1
Can anybody please help with the correct IF statement syntax to be used in the SQL script based view?Hi Lakshmi,
below is the syntax for IF statement.
IF <bool_expr1> THEN
<then_stmts1>
ELSEIF <bool_expr2>
THEN <then_stmts2>
[ELSE <else_stmts3>]
END IF
eg :
BEGIN
DECLARE found INT := 1;
SELECT count(*) INTO found FROM books WHERE isbn = :v_isbn;
IF :found = 0 THEN
INSERT INTO books VALUES (:v_isbn, 'In-Memory Data Management', 1, 1, '2011', 42.75, 'EUR');
ELSE
UPDATE books SET price = 42.75 WHERE isbn =:v_isbn;
END IF;
END;
Sreehari -
Pl/sql script needed - Urgent
Hi All,
I have one problem. I have to populate a table having rows more than 500000000 $ through PL/SQL.
For getting the idea...I have created one dummy table " T1 " with column " X " having 9 rows and
values in source are -
row 1 = 10
row 5 = 20
row 8 = 30
Other rows(2, 3, 4, 6, 7, 9) are null.
I want to carry fwd the values so the values in the same table will come like -
row 1, 2, 3, 4 = 10
row 5, 6 ,7 = 20
row 8,9 = 30
For resolving the problem i have written a procedure :
DECLARE
CURSOR cur_adb IS SELECT * FROM t1 ;
var cur_adb%rowtype ;
var1 number(10) ;
BEGIN
OPEN cur_adb ;
LOOP
FETCH cur_adb INTO var ;
DBMS_OUTPUT.PUT_LINE ( 'x=') ;
EXIT WHEN cur_adb%ROWCOUNT > 10 ;
If var is not null
then update t1
set x = var ;
var1 := VAR;
else update t1
set x = var1 ;
exit;
end if;
END LOOP;
CLOSE cur_adb ;
END ;
But it is giving me wrong result as it is fetching more rows at a time.
Pls. send me the correct Pl/SQL script as soon as possible.
Note: You can directaly send the procedure to [email protected] .
Thanks & Regs,
AshishHello,
I got the solution by adding on more column in the source table :
source table : T1 -> x x_id
10 1
2
3
4
20 5
6
7
30 8
9
The procedure is :
SQL> DECLARE
2 CURSOR cur_adb IS SELECT x, x_id FROM t1 ;
3 var number(10) ;
4 var1 number(10) ;
5 var2 number(10) ;
6 BEGIN
7 OPEN cur_adb ;
8 LOOP
9 FETCH cur_adb INTO var , var2 ;
10 If var is not null
11 then var1 := VAR;
12 elsif var is null
13 then update t1
14 set x = var1
15 where x_id = var2;
16 end if;
17 DBMS_OUTPUT.PUT_LINE ('The value of x=' || var) ;
18 Exit when cur_adb%ROWCOUNT > 9 or cur_adb%NOTFOUND ;
19 END LOOP;
20 CLOSE cur_adb ;
21 END ;
22 /
The value of x=10
The value of x=10
The value of x=10
The value of x=10
The value of x=20
The value of x=20
The value of x=20
The value of x=30
The value of x=30
The value of x=30
PL/SQL procedure successfully completed.
Thanks everyone for helping me........
Regards,
Ashish -
Can't Upload SQL scripts or application scripts in APEX 3.1
I have installed APEX 3.1 on an Oracle 10g database.
I can log in to APEX, create applications, and run applications.
One application I import is the sample OEHR application which imports correctly at the hosted site.
However, when I try to upload an SQL script or import the sample application I get
"Page not Found" for this page http://csora:7777/pls/apex/wwv_flow.accept
I've included my dads.conf below and also some Apache error entries
Alias /i/ "e:\oracle\product\10.1.0\Db\Apache\Apache\images/"
AddType text/xml xbl
AddType text/x-component htc
<Location /pls/apex>
Order deny,allow
PlsqlDocumentPath docs
AllowOverride None
PlsqlDocumentProcedure wwv_flow_file_mgr.process_download
PlsqlDatabaseConnectString csora:1521:ORCL ServiceNameFormat
PlsqlNLSLanguage AMERICAN_AMERICA.AL32UTF8
PlsqlAuthenticationMode Basic
SetHandler pls_handler
PlsqlDocumentTablename wwv_flow_file_object$
PlsqlDatabaseUsername APEX_PUBLIC_USER
plsqlDefaultPage apex
PlsqlDatabasePassword hocking
Allow from all
</Location>
I:[Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2864:2873,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/topnav2.gif
[Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2924:2771,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/left_curve.gif
[Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2944:2767,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/left_curve.gif
[Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2972:2750,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/right_curve.gif
[Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2940:2762,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/right_curve.gif
[Mon Apr 14 16:19:33 2008] [error] [client 10.116.101.158] [ecid: 1208204373:198.30.4.195:2696:2924:2773,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/topnav2.gif
[Mon Apr 14 16:21:48 2008] [error] [client 10.116.101.158] [ecid: 1208204507:198.30.4.195:2696:2948:2801,0] mod_plsql: /pls/apex/wwv_flow.accept HTTP-404 ORA-00942: table or view does not exist
[Mon Apr 14 16:23:29 2008] [error] [client 10.116.101.158] [ecid: 1208204609:198.30.4.195:2696:2788:2760,0] mod_plsql: /pls/apex/wwv_flow.accept HTTP-404 ORA-00942: table or view does not exist
[Mon Apr 14 16:23:29 2008] [error] [client 10.116.101.158] [ecid: 1208204609:198.30.4.195:2696:2788:2761,0] mod_wchandshake: incorrect uri: name="p_t04" passed in.
[Mon Apr 14 16:23:29 2008] [error] [client 10.116.101.158] [ecid: 1208204609:198.30.4.195:2696:2788:2761,0] Invalid URI in request -data; name="p_t04"
Am I missing some files or directories from the 3.1 install? Any help would be appreciated since I think I'm close to having APEX fully functional.Val,
In this line:
PlsqlDocumentTablename wwv_flow_file_object$
...that needs to be wwv_flow_file_objects$
Scott -
How can I convert a mysql sql script to a oracle sql script
Hi,
We have a bunch of tables with data running on a mysql server.
This should now be moved to an oracle 9 db.
are there any tools to convert the import script of a mysql db
to a format of the sql script that work for oracle ?
Thanks
MichaelOracle has a tool called Migration Toolbench, which supports MySQL 3.22 and 3.23:
http://otn.oracle.com/tech/migration/workbench/content.html
On this same topic, I was wondering if anybody has tried migrating from PostgreSQL to Oracle 9i. The workbench doesn't seem to support it, and feeding a pg_dump file directly into SQL*Plus is not working. -
How to reference dynamic parameters in the PL/SQL script
The meaning of dynamic parameter is the position and name of parameters will be changed based on the data structure of a referenced text file reading by the concerned PL/SQL script. Anybody can post a sample code will be very appreciated.
The SQL and PL/SQL discussion forum is a good source for this kind of information.
The URL is:
PL/SQL -
How can I run a SQL script file...
How can I run a SQL script file from a location on my computer without providing the whole path?
Is there some way I can set a "Working folder" in SQL Plus??
Thanks!
TomYou can create an environment variable called "SQLPATH" which is a list of directories that SQL*Plus will search for your .SQL
scripts.
I would like to use another directory than the oracle/bin...
How can I do this ??
Hello,
U can do this by this way:
Save odm_script.sql file to the default Oracle
directory i.e. Oracle-Home/bin and Run following command
through SQL Plus.
SQL>@Script_Name
I hope this will resolve ur problem.
Regards,
Omer Saeed Khan. -
Retrieve alert values for use as parameter in corrective action sql script
I am trying to write a corrective action sql script to kill a session that is blocking other sessions. I have the "blocking session count" metric set and the alert is firing correctly.
Is there any way to retrieve the sid and serial number from the alert generated and use it in a corrective action sql script?
Here is the alert generated:
Target Name=myproddb.world
Target Type=Database Instance
Host=myprodserver
Metric=Blocking Session Count
Blocking Session ID=SID: 522 Serial#: 5228
Timestamp=Mar 4, 2008 5:57:12 PM EST
Severity=Warning
Message=Session 522 is blocking 1 other sessions
Notification Rule Name=Testing Corrective actions
Notification Rule Owner=sysman
Clearly the sid, and serial # is contained within the alert Message field
what I want to write for the sql script is :
alter system kill session '%sid%,%serial_no%' immediate;
and have GC pass in the sid and serial_no to the script.
The "Target Properties" listed on the right of the Edit Corrective Action screen lists minimal details pertaining to the alert and certainly not the session sid, serial no.
Generically, is there any way to retrieve the values from an alert and use them in a corrective action script or job?
I've looked into getting the values from the mgmt$alert_history table, but I'm hoping that GC can pass the values to the sql script.
thanks in advance for your help.Hi
You can implementing a procedure like this.
1. When a block session count alarms occurs, there is a column in the v$lock that you can examine.
#!/bin/ksh
#kill_block_session.sh
#first export your variables
export ORACLE_HOME=/oracle/product/10.2.0.3
export ORACLE_SID=SIDNAME
$ORACLE_HOME/bin/sqlplus "/ as sysdba" << EOF
execute immediate killed_blocks;
EOF
# end
The killed_blocks is a procedure:
create procedure
declare
v_sid varchar2(15);
v_serial varchar2(15);
-- now a sql query that retrieve the sid and serial
-- you can obtain these values from v$session and v$lock
select vs.sid,vs.serial into v_sid,v_serial
from v$session vs,v$lock vl
where vs.sid=vl.sid
and vl.block >0
-- After this, you execute a dbms_put line with these
-- values
But you understant that this response action is very dangerous, because its possible that you kill sessions that the blocking are transitient.
You must examine your enviroment and your application and establish the metric like UDM and not for only session blocking count.
You must to see:
- The type of block
- The ctime time in the v$lock for to understatn the amount of time to determine that the block is need killed.
- In my opinion you need a special UDM and deactivate the blocking sesion count
If you want help to create this UDM send me a mail to [email protected]
Regards
Robert -
How to run a sql script in oracle forms
Hi,
For me there is an sql script. I need to run that sql script in forms.
Actually we will run that sql file in pl/sql developer by giving @and the file name.
But how to run that file in forms.
Can any one help on these.Which book I have to look.
ThanksActually there is a script files which will drop all the indexes and tables.
DROP querry will be there for each index and each table.
So I run the script all the indexes and all the tables will be deleted. So using forms I have to run that script.
Thanks -
How to execute a sql script in dbms_job?
how to execute a sql script in dbms_job?
See my response to Re: how to execute a sql script file in procedure or trigger.
Cheers, APC
Maybe you are looking for
-
Our school has four eMacs. One of them, a 1GHz, 10.3.9 Panther, 256 MB RAM, and out of warranty, has started to have a display problem. The display is showing negative colours, like white shows as black, blue shows as orange etc. This only affects ou
-
Error message in iTunes 7 (recognizing iPod)
Hi, I own a 5th gen iPod and am running iTunes on Windows XP. I recently downloaded both iTunes 7 and the newest iPod update. Since installing each of these upgrades, each time I attempt to connect my iPod to my laptop I receive the following error:
-
Check Name Error after hitting Submit Form button
The screenshot above is of the error I am receiving once clicked on the Submit button. All our users are currently running XP 32bit, Adobe Acrobat Pro 9.3.4 (which was used to create the form), Adobe Reader 9.3.4 and Outlook 2010 Exchange. I've alr
-
I cannot boot my 2012 Macbook Air 13" from external USB 2.0/3.0 drive.
I just purchased a new 2012 MacBook Air 13" with 8GB ram and 256Gb SSD. I have clones of my 2011 MBA drive made with Superduper on both a USB 2.0 and USB 3.0 external drives. The USB 2.0 drive enclosure contains the OWC Aura 256GB 6G SSD that used to
-
Deactivate Tooltips for every column in ALV
Hi Everybody, how can i deactivate the tooltip for every column in a ALV. regards, Sid