IF ELSEIF ELSE error
Good Morning
This code compiles fine:
IF v_status_code = '3' THEN
INSERT INTO CRAM_STG
(ID, ITEM_NO, CHGNBR, UI, SUPPLYACTIONCODE, QTY, ACCT, RECEIPTDATE, REQUISITIONDATE, PROCESSDATE)
VALUES
( to_char(sysdate,'YYMMDDHH24MISS') || test_seq.nextval, no_stock_rec.item_no, v_change_no, v_unit_of_issue, 'UR', no_stock_rec.order_qty,
no_stock_rec.acct, sysdate, sysdate, sysdate);
ELSE
dbms_output.put_line ('Else ' );
END IF;
However when I add an elseif I get the following error. Thanks for your help. :
END;
Error report:
ORA-06550: line 96, column 20:
PLS-00103: Encountered the symbol "V_STATUS_CODE" when expecting one of the following:
:= . ( @ % ;
Here is the ELSEIF code
IF v_status_code = '3' THEN
INSERT INTO CRAM_STG
(ID, ITEM_NO, CHGNBR, UI, SUPPLYACTIONCODE, QTY, ACCT, RECEIPTDATE, REQUISITIONDATE, PROCESSDATE)
VALUES
( to_char(sysdate,'YYMMDDHH24MISS') || test_seq.nextval, no_stock_rec.item_no, v_change_no, v_unit_of_issue, 'UR', no_stock_rec.order_qty,
no_stock_rec.acct, sysdate, sysdate, sysdate);
ELSEIF v_status_code = '4' THEN
INSERT INTO CRAM_STG
(ID, ITEM_NO, CHGNBR, UI, SUPPLYACTIONCODE, QTY, ACCT, RECEIPTDATE, REQUISITIONDATE, PROCESSDATE)
VALUES
( to_char(sysdate,'YYMMDDHH24MISS') || test_seq.nextval, no_stock_rec.item_no, v_change_no, v_unit_of_issue, 'NR', no_stock_rec.order_qty,
no_stock_rec.acct, sysdate, sysdate, sysdate);
ELSE
dbms_output.put_line ('Else ' );
END IF;
Use ELSIF instead...
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/controlstructures.htm#sthref910
Similar Messages
-
Hi
I have a trigger which had just if-else in it. Due to change in business requirement I had to re develop it and I decided to use if-elseif-else statement. I am getting the following error
47/9 PLS-00103: Encountered the symbol "C_OPSHE" when expecting one of the following:
. ( * @ % & = - + < / > at in is mod remainder not rem then
<an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
LIKE4_ LIKEC_ between || multiset member SUBMULTISET_
The symbol "then" was substituted for "C_OPSHE" to continue.
78/1 PLS-00103: Encountered the symbol "ELSE" when expecting one of the following:
begin case declare end exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe
83/1 PLS-00103: Encountered the symbol "EXCEPTION"
85/4 PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
end not pragma final instantiable order overriding static
member constructor map Can some one help me please where I am getting it wrong:
My trigger is as follows
DECLARE
crt_keyholder CLOB;
addto varchar2(100);
crt_key varchar2(75);
issue varchar2(75);
del_key varchar2(75);
CURSOR c_opsHE IS
SELECT pu.person_code FROM people_units pu
INNER JOIN unit_instances ui
ON pu.unit_instance_code = ui.fes_unit_instance_code
WHERE pu.unit_type = 'R'
AND pu.progress_status ='A'
AND pu.calocc_code LIKE '%12/13%'
AND (pu.unit_instance_code LIKE 'Z%' OR pu.unit_instance_code LIKE 'V%')
AND pu.unit_instance_code NOT LIKE 'ZX%'
AND ui.fes_source_finance = 'HEFCE';
CURSOR c_opsFE IS
SELECT pu.person_code FROM people_units pu
INNER JOIN unit_instances ui
ON pu.unit_instance_code = ui.fes_unit_instance_code
WHERE pu.unit_type = 'R'
AND pu.progress_status ='A'
AND pu.calocc_code LIKE '%12/13%'
AND (pu.unit_instance_code LIKE 'Z%' OR pu.unit_instance_code LIKE 'V%')
AND pu.unit_instance_code NOT LIKE 'ZX%'
AND ui.fes_source_finance <> 'HEFCE';
v_recOpsFE PEOPLE.PERSON_CODE%TYPE;
v_recOpsHE PEOPLE.PERSON_CODE%TYPE;
BEGIN
if :new.fes_user_29 is not null then
if :new.fes_staff_code is not null and :new.staff_user_4 = 'Y' then
crt_keyholder:= 'create keyholder'||' ' ||'"'|| :new.person_code||'"'||' '|| 'longname = "' ||:new.forename ||' '||:new.surname||'"'||' '||'comment = ""'||' '||'info1 = ""'||' '|| 'info2 ='||' '||'"'||:new.fes_staff_code||'"'||' '||'info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
addto:= 'addtocommunity keyholder'||' '||'"'|| :new.person_code ||'"'||' community = "Staff" defaultgroups = "Yes";';
crt_key:= 'create key'||' '||:new.fes_user_29||' box = '||'"General Use"'||' '||'technology = "Magnetic";';
issue:= 'issue key '||:new.fes_user_29||' '||'technology = "Magnetic" keyholder ='||' '||'"'||:new.person_code||'";';
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_keyholder,0,'');
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',addto,0,'');
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_key,0,'');
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',issue,0,'');
else if
OPEN c_opsHE;
FETCH c_opsHE INTO v_recOpsHE;
IF c_opsHE%FOUND THEN
crt_keyholder:= 'create keyholder'||' ' ||'"'|| :new.person_code||'"'||' '|| 'longname = "' ||:new.forename ||' '||:new.surname||'"'||' '||'comment = ""' ||' ' ||'info1 = "" info2 = "" info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
addto:= 'addtocommunity keyholder'||' '||'"'|| :new.person_code ||'"'||' community = "HEStudents" defaultgroups = "Yes";';
crt_key:= 'create key'||' '||:new.fes_user_29||' box = '||'"General Use"'||' '||'technology = "Magnetic";';
issue:= 'issue key '||:new.fes_user_29||' '||'technology = "Magnetic" keyholder ='||' '||'"'||:new.person_code||'";';
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_keyholder,0,'');
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',addto,0,'');
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_key,0,'');
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',issue,0,'');
end if;
CLOSE c_opsHE;
else
OPEN c_opsFE;
FETCH c_opsFE INTO v_recOpsFE;
IF c_opsFE%FOUND THEN
crt_keyholder:= 'create keyholder'||' ' ||'"'|| :new.person_code||'"'||' '|| 'longname = "' ||:new.forename ||' '||:new.surname||'"'||' '||'comment = ""' ||' ' ||'info1 = "" info2 = "" info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
addto:= 'addtocommunity keyholder'||' '||'"'|| :new.person_code ||'"'||' community = "FEStudents" defaultgroups = "Yes";';
crt_key:= 'create key'||' '||:new.fes_user_29||' box = '||'"General Use"'||' '||'technology = "Magnetic";';
issue:= 'issue key '||:new.fes_user_29||' '||'technology = "Magnetic" keyholder ='||' '||'"'||:new.person_code||'";';
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_keyholder,0,'');
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',addto,0,'');
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_key,0,'');
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',issue,0,'');
end if;
CLOSE c_opsFE;
end if;
else
del_key:= 'delete key'||' '||:old.fes_user_29||' '||'technology = "Magnetic"'||';';
insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',del_key,0,'');
end if;
EXCEPTION
WHEN others THEN Raise;
END;For better readability, I formatted your code.. please check what should be there in place of (0=0)..
DECLARE
crt_keyholder CLOB;
addto VARCHAR2 (100);
crt_key VARCHAR2 (75);
issue VARCHAR2 (75);
del_key VARCHAR2 (75);
CURSOR c_opsHE IS
SELECT pu.person_code
FROM people_units pu
INNER JOIN
unit_instances ui
ON pu.unit_instance_code = ui.fes_unit_instance_code
WHERE pu.unit_type = 'R'
AND pu.progress_status = 'A'
AND pu.calocc_code LIKE '%12/13%'
AND (pu.unit_instance_code LIKE 'Z%'
OR pu.unit_instance_code LIKE 'V%')
AND pu.unit_instance_code NOT LIKE 'ZX%'
AND ui.fes_source_finance = 'HEFCE';
CURSOR c_opsFE IS
SELECT pu.person_code
FROM people_units pu
INNER JOIN
unit_instances ui
ON pu.unit_instance_code = ui.fes_unit_instance_code
WHERE pu.unit_type = 'R'
AND pu.progress_status = 'A'
AND pu.calocc_code LIKE '%12/13%'
AND (pu.unit_instance_code LIKE 'Z%'
OR pu.unit_instance_code LIKE 'V%')
AND pu.unit_instance_code NOT LIKE 'ZX%'
AND ui.fes_source_finance != 'HEFCE';
v_recOpsFE PEOPLE.PERSON_CODE%TYPE;
v_recOpsHE PEOPLE.PERSON_CODE%TYPE;
BEGIN
IF :new.fes_user_29 IS NOT NULL THEN
IF :new.fes_staff_code IS NOT NULL AND :new.staff_user_4 = 'Y' THEN
crt_keyholder :=
'create keyholder'
|| ' '
|| '"'
|| :new.person_code
|| '"'
|| ' '
|| 'longname = "'
|| :new.forename
|| ' '
|| :new.surname
|| '"'
|| ' '
|| 'comment = ""'
|| ' '
|| 'info1 = ""'
|| ' '
|| 'info2 ='
|| ' '
|| '"'
|| :new.fes_staff_code
|| '"'
|| ' '
|| 'info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
addto :=
'addtocommunity keyholder'
|| ' '
|| '"'
|| :new.person_code
|| '"'
|| ' community = "Staff" defaultgroups = "Yes";';
crt_key :=
'create key'
|| ' '
|| :new.fes_user_29
|| ' box = '
|| '"General Use"'
|| ' '
|| 'technology = "Magnetic";';
issue :=
'issue key '
|| :new.fes_user_29
|| ' '
|| 'technology = "Magnetic" keyholder ='
|| ' '
|| '"'
|| :new.person_code
|| '";';
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
crt_keyholder,
0,
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
addto,
0,
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
crt_key,
0,
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
issue,
0,
ELSIF (0 = 0) THEN
OPEN c_opsHE;
FETCH c_opsHE INTO v_recOpsHE;
IF c_opsHE%FOUND THEN
crt_keyholder :=
'create keyholder'
|| ' '
|| '"'
|| :new.person_code
|| '"'
|| ' '
|| 'longname = "'
|| :new.forename
|| ' '
|| :new.surname
|| '"'
|| ' '
|| 'comment = ""'
|| ' '
|| 'info1 = "" info2 = "" info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
addto :=
'addtocommunity keyholder'
|| ' '
|| '"'
|| :new.person_code
|| '"'
|| ' community = "HEStudents" defaultgroups = "Yes";';
crt_key :=
'create key'
|| ' '
|| :new.fes_user_29
|| ' box = '
|| '"General Use"'
|| ' '
|| 'technology = "Magnetic";';
issue :=
'issue key '
|| :new.fes_user_29
|| ' '
|| 'technology = "Magnetic" keyholder ='
|| ' '
|| '"'
|| :new.person_code
|| '";';
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
crt_keyholder,
0,
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
addto,
0,
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
crt_key,
0,
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
issue,
0,
END IF;
CLOSE c_opsHE;
ELSE
OPEN c_opsFE;
FETCH c_opsFE INTO v_recOpsFE;
IF c_opsFE%FOUND THEN
crt_keyholder :=
'create keyholder'
|| ' '
|| '"'
|| :new.person_code
|| '"'
|| ' '
|| 'longname = "'
|| :new.forename
|| ' '
|| :new.surname
|| '"'
|| ' '
|| 'comment = ""'
|| ' '
|| 'info1 = "" info2 = "" info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
addto :=
'addtocommunity keyholder'
|| ' '
|| '"'
|| :new.person_code
|| '"'
|| ' community = "FEStudents" defaultgroups = "Yes";';
crt_key :=
'create key'
|| ' '
|| :new.fes_user_29
|| ' box = '
|| '"General Use"'
|| ' '
|| 'technology = "Magnetic";';
issue :=
'issue key '
|| :new.fes_user_29
|| ' '
|| 'technology = "Magnetic" keyholder ='
|| ' '
|| '"'
|| :new.person_code
|| '";';
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
crt_keyholder,
0,
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
addto,
0,
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
crt_key,
0,
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
issue,
0,
END IF;
CLOSE c_opsFE;
END IF;
ELSE
del_key :=
'delete key'
|| ' '
|| :old.fes_user_29
|| ' '
|| 'technology = "Magnetic"'
|| ';';
INSERT INTO ug_command
VALUES (UG_SEQUENCE.NEXTVAL,
'ORACLE',
del_key,
0,
END IF;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;Cheers,
Manik -
If elseif else echo statement with radio buttons
Hi everyone Please help me out here. I have a standard php file with 4 groups of questions (radio groups). The user must answer "yes" to ALL 4 questions where after "You Qualify" will echo on the same page. If any of the questions are answered "No" to, then "you do not qualify" must echo on the same page. If no answer is selected - then no echo This sounds like a simple if elseif else statement, but for some reason I just cant get it right. Could anyone please help me out with this? Herewith code that I have tried:
Do you like apples? Yes No
Do you like oranges?
Yes No
Do you like pears?
Yes No
Do you like lemons?
Yes No<?php
if ($a > $b) {
echo "a is bigger than b";
} elseif ($a == $b) {
echo "a is equal to b";
} else {
echo "a is smaller than b";
?> -
So, now I've been trying to learn If, elseif and else statements properly. And I'm doing something wrong.
A guy told me his website would email specific people based on what zipcode they put in the contact form on his site. I was wondering how he did it, so I tried to recreate something similar.
Here is what I've done:
1. I created a file called zipcodes.php
2. In this file it has set every zipcode to a variable. For instance:
<?php
$Nashville=("37010" or "37027" or "37040" or "37055" or "37152");
?>
3. I created a form with a field called 'zip'.
4. I created a php file called phpmail.php to send this form.
5. Right now, the top of this file looks like this:
<?php
include("zipcodes.php");
$zip=$_POST["zip"];
//NASHVILLE//
if ($zip==$Nashville)
$my_email = "[email protected]";
//Knoxville//
if ($zip==$Knoxville)
$my_email = "[email protected]";
//Huntsville//
if ($zip==$Huntsville)
$my_email = "[email protected]";
...etc.
This doesn't work. It sends them all to the last option which is texas or [email protected]
Before I had the first if set to if and all the others set to elseif
But that didn't work. It sent all the emails to Nashville email I made.
If statements must work though in this way. Because if I have this:
if ($zip==$Nashville)
$my_email = "[email protected]";
//Anything Else//
else $my_email = "[email protected]";
It works. Meaning if a zipcode is in Nashville it goes to one email - and if it isn't in Nashville - it goes to hippityhoppity.
Am I not getting something about all of this? Thanks!Yeah I know. I also wish it'd let me use PHP syntax instead of plain. I think it'd make things easier to read.
Here is the entire script. It is made to work with any form with little regard for what the form has in it. So long as there is an email field and a zip field.
<?php
include("zipcodes.php");
$zip=$_POST["zip"];
if (in_array($zip, $Nashville)) {
$my_email = ".....";
}elseif (in_array($zip, $Knoxville)) {
$my_email = ".....";
}elseif (in_array($zip, $Huntsville)) {
$my_email = ".....";
}elseif (in_array($zip, $Florida)) {
$my_email = ".....";
}elseif (in_array($zip, $Georgia)) {
$my_email = ".....";
}elseif (in_array($zip, $SouthCarolina)) {
$my_email = ".....";
}elseif (in_array($zip, $NorthCarolina)) {
$my_email = ".....";
}elseif (in_array($zip, $Pennsylvania)) {
$my_email = ".....";
}elseif (in_array($zip, $Maryland)) {
$my_email = ".....";
}elseif (in_array($zip, $Virginia)) {
$my_email = ".....";
}elseif (in_array($zip, $Texas)) {
$my_email = ".....";
} else { $my_email = ".....";
$continue = "/";
$errors = array();
if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
function recursive_array_check_header($element_value)
global $set;
if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc: )/i",$element_value)){$set = 1;}}
else
foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);}
recursive_array_check_header($_REQUEST);
if($set){$errors[] = "You cannot send an email header";}
unset($set);
if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))
if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or a colon";}
$_REQUEST['email'] = trim($_REQUEST['email']);
if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}
if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
function recursive_array_check_blank($element_value)
global $set;
if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
else
foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
recursive_array_check_blank($_REQUEST);
if(!$set){$errors[] = "You cannot send a blank form";}
unset($set);
if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;}
if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}
function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}
$message = build_message($_REQUEST);
$message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."";
$message = stripslashes($message);
$subject = "FormToEmail Comments";
$headers = "From: " . $_REQUEST['email'];
mail($my_email,$subject,$message,$headers);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Dreamweaver Tutorial - Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<div>
<center>
<b>Thank you <?php print stripslashes($_REQUEST['name']); ?></b>
<br>Your message has been sent
<p><a href="<?php print $continue; ?>">Click here to continue</a></p>
</center>
</div>
</body>
</html> -
If, elseIf, else statement block.
How would you test whether a radiobutton is selected or not?
if ( lineButton.Selected == true ){
s[ 0 ].move( move, move );;
else {
System.out.println("wasn't selected");
Keeps saying cannot find symbol - variable lineButton.
My best guess. If anyone could point out how to access the state of the button for using in this if, I would appreciate it.i think i understand what is meant by the code you posted. It asks if the radiobutton is selected, and if so, then performs the statements.
I tried to use it, hopefully properly but still get the same error.
Here is the code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class Ch09Sample extends Applet implements ActionListener
// Members
private Button moveButton = new Button( "Move" );
private TextField moveText = new TextField( "5" );
private TextField moveText2 = new TextField( "5" );
private int move = 0;
private Shape [] s = new Shape[ 4 ];;
private MyCanvas canvas = new MyCanvas();
static String lineString = "Line";
static String rectangleString = "Rectangle";
static String circleString = "Circle";
static String ovalString = "Oval";
// An inner class
class MyCanvas extends Canvas
public void paint(Graphics g)
for( int k = 0; k < s.length; k++ )
s[ k ].draw( g );
public void init()
// Construct the shapes
s[0] = new Line( 50, 80, 100, 110, Color.red );
s[1] = new Circle( new Point( 30, 180 ), 20, Color.green );
s[2] = new Oval( new Point( 150, 50 ), Color.blue );
//s[3] = new Rectangle( );
// Set the background color
this.setBackground( Color.white );
// Create the user interface
Panel p1 = new Panel();
p1.setLayout( new FlowLayout() );
p1.setBackground( Color.white );
Label label1 = new Label( "Moves in X:" );
p1.add( label1 );
p1.add( moveText );
Label label2 = new Label( "Moves in Y:" );
p1.add( label2 );
p1.add( moveText2 );
p1.add( moveButton );
JRadioButton lineButton = new JRadioButton(lineString);
lineButton.setMnemonic(KeyEvent.VK_B);
lineButton.setActionCommand(lineString);
lineButton.setSelected(true);
JRadioButton rectangleButton = new JRadioButton(rectangleString);
rectangleButton.setMnemonic(KeyEvent.VK_C);
rectangleButton.setActionCommand(rectangleString);
JRadioButton circleButton = new JRadioButton(circleString);
circleButton.setMnemonic(KeyEvent.VK_D);
circleButton.setActionCommand(circleString);
JRadioButton ovalButton = new JRadioButton(ovalString);
ovalButton.setMnemonic(KeyEvent.VK_R);
ovalButton.setActionCommand(ovalString);
ButtonGroup group = new ButtonGroup();
group.add(lineButton);
group.add(rectangleButton);
group.add(circleButton);
group.add(ovalButton);
moveButton.addActionListener( this );
lineButton.addActionListener(this);
rectangleButton.addActionListener(this);
circleButton.addActionListener(this);
ovalButton.addActionListener(this);
p1.add( lineButton );
p1.add( rectangleButton );
p1.add( circleButton );
p1.add( ovalButton );
setLayout( new BorderLayout() );
add( "North", p1 );
add( "Center", canvas );
// An instance method
public void moveDraw()
// Get the user's input
move = Integer.parseInt( moveText.getText() );
// Move the shapes polymorphically
for ( int k= 0; k < s.length; k++ )
s[ k ].move( move, move );
if(lineButton.isSelected()) {
s[ 0 ].move( move, move );;
} else {
System.out.println("wasn't selected");
// Repaint the canvas
canvas.repaint();
public void actionPerformed( ActionEvent e )
// Move the shapes and repaint the canvas
moveDraw();
} -
Hi,
I am trying to write a if statement within a JSP page. I have some images stored in the database. Some of the entries does not have images. What I want to do is, if the entry did not match the string images then I want it to do nothing and if it is null then I want it to do nothing, else I would like to show the image. How would I write this code? The following is that I have gotten right now...
<% if (rs.getString("image")==("images/untitled.gif") %>
here I want it to do nothing...
<% else if (rs.getString("image")=null)%>
don't show anything again..
<% else %> now is the change to show the image
<IMG SRC="(rs.getString("image"))" >
<% } %>
How do I say to do nothing. I don't want it to do a out println.. but if I leave it blank the error message is 'else' without 'if'
Any suggestions as to show nothing is the image does not exist? Thanks for all the commnents!I came up with a solution similar to yoda's:
<% String imagePath = rs.getString("image");
if ( imagePath != null && imagePath.equals("images/untitled.gif") )
{ %>
<img src="<%= imagePath %>">
<% } %>However, I don't quite understand your reply:
I am still showing the boxes that are null without an imageAre you saying that if the image path is null you want an image displayed or not?
--Nicole -
Using multy-conditional filters (if/then/ELSEIF/else)
Hello,
I need to create multiple policies for adding disclaimers.
We have a default disclaimer and now two unique ones for domains that need to maintain their own.
I created text recourses for all disclaimers and like to make a content filter that does the following:
if the senderdomain = UniqueDomain1 then
add disclaimerDomain1
Else if the senderdomain = UniqueDomain2 then
add disclaimerDomain2
Else
Add default Disclaimer
I created the following filter syntax:
add_disclaimer: if (recv-listener == "relay") AND (mail-from == "^.*@domain1\\.com$")
{add-footer("domain1Disclaimer");}
elif (recv-listener == "relay") AND (mail-from == "^.*@domain2\\.com$")
{add-footer("domain2Disclaimer");}
elif (recv-listener == "relay")
{add-footer("defaultDisclaimer");}
When I submit the filter I get the error "An error occurred during processing: Syntax error at the end of filter".
Does anyone know if Ironport filters support the Python "elif" routine? if so, what am I doing wrong, if not..... does anyone have any suggestions what way I can deliver this functionality?
Thank you!
StevenYou can probably get the IF/ELSE IF/ELSE logic to work on the Ironport message filters, but I would suggest that you use a combination of Outgoing mail policies and outgoing content filters.
1. Create all your different disclaimers in the [Mail Policies > Text Resources] section.
2. Create a corresponding outgoing content that pertains to each sender domain and assign the outgoing content filter.
i.e.
Let's say you have two domains and then the default domain:
domain1, domain2, default domain
if "mail-from" ends with "@domain1"
then
apply domain1-disclaimer-footer
deliver();
if "mail-from" ends with "@domain2"
then
apply domain2-disclaimer-footer
deliver();
if "mail-from" ends with "default-domain"
then
apply default-disclaimer-footer
deliver();
3. Then go to your outgoing mail policies > default policies > content filters and enable all three filters.
Similarily, you can create two additional customized outgoing mail policies and each policy can have it's own outgoing content filters.
Bottom line, you can definitely do it with message filters, but the outgoing mail policies/outgoing content filters may be easier to maintain.
Let me know if you have any questions or concerns.
apply domain2-
Hello,
I need to create multiple policies for adding disclaimers.
We have a default disclaimer and now two unique ones for domains that need to maintain their own.
I created text recourses for all disclaimers and like to make a content filter that does the following:
if the senderdomain = UniqueDomain1 then
add disclaimerDomain1
Else if the senderdomain = UniqueDomain2 then
add disclaimerDomain2
Else
Add default Disclaimer
I created the following filter syntax:
add_disclaimer: if (recv-listener == "relay") AND (mail-from == "^.*@domain1\\.com$")
{add-footer("domain1Disclaimer");}
elif (recv-listener == "relay") AND (mail-from == "^.*@domain2\\.com$")
{add-footer("domain2Disclaimer");}
elif (recv-listener == "relay")
{add-footer("defaultDisclaimer");}
When I submit the filter I get the error "An error occurred during processing: Syntax error at the end of filter".
Does anyone know if Ironport filters support the Python "elif" routine? if so, what am I doing wrong, if not..... does anyone have any suggestions what way I can deliver this functionality?
Thank you!
Steven -
Good Morning,
I have been doing if/else if scripting scripting on a form and it was working pretty well. I then had a scenario where multiple fields had to appear or not and I set them up the same way as I had in other ones and they won't work. I get an error saying I've used "else" incorrectly I've tried with field names and with subforms. Any suggestions on what I can do to correct it? I've uploaded a file with two examples of what I'm trying to do, the first uses the subforms in the script and the second uses the fields.
Thanks!
https://acrobat.com/#d=-NCGILkZZ4OUkCEpBFO-qgI just discovered one problem. If I select Yes and then select No because I changed my mind the options for Yes stay visibile. Ther reverse is also true. If I select Select One everything goes away like it should. Any thoughts on how to fix this?
-
I am trying to set up a form in flash that will email the
entered data in the fields. I have the email part functioning
correctly. My problem is getting the error message when the user
does not fill in a field.
Here is my code on my submit button:
on (release) {
if (txtName ne "" && txtFrom ne "" &&
txtMessage ne "") {
loadVariablesNum("cdontsMail.asp", 0, "POST");
gotoAndPlay("valid");
} else {
gotoAndPlay("invalid");
If I type in a 1 or any character between the quotes, it
realized that and sends an error. For instance, if I coded : if
(txtName ne "1"... and typed in a 1 in the txtName field, it would
come back as invalid. For some reason, it doesn't realize "" to
mean an empty field. What am I doing wrong here????
DaveI am working in FlashMX 2004, so I'm not sure if that has
this option. But here's the code I added:
on (release) {
trace(txtName+" "+txtName.length);
if (txtName != "" && txtFrom != "" &&
txtMessage != "") {
loadVariablesNum("cdontsMail.asp", 0, "POST");
gotoAndPlay("invalid");
} else {
gotoAndPlay("valid");
When I play the file and hit submit without entering
anything, it gives me this:
_level0.txtName 0
Dave -
How to acheive IF elseif elseif else condition using std mapping functions
How to perform the following mapping using standard graphical functions:
if (a = 1)
result.addValue("3");
else if (a = 2)
result.addValue("6");
else if (a = 5)
result.addvalue("7");
else if (a = 10)
result.addValue("11");
else
result.addValue(a);
can this requirement be acheived without using a UDF?
Regards
bhaskerUDF is better way to get this done.
you try like this using Standard function:
Const 3 /THEN
(A equals 1) IF (output of ifThenElse) ->TragetFiled
\ELSE
/THEN /(output of IfThenElse input to else of first If)
IF /
\ELSE
Like wise for other conditions....
In else part of ifThenElse, give the output of second ifThenElse. here in ths case you need four ifThenElse.
CodeGenerated:
/ns0:MT_/targetFIELD = iF(const([value=3]), stringEquals(/ns0:MT_XML_OB/A=, const([value=1])),
iF(const([value=6]), stringEquals(/ns0:MT_XML_OB/A=, const([value=2])),
iF(const([value=7]), stringEquals(/ns0:MT_XML_OB/A=, const([value=5])),
iF(const([value=11]), stringEquals(/ns0:MT_XML_OB/A=, const[value=10])), /ns0:MT_XML_OB/A=))))
Ritu
Edited by: Ritu Sinha on Apr 13, 2009 2:48 PM -
I am getting an else if error, and I have no clue why. Can somebody help me out? Thanks in advance!
PrimaryColors.java:71: 'else' without 'if'
else if(buttonString.equals("Blue"));
PrimaryColors.java:73: 'else' without 'if'
else if(buttonString.equals("Red"));
PrimaryColors.java:75: 'else' without 'if'
else
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.FlowLayout;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class PrimaryColors extends JFrame implements ActionListener
public static final int WIDTH = 300;
public static final int HEIGHT = 200;
private JPanel yellowPanel;
private JPanel bluePanel;
private JPanel redPanel;
public PrimaryColors()
super("Primary Colors");
setSize(WIDTH, HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
JPanel biggerPanel = new JPanel();
biggerPanel.setLayout(new GridLayout(3, 1));
yellowPanel = new JPanel();
yellowPanel.setBackground(Color.BLACK);
biggerPanel.add(yellowPanel);
bluePanel = new JPanel();
bluePanel.setBackground(Color.BLACK);
biggerPanel.add(bluePanel);
redPanel = new JPanel();
redPanel.setBackground(Color.BLACK);
biggerPanel.add(redPanel);
add(biggerPanel, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel();
buttonPanel.setBackground(Color.BLACK);
buttonPanel.setLayout(new FlowLayout());
JButton yellowButton = new JButton("Yellow");
yellowButton.setBackground(Color.YELLOW);
yellowButton.addActionListener(this);
buttonPanel.add(yellowButton);
JButton blueButton = new JButton("Blue");
blueButton.setBackground(Color.BLUE);
blueButton.addActionListener(this);
buttonPanel.add(blueButton);
JButton redButton = new JButton("Red");
redButton.setBackground(Color.RED);
redButton.addActionListener(this);
buttonPanel.add(redButton);
add(buttonPanel, BorderLayout.WEST);
public void actionPerformed(ActionEvent e)
String buttonString = e.getActionCommand();
if(buttonString.equals("Yellow"));
yellowPanel.setBackground(Color.YELLOW);
else if(buttonString.equals("Blue"));
bluePanel.setBackground(Color.BLUE);
else if(buttonString.equals("Red"));
redPanel.setBackground(Color.RED);
else
System.out.println("Unexpected error");
public static void main(String[] args)
PrimaryColors gui = new PrimaryColors();
gui.setVisible(true);
}Get into the habit of always using braces around if's and loops. Consider the following.
if(condition)
firstLine;
else
anotherLine;Then later you need to change to code.
if(condition)
firstLine;
secondLine; //always executed
else // error else without if
anotherLine;By not using braces in the first place can lead to errors if you forget to include then when the code changes. -
Hi.. i m tuning my Oracle Database, for that i need to install Statspack package, when i compiled package... it returned following error.
Warning: Package Body created with compilation errors.
SQL> show error
Errors for PACKAGE BODY STATSPACK:
LINE/COL ERROR
2045/3 PLS-00201: identifier 'SYS.DBMS_SHARED_POOL' must be declared
2045/3 PL/SQL: Statement ignored
HOw to solve above error..Please check the following Package, and do help me.
Note: I m connected perfstat user, no as SYS user.
create or replace package body STATSPACK as
/* Define package variables.
Variables prefixed with p_ are package variables.
p_snap_id integer; /* snapshot id */
p_instance_number number; /* instance number */
p_instance_name varchar2(16); /* instance name */
p_startup_time date; /* instance startup time */
p_parallel varchar2(3); /* parallel server */
p_version varchar2(17); /* Oracle release */
p_dbid number; /* database id */
p_host_name varchar2(64); /* host instance is on */
p_name varchar2(9); /* database name */
p_new_sga integer; /* Instance bounced since last snap? */
tmp_int integer; /* initialise defaults */
p_def_snap_level number default 5; /* default snapshot lvl */
p_def_session_id number default 0; /* default session id */
p_def_ucomment varchar2(160) default null;
p_def_pin_statspack varchar2(10) default 'TRUE';
p_def_last_modified date default SYSDATE;
/* Below are the default threshold (_th) values for choosing SQL statements
to store in the stats$sqlsummary table - these statements will typically
be the statements using the most resources.
p_def_num_sql number default 50; /* Num. SQL statements */
p_def_executions_th number default 100; /* Num. executions */
p_def_parse_calls_th number default 1000; /* Num. parse calls */
p_def_disk_reads_th number default 1000; /* Num. disk reads */
p_def_buffer_gets_th number default 10000; /* Num. buf gets */
p_def_sharable_mem_th number default 1048576; /* Sharable memory */
p_def_version_count_th number default 20; /* Child Cursors */
p_def_all_init varchar2(10) default 'FALSE';
cursor get_instance is
select instance_number, instance_name
, startup_time, parallel, version
, host_name
from v$instance;
cursor get_db is
select dbid, name
from v$database;
procedure SNAP
(i_snap_level in number default null
,i_session_id in number default null
,i_ucomment in varchar2 default null
,i_num_sql in number default null
,i_executions_th in number default null
,i_parse_calls_th in number default null
,i_disk_reads_th in number default null
,i_buffer_gets_th in number default null
,i_sharable_mem_th in number default null
,i_version_count_th in number default null
,i_all_init in varchar2 default null
,i_pin_statspack in varchar2 default null
,i_modify_parameter in varchar2 default 'FALSE'
is
/* Takes a snapshot by calling the SNAP function, and discards
the snapshot id. This is useful when automating taking
snapshots from dbms_job
l_snap_id number;
begin
l_snap_id := statspack.snap ( i_snap_level, i_session_id, i_ucomment
, i_num_sql
, i_executions_th
, i_parse_calls_th
, i_disk_reads_th
, i_buffer_gets_th
, i_sharable_mem_th
, i_version_count_th
, i_all_init
, i_pin_statspack
, i_modify_parameter);
end SNAP;
procedure MODIFY_STATSPACK_PARAMETER
( i_dbid in number default null
, i_instance_number in number default null
, i_snap_level in number default null
, i_session_id in number default null
, i_ucomment in varchar2 default null
, i_num_sql in number default null
, i_executions_th in number default null
, i_parse_calls_th in number default null
, i_disk_reads_th in number default null
, i_buffer_gets_th in number default null
, i_sharable_mem_th in number default null
, i_version_count_th in number default null
, i_all_init in varchar2 default null
, i_pin_statspack in varchar2 default null
, i_modify_parameter in varchar2 default 'TRUE'
is
/* Calls QAM with the modify flag, and discards the
output variables
l_snap_level number;
l_session_id number;
l_ucomment varchar2(160);
l_num_sql number;
l_executions_th number;
l_parse_calls_th number;
l_disk_reads_th number;
l_buffer_gets_th number;
l_sharable_mem_th number;
l_version_count_th number;
l_all_init varchar2(5);
l_pin_statspack varchar2(10);
begin
statspack.qam_statspack_parameter( i_dbid
, i_instance_number
, i_snap_level
, i_session_id
, i_ucomment
, i_num_sql
, i_executions_th
, i_parse_calls_th
, i_disk_reads_th
, i_buffer_gets_th
, i_sharable_mem_th
, i_version_count_th
, i_all_init
, i_pin_statspack
, 'TRUE'
, l_snap_level
, l_session_id
, l_ucomment
, l_num_sql
, l_executions_th
, l_parse_calls_th
, l_disk_reads_th
, l_buffer_gets_th
, l_sharable_mem_th
, l_version_count_th
, l_all_init
, l_pin_statspack);
/* As we have explicity been requested to change the parameters,
independently of taking a snapshot, commit
commit;
end MODIFY_STATSPACK_PARAMETER;
procedure QAM_STATSPACK_PARAMETER
( i_dbid in number default null
, i_instance_number in number default null
, i_snap_level in number default null
, i_session_id in number default null
, i_ucomment in varchar2 default null
, i_num_sql in number default null
, i_executions_th in number default null
, i_parse_calls_th in number default null
, i_disk_reads_th in number default null
, i_buffer_gets_th in number default null
, i_sharable_mem_th in number default null
, i_version_count_th in number default null
, i_all_init in varchar2 default null
, i_pin_statspack in varchar2 default null
, i_modify_parameter in varchar2 default 'FALSE'
, o_snap_level out number
, o_session_id out number
, o_ucomment out varchar2
, o_num_sql out number
, o_executions_th out number
, o_parse_calls_th out number
, o_disk_reads_th out number
, o_buffer_gets_th out number
, o_sharable_mem_th out number
, o_version_count_th out number
, o_all_init out varchar2
, o_pin_statspack out varchar2
is
/* Query And Modify statspack parameter procedure, allows query
and/or user modification of the statistics collection parameters
for an instance. If there are no pre-existing parameters for
an instance, insert the Oracle defaults.
l_instance_number number;
l_dbid number;
ui_all_init varchar2(5);
l_params_exist varchar2(1);
begin
if ((i_dbid is null ) or (i_instance_number is null)) then
l_dbid := p_dbid;
l_instance_number := p_instance_number;
else
l_dbid := i_dbid;
l_instance_number := i_instance_number;
end if;
/* Upper case any input vars which are inserted */
ui_all_init := upper(i_all_init);
if ( (i_modify_parameter is null)
or (upper(i_modify_parameter) = 'FALSE') ) then
/* Query values, if none exist, insert the defaults tempered
with variables supplied */
begin
select nvl(i_session_id, session_id)
, nvl(i_snap_level, snap_level)
, nvl(i_ucomment, ucomment)
, nvl(i_num_sql, num_sql)
, nvl(i_executions_th, executions_th)
, nvl(i_parse_calls_th, parse_calls_th)
, nvl(i_disk_reads_th, disk_reads_th)
, nvl(i_buffer_gets_th, buffer_gets_th)
, nvl(i_sharable_mem_th, sharable_mem_th)
, nvl(i_version_count_th, version_count_th)
, nvl(ui_all_init, all_init)
, nvl(i_pin_statspack, pin_statspack)
into o_session_id
, o_snap_level
, o_ucomment
, o_num_sql
, o_executions_th
, o_parse_calls_th
, o_disk_reads_th
, o_buffer_gets_th
, o_sharable_mem_th
, o_version_count_th
, o_all_init
, o_pin_statspack
from stats$statspack_parameter
where instance_number = l_instance_number
and dbid = l_dbid;
exception
when NO_DATA_FOUND then
insert into stats$statspack_parameter
( dbid
, instance_number
, session_id
, snap_level
, ucomment
, num_sql
, executions_th
, parse_calls_th
, disk_reads_th
, buffer_gets_th
, sharable_mem_th
, version_count_th
, all_init
, pin_statspack
, last_modified
values
( l_dbid
, l_instance_number
, p_def_session_id
, p_def_snap_level
, p_def_ucomment
, p_def_num_sql
, p_def_executions_th
, p_def_parse_calls_th
, p_def_disk_reads_th
, p_def_buffer_gets_th
, p_def_sharable_mem_th
, p_def_version_count_th
, p_def_all_init
, p_def_pin_statspack
, SYSDATE
returning nvl(i_session_id, p_def_session_id)
, nvl(i_snap_level, p_def_snap_level)
, nvl(i_ucomment, p_def_ucomment)
, nvl(i_num_sql, p_def_num_sql)
, nvl(i_executions_th, p_def_executions_th)
, nvl(i_parse_calls_th, p_def_parse_calls_th)
, nvl(i_disk_reads_th, p_def_disk_reads_th)
, nvl(i_buffer_gets_th, p_def_buffer_gets_th)
, nvl(i_sharable_mem_th, p_def_sharable_mem_th)
, nvl(i_version_count_th, p_def_version_count_th)
, nvl(ui_all_init, p_def_all_init)
, nvl(i_pin_statspack, p_def_pin_statspack)
into o_session_id
, o_snap_level
, o_ucomment
, o_num_sql
, o_executions_th
, o_parse_calls_th
, o_disk_reads_th
, o_buffer_gets_th
, o_sharable_mem_th
, o_version_count_th
, o_all_init
, o_pin_statspack;
end; /* don't modify parameter values */
elsif upper(i_modify_parameter) = 'TRUE' then
/* modify values, if none exist, insert the defaults tempered
with the variables supplied */
begin
update stats$statspack_parameter
set session_id = nvl(i_session_id, session_id)
, snap_level = nvl(i_snap_level, snap_level)
, ucomment = nvl(i_ucomment, ucomment)
, num_sql = nvl(i_num_sql, num_sql)
, executions_th = nvl(i_executions_th, executions_th)
, parse_calls_th = nvl(i_parse_calls_th, parse_calls_th)
, disk_reads_th = nvl(i_disk_reads_th, disk_reads_th)
, buffer_gets_th = nvl(i_buffer_gets_th, buffer_gets_th)
, sharable_mem_th = nvl(i_sharable_mem_th, sharable_mem_th)
, version_count_th = nvl(i_version_count_th, version_count_th)
, all_init = nvl(ui_all_init, all_init)
, pin_statspack = nvl(i_pin_statspack, pin_statspack)
where instance_number = l_instance_number
and dbid = l_dbid
returning session_id
, snap_level
, ucomment
, num_sql
, executions_th
, parse_calls_th
, disk_reads_th
, buffer_gets_th
, sharable_mem_th
, version_count_th
, all_init
, pin_statspack
into o_session_id
, o_snap_level
, o_ucomment
, o_num_sql
, o_executions_th
, o_parse_calls_th
, o_disk_reads_th
, o_buffer_gets_th
, o_sharable_mem_th
, o_version_count_th
, o_all_init
, o_pin_statspack;
if SQL%ROWCOUNT = 0 then
insert into stats$statspack_parameter
( dbid
, instance_number
, session_id
, snap_level
, ucomment
, num_sql
, executions_th
, parse_calls_th
, disk_reads_th
, buffer_gets_th
, sharable_mem_th
, version_count_th
, all_init
, pin_statspack
, last_modified
values
( l_dbid
, l_instance_number
, nvl(i_session_id, p_def_session_id)
, nvl(i_snap_level, p_def_snap_level)
, nvl(i_ucomment, p_def_ucomment)
, nvl(i_num_sql, p_def_num_sql)
, nvl(i_executions_th, p_def_executions_th)
, nvl(i_parse_calls_th, p_def_parse_calls_th)
, nvl(i_disk_reads_th, p_def_disk_reads_th)
, nvl(i_buffer_gets_th, p_def_buffer_gets_th)
, nvl(i_sharable_mem_th, p_def_sharable_mem_th)
, nvl(i_version_count_th, p_def_version_count_th)
, nvl(ui_all_init, p_def_all_init)
, nvl(i_pin_statspack, p_def_pin_statspack)
, SYSDATE
returning session_id
, snap_level
, ucomment
, num_sql
, executions_th
, parse_calls_th
, disk_reads_th
, buffer_gets_th
, sharable_mem_th
, version_count_th
, all_init
, pin_statspack
into o_session_id
, o_snap_level
, o_ucomment
, o_num_sql
, o_executions_th
, o_parse_calls_th
, o_disk_reads_th
, o_buffer_gets_th
, o_sharable_mem_th
, o_version_count_th
, o_all_init
, o_pin_statspack;
end if;
end; /* modify values */
else
/* error */
raise_application_error
(-20100,'QAM_STATSPACK_PARAMETER i_modify_parameter value is invalid');
end if; /* modify */
end QAM_STATSPACK_PARAMETER;
procedure STAT_CHANGES
/* Returns a set of differences of the values from corresponding pairs
of rows in STATS$SYSSTAT, STATS$LIBRARYCACHE and STATS$WAITSTAT,
based on the begin and end (bid, eid) snapshot id's specified.
This procedure is the only call to STATSPACK made by the statsrep
report.
Modified to include multi-db support.
( bid IN number
, eid IN number
, db_ident IN number
, inst_num IN number
, parallel IN varchar2
, lhtr OUT number, bfwt OUT number
, tran OUT number, chng OUT number
, ucal OUT number, urol OUT number
, rsiz OUT number
, phyr OUT number, phyrd OUT number
, phyrdl OUT number
, phyw OUT number, ucom OUT number
, prse OUT number, hprse OUT number
, recr OUT number, gets OUT number
, rlsr OUT number, rent OUT number
, srtm OUT number, srtd OUT number
, srtr OUT number, strn OUT number
, lhr OUT number, bc OUT varchar2
, sp OUT varchar2, lb OUT varchar2
, bs OUT varchar2, twt OUT number
, logc OUT number, prscpu OUT number
, tcpu OUT number, exe OUT number
, prsela OUT number
, bspm OUT number, espm OUT number
, bfrm OUT number, efrm OUT number
, blog OUT number, elog OUT number
, bocur OUT number, eocur OUT number
, dmsd OUT number, dmfc OUT number -- begin OPS
, dfcms OUT number, dfcmr OUT number
, dmsi OUT number, dmrv OUT number
, dynal OUT number, dynares OUT number
, pmrv OUT number, pmpt OUT number
, npmrv OUT number, npmpt OUT number
, scma OUT number, scml OUT number
, pinc OUT number, picrnc OUT number
, picc OUT number, picrcc OUT number
, pbc OUT number, pbcrc OUT number
, pcba OUT number, pccrba OUT number
, pcrbpi OUT number
, dynapres OUT number, dynapshl OUT number
, prcma OUT number, prcml OUT number
, pwrm OUT number, pfpim OUT number
, pwnm OUT number
, dpms OUT number, dnpms OUT number
, glsg OUT number, glag OUT number
, glgt OUT number, glsc OUT number
, glac OUT number, glct OUT number
, glrl OUT number
, gcge OUT number, gcgt OUT number
, gccv OUT number, gcct OUT number
, gccrrv OUT number, gccrrt OUT number
, gccurv OUT number, gccurt OUT number
, gccrsv OUT number
, gccrbt OUT number, gccrft OUT number
, gccrst OUT number, gccusv OUT number
, gccupt OUT number, gccuft OUT number
, gccust OUT number -- end OPS
) is
bval number;
eval number;
l_b_session_id number; /* begin session id */
l_b_serial# number; /* begin serial# */
l_e_session_id number; /* end session id */
l_e_serial# number; /* end serial# */
function LIBRARYCACHE_HITRATIO RETURN number is
/* Returns Library cache hit ratio for the begin and end (bid, eid)
snapshot id's specified
cursor LH (i_snap_id number) is
select sum(pins), sum(pinhits)
from stats$librarycache
where snap_id = i_snap_id
and dbid = db_ident
and instance_number = inst_num;
bpsum number;
bhsum number;
epsum number;
ehsum number;
begin
if not LH%ISOPEN then open LH (bid); end if;
fetch LH into bpsum, bhsum;
if LH%NOTFOUND then
raise_application_error
(-20100,'Missing start value for stats$librarycache');
end if; close LH;
if not LH%ISOPEN then open LH (eid); end if;
fetch LH into epsum, ehsum;
if LH%NOTFOUND then
raise_application_error
(-20100,'Missing end value for stats$librarycache');
end if; close LH;
return (ehsum - bhsum) / (epsum - bpsum);
end LIBRARYCACHE_HITRATIO;
function GET_PARAM (i_name varchar2) RETURN varchar2 is
/* Returns the value for the init.ora parameter for the snapshot
specified.
cursor PARAMETER is
select value
from stats$parameter
where snap_id = eid
and dbid = db_ident
and instance_number = inst_num
and name = i_name;
par_value varchar2(512);
begin
if not PARAMETER%ISOPEN then open PARAMETER; end if;
fetch PARAMETER into par_value;
if PARAMETER%NOTFOUND then
raise_application_error
(-20100,'Missing Init.ora parameter '|| i_name);
end if; close PARAMETER;
return par_value;
end GET_PARAM;
function GET_SYSSTAT (i_name varchar2, i_beid number) RETURN number is
/* Returns the value for the System Statistic for the snapshot
specified.
cursor SYSSTAT is
select value
from stats$sysstat
where snap_id = i_beid
and dbid = db_ident
and instance_number = inst_num
and name = i_name;
stat_value varchar2(512);
begin
if not SYSSTAT%ISOPEN then open SYSSTAT; end if;
fetch SYSSTAT into stat_value;
if SYSSTAT%NOTFOUND then
raise_application_error
(-20100,'Missing System Statistic '|| i_name);
end if; close SYSSTAT;
return stat_value;
end GET_SYSSTAT;
function BUFFER_WAITS RETURN number is
/* Returns the total number of waits for all buffers in the interval
specified by the begin and end snapshot id's (bid, eid)
cursor BW (i_snap_id number) is
select sum(wait_count)
from stats$waitstat
where snap_id = i_snap_id
and dbid = db_ident
and instance_number = inst_num;
bbwsum number; ebwsum number;
begin
if not BW%ISOPEN then open BW (bid); end if;
fetch BW into bbwsum;
if BW%NOTFOUND then
raise_application_error
(-20100,'Missing start value for stats$waitstat');
end if; close BW;
if not BW%ISOPEN then open BW (eid); end if;
fetch BW into ebwsum;
if BW%NOTFOUND then
raise_application_error
(-20100,'Missing end value for stats$waitstat');
end if; close BW;
return ebwsum - bbwsum;
end BUFFER_WAITS;
function TOTAL_EVENT_TIME RETURN number is
/* Returns the total amount of time waited for events for
the interval specified by the begin and end snapshot id's
(bid, eid) by foreground processes. This excludes idle
wait events.
cursor WAITS (i_snap_id number) is
select sum(time_waited_micro)
from stats$system_event
where snap_id = i_snap_id
and dbid = db_ident
and instance_number = inst_num
and event not in (select event from stats$idle_event);
bwaittime number;
ewaittime number;
begin
if not WAITS%ISOPEN then open WAITS (bid); end if;
fetch WAITS into bwaittime;
if WAITS%NOTFOUND then
raise_application_error
(-20100,'Missing start value for stats$system_event');
end if; close WAITS;
if not WAITS%ISOPEN then open WAITS (eid); end if;
fetch WAITS into ewaittime;
if WAITS%NOTFOUND then
raise_application_error
(-20100,'Missing end value for stats$system_event');
end if; close WAITS;
return ewaittime - bwaittime;
end TOTAL_EVENT_TIME;
function LATCH_HITRATIO return NUMBER is
/* Returns the latch hit ratio specified by the begin and
end snapshot id's (bid, eid)
cursor GETS_MISSES (i_snap_id number) is
select sum(gets), sum(misses)
from stats$latch
where snap_id = i_snap_id
and dbid = db_ident
and instance_number = inst_num;
blget number; -- beginning latch gets
blmis number; -- beginning latch misses
elget number; -- end latch gets
elmis number; -- end latch misses
begin
if not GETS_MISSES%ISOPEN then open GETS_MISSES (bid); end if;
fetch GETS_MISSES into blget, blmis;
if GETS_MISSES%NOTFOUND then
raise_application_error
(-20100,'Missing start value for STATS$LATCH gets and misses');
end if; close GETS_MISSES;
if not GETS_MISSES%ISOPEN then open GETS_MISSES (eid); end if;
fetch GETS_MISSES into elget, elmis;
if GETS_MISSES%NOTFOUND then
raise_application_error
(-20100,'Missing end value for STATS$LATCH gets and misses');
end if; close GETS_MISSES;
return ( ( elmis - blmis ) / ( elget - blget ) );
end LATCH_HITRATIO;
function SGASTAT (i_name varchar2, i_beid number) RETURN number is
/* Returns the bytes used by i_name in the shared pool
for the begin or end snapshot (bid, eid) specified
cursor bytes_used is
select bytes
from stats$sgastat
where snap_id = i_beid
and dbid = db_ident
and instance_number = inst_num
and pool in ('shared pool', 'all pools')
and name = i_name;
total_bytes number;
begin
if i_name = 'total_shared_pool' then
select sum(bytes)
into total_bytes
from stats$sgastat
where snap_id = i_beid
and dbid = db_ident
and instance_number = inst_num
and pool in ('shared pool','all pools');
else
open bytes_used; fetch bytes_used into total_bytes;
if bytes_used%notfound then
raise_application_error
(-20100,'Missing value for SGASTAT: '||i_name);
end if;
close bytes_used;
end if;
return total_bytes;
end SGASTAT;
function SYSDIF (i_name varchar2) RETURN number is
/* Returns the difference between statistics for the statistic
name specified for the interval between the begin and end
snapshot id's (bid, eid)
cursor SY (i_snap_id number) is
select value
from stats$sysstat
where snap_id = i_snap_id
and dbid = db_ident
and instance_number = inst_num
and name = i_name;
begin
/* Get start value */
open SY (bid); fetch SY into bval;
if SY%notfound then
raise_application_error
(-20100,'Missing start value for statistic: '||i_name);
end if; close SY;
/* Get end value */
open SY (eid); fetch SY into eval;
if SY%notfound then
raise_application_error
(-20100,'Missing end value for statistic: '||i_name);
end if; close SY;
/* Return difference */
return eval - bval;
end SYSDIF;
function SESDIF (st_name varchar2) RETURN number is
/* Returns the difference between statistics values for the
statistic name specified for the interval between the begin and end
snapshot id's (bid, eid), for the session monitored for that
snapshot
cursor SE (i_snap_id number) is
select ses.value
from stats$sysstat sys
, stats$sesstat ses
where sys.snap_id = i_snap_id
and ses.snap_id = i_snap_id
and ses.dbid = db_ident
and sys.dbid = db_ident
and ses.instance_number = inst_num
and sys.instance_number = inst_num
and ses.statistic# = sys.statistic#
and sys.name = st_name;
begin
/* Get start value */
open SE (bid); fetch SE into bval;
if SE%notfound then
eval :=0;
end if; close SE;
/* Get end value */
open SE (eid); fetch SE into eval;
if SE%notfound then
eval :=0;
end if; close SE;
/* Return difference */
return eval - bval;
end SESDIF;
function DLMDIF (i_name varchar2) RETURN number is
/* Returns the difference between statistics for the statistic
name specified for the interval between the begin and end
snapshot id's (bid, eid)
cursor DLM (i_snap_id number) is
select value
from stats$dlm_misc
where snap_id = i_snap_id
and dbid = db_ident
and instance_number = inst_num
and name = i_name;
begin
/* Get start value */
open DLM (bid); fetch DLM into bval;
if DLM%notfound then
raise_application_error
(-20100,'Missing start value for statistic: '||i_name);
end if; close DLM;
/* Get end value */
open DLM (eid); fetch DLM into eval;
if DLM%notfound then
raise_application_error
(-20100,'Missing end value for statistic: '||i_name);
end if; close DLM;
/* Return difference */
return eval - bval;
end DLMDIF;
begin /* main procedure body of STAT_CHANGES */
lhtr := LIBRARYCACHE_HITRATIO;
bfwt := BUFFER_WAITS;
lhr := LATCH_HITRATIO;
chng := SYSDIF('db block changes');
ucal := SYSDIF('user calls');
urol := SYSDIF('user rollbacks');
ucom := SYSDIF('user commits');
tran := ucom + urol;
rsiz := SYSDIF('redo size');
phyr := SYSDIF('physical reads');
phyrd := SYSDIF('physical reads direct');
phyrdl := SYSDIF('physical reads direct (lob)');
phyw := SYSDIF('physical writes');
hprse := SYSDIF('parse count (hard)');
prse := SYSDIF('parse count (total)');
gets := SYSDIF('session logical reads');
recr := SYSDIF('recursive calls');
rlsr := SYSDIF('redo log space requests');
rent := SYSDIF('redo entries');
srtm := SYSDIF('sorts (memory)');
srtd := SYSDIF('sorts (disk)');
srtr := SYSDIF('sorts (rows)');
logc := SYSDIF('logons cumulative');
prscpu := SYSDIF('parse time cpu');
prsela := SYSDIF('parse time elapsed');
tcpu := SYSDIF('CPU used by this session');
exe := SYSDIF('execute count');
bs := GET_PARAM('db_block_size');
bc := GET_PARAM('db_block_buffers') * bs;
if bc = 0 then
bc := GET_PARAM('db_cache_size')
+ GET_PARAM('db_keep_cache_size')
+ GET_PARAM('db_recycle_cache_size')
+ GET_PARAM('db_2k_cache_size')
+ GET_PARAM('db_4k_cache_size')
+ GET_PARAM('db_8k_cache_size')
+ GET_PARAM('db_16k_cache_size')
+ GET_PARAM('db_32k_cache_size');
end if;
sp := GET_PARAM('shared_pool_size');
lb := GET_PARAM('log_buffer');
twt := TOTAL_EVENT_TIME; -- total wait time for all non-idle events
bspm := SGASTAT('total_shared_pool', bid);
espm := SGASTAT('total_shared_pool', eid);
bfrm := SGASTAT('free memory', bid);
efrm := SGASTAT('free memory', eid);
blog := GET_SYSSTAT('logons current', bid);
elog := GET_SYSSTAT('logons current', eid);
bocur := GET_SYSSTAT('opened cursors current', bid);
eocur := GET_SYSSTAT('opened cursors current', eid);
/* Do we want to report on cluster-specific statistics? Check
in procedure variable "parallel".
if parallel = 'YES' then
dmsd := DLMDIF('messages sent directly');
dmfc := DLMDIF('messages flow controlled');
dmsi := DLMDIF('messages sent indirectly');
dmrv := DLMDIF('messages received');
dfcms := DLMDIF('flow control messages sent');
dfcmr := DLMDIF('flow control messages received');
dynal := DLMDIF('dynamically allocated enqueues');
dynares := DLMDIF('dynamically allocated resources');
pmrv := DLMDIF('gcs msgs received');
pmpt := DLMDIF('gcs msgs process time(ms)');
npmrv := DLMDIF('ges msgs received');
npmpt := DLMDIF('ges msgs process time(ms)');
scma := DLMDIF('gcs side channel msgs actual');
scml := DLMDIF('gcs side channel msgs logical');
pinc := DLMDIF('gcs immediate (null) converts');
picrnc := DLMDIF('gcs immediate cr (null) converts');
picc := DLMDIF('gcs immediate (compatible) converts');
picrcc := DLMDIF('gcs immediate cr (compatible) converts');
pbc := DLMDIF('gcs blocked converts');
pbcrc := DLMDIF('gcs blocked cr converts');
pcba := DLMDIF('gcs compatible basts');
pccrba := DLMDIF('gcs compatible cr basts');
pcrbpi := DLMDIF('gcs cr basts to PIs');
dynapres := DLMDIF('dynamically allocated gcs resources');
dynapshl := DLMDIF('dynamically allocated gcs shadows');
prcma := DLMDIF('gcs recovery claim msgs actual');
prcml := DLMDIF('gcs recovery claim msgs logical');
pwrm := DLMDIF('gcs write request msgs');
pfpim := DLMDIF('gcs flush pi msgs');
pwnm := DLMDIF('gcs write notification msgs');
dpms := SYSDIF('gcs messages sent');
dnpms := SYSDIF('ges messages sent');
glsg := SYSDIF('global lock sync gets');
glag := SYSDIF('global lock async gets');
glgt := SYSDIF('global lock get time');
glsc := SYSDIF('global lock sync converts');
glac := SYSDIF('global lock async converts');
glct := SYSDIF('global lock convert time');
glrl := SYSDIF('global lock releases');
gcge := SYSDIF('global cache gets');
gcgt := SYSDIF('global cache get time');
gccv := SYSDIF('global cache converts');
gcct := SYSDIF('global cache convert time');
gccrrv := SYSDIF('global cache cr blocks received');
gccrrt := SYSDIF('global cache cr block receive time');
gccurv := SYSDIF('global cache current blocks received');
gccurt := SYSDIF('global cache current block receive time');
gccrsv := SYSDIF('global cache cr blocks served');
gccrbt := SYSDIF('global cache cr block build time');
gccrft := SYSDIF('global cache cr block flush time');
gccrst := SYSDIF('global cache cr block send time');
gccusv := SYSDIF('global cache current blocks served');
gccupt := SYSDIF('global cache current block pin time');
gccuft := SYSDIF('global cache current block flush time');
gccust := SYSDIF('global cache current block send time');
end if;
/* Determine if we want to report on session-specific statistics.
Check that the session is the same one for both snapshots.
select session_id
, serial#
into l_b_session_id
, l_b_serial#
from stats$snapshot
where snap_id = bid
and dbid = db_ident
and instance_number = inst_num;
select session_id
, serial#
into l_e_session_id
, l_e_serial#
from stats$snapshot
where snap_id = eid
and dbid = db_ident
and instance_number = inst_num;
if ( (l_b_session_id = l_e_session_id)
and (l_b_serial# = l_e_serial#)
and (l_b_session_id != 0) ) then
/* we have a valid comparison - it is the
same session - get number of tx performed
by this session */
strn := SESDIF('user rollbacks') + SESDIF('user commits');
if strn = 0 then
/* No new transactions */
strn := 1;
end if;
else
/* No valid comparison can be made */
strn :=1;
end if;
end STAT_CHANGES;
function SNAP
(i_snap_level in number default null
,i_session_id in number default null
,i_ucomment in varchar2 default null
,i_num_sql in number default null
,i_executions_th in number default null
,i_parse_calls_th in number default null
,i_disk_reads_th in number default null
,i_buffer_gets_th in number default null
,i_sharable_mem_th in number default null
,i_version_count_th in number default null
,i_all_init in varchar2 default null
,i_pin_statspack in varchar2 default null
,i_modify_parameter in varchar2 default 'FALSE'
RETURN integer IS
/* This function performs a snapshot of the v$ views into the
stats$ tables, and returns the snapshot id.
If parameters are passed, these are the values used, otherwise
the values stored in the stats$statspack_parameter table are used.
l_snap_id integer;
l_snap_level number;
l_session_id number;
l_serial# number;
l_ucomment varchar2(160);
l_num_sql number;
l_executions_th number;
l_parse_calls_th number;
l_disk_reads_th number;
l_buffer_gets_th number;
l_sharable_mem_th number;
l_version_count_th number;
l_all_init varchar2(5);
l_pin_statspack varchar2(10);
l_sql_stmt varchar2(3000);
l_slarti varchar2(20);
l_threshold number;
l_total_sql number := 0;
l_total_sql_mem number := 0;
l_single_use_sql number := 0;
l_single_use_sql_mem number := 0;
l_text_subset varchar2(31);
l_sharable_mem number;
l_version_count number;
l_sorts number;
l_module varchar2(64);
l_loaded_versions number;
l_executions number;
l_loads number;
l_invalidations number;
l_parse_calls number;
l_disk_reads number;
l_buffer_gets number;
l_rows_processed number;
l_address raw(8);
l_hash_value number;
l_version_count number;
l_max_begin_time date;
cursor GETSERIAL is
select serial#
from v$session
where sid = l_session_id;
PROCEDURE snap_sql IS
begin
/* Gather summary statistics */
insert into stats$sql_statistics
( snap_id
, dbid
, instance_number
, total_sql
, total_sql_mem
, single_use_sql
, single_use_sql_mem
select l_snap_id
, p_dbid
, p_instance_number
, count(1)
, sum(sharable_mem)
, sum(decode(executions, 1, 1, 0))
, sum(decode(executions, 1, sharable_mem, 0))
from stats$v$sqlxs
where is_obsolete = 'N';
/* Gather SQL statements which exceed any threshold,
excluding obsolete parent cursors
insert into stats$sql_summary
( snap_id
, dbid
, instance_number
, text_subset
, sharable_mem
, sorts
, module
, loaded_versions
, executions
, loads
, invalidations
, parse_calls
, disk_reads
, buffer_gets
, rows_processed
, command_type
, address
, hash_value
, version_count
, cpu_time
, elapsed_time
, outline_sid
, outline_category
select l_snap_id
, p_dbid
, p_instance_number
, substr(sql_text,1,31)
, sharable_mem
, sorts
, module
, loaded_versions
, executions
, loads
, invalidations
, parse_calls
, disk_reads
, buffer_gets
, rows_processed
, command_type
, address
, hash_value
, version_count
, cpu_time
, elapsed_time
, outline_sid
, outline_category
from stats$v$sqlxs
where is_obsolete = 'N'
and ( buffer_gets > l_buffer_gets_th
or disk_reads > l_disk_reads_th
or parse_calls > l_parse_calls_th
or executions > l_executions_th
or sharable_mem > l_sharable_mem_th
or version_count > l_version_count_th
/* Insert the SQL Text for hash_values captured in the snapshot
into stats$sqltext if it's not already there. Identify SQL which
execeeded the threshold by querying stats$sql_summary for this
snapid and database instance
insert into stats$sqltext
( hash_value
, text_subset
, piece
, sql_text
, address
, command_type
, last_snap_id
select st1.hash_value
, ss.text_subset
, st1.piece
, st1.sql_text
, st1.address
, st1.command_type
, ss.snap_id
from v$sqltext st1
, stats$sql_summary ss
where ss.snap_id = l_snap_id
and ss.dbid = p_dbid
and ss.instance_number = p_instance_number
and st1.hash_value = ss.hash_value
and st1.address = ss.address
and not exists (select 1
from stats$sqltext st2
where st2.hash_value = ss.hash_value
and st2.text_subset = ss.text_subset
IF l_snap_level >= 6 THEN
/* Identify SQL which execeeded the threshold by querying
stats$sql_summary for this snapid and database instance.
Capture the plans which were used for the high-load SQL if
don't already have this data.
Omit capturing plan usage information for cursors which
have a zero plan hash value.
Currently this is captured in a level 6 (or greater)
snapshot, however this may be integrated into level 5
snapshot at a later date.
hl - high load
insert into stats$sql_plan_usage
( hash_value
, text_subset
, plan_hash_value
, cost
, snap_id
, address
, optimizer
select hl.hash_value
, hl.text_subset
, hl.plan_hash_value
, hl.cost
, max(hl.snap_id)
, max(hl.address)
, max(hl.optimizer)
from (select /*+ ordered use_nl(sq) index(sq) */
ss.hash_value
, ss.text_subset
, sq.plan_hash_value
, nvl(sq.optimizer_cost,-9) cost
, ss.snap_id snap_id
, ss.address
, sq.optimizer_mode optimizer
from stats$sql_summary ss
, v$sql sq
where ss.snap_id = l_snap_id
and ss.dbid = p_dbid
and ss.instance_number = p_instance_number
and sq.hash_value = ss.hash_value
and sq.address = ss.address
and sq.plan_hash_value > 0
) hl
where not exists (select /*+ no_unnest */
from stats$sql_plan_usage spu
where spu.hash_value = hl.hash_value
and spu.text_subset = hl.text_subset
and spu.plan_hash_value
= hl.plan_hash_value
and spu.cost = hl.cost
group by hl.hash_value
, hl.text_subset
, hl.plan_hash_value
, hl.cost
, hl.optimizer;
/* For all new hash_value, plan_hash_value, cost combinations
just captured, get the optimizer plans, if we don't already
have them. Note that the plan (and hence the plan hash value)
comprises the access path and the join order (and not
variable factors such as the cardinality).
insert into stats$sql_plan
( plan_hash_value
, id
, operation
, options
, object_node
, object#
, object_owner
, object_name
, optimizer
, parent_id
, depth
, position
, cost
, cardinality
, bytes
, other_tag
, partition_start
, partition_stop
, partition_id
, other
, distribution
, cpu_cost
, io_cost
, temp_space
, snap_id
select /*+ ordered use_nl(s) use_nl(sp.p) */
new_plan.plan_hash_value
, sp.id
, max(sp.operation)
, max(sp.options)
, max(sp.object_node)
, max(sp.object#)
, max(sp.object_owner)
, max(sp.object_name)
, max(sp.optimizer)
, max(sp.parent_id)
, max(sp.depth)
, max(sp.position)
, max(sp.cost)
, max(sp.cardinality)
, max(sp.bytes)
, max(sp.other_tag)
, max(sp.partition_start)
, max(sp.partition_stop)
, max(sp.partition_id)
, max(sp.other)
, max(sp.distribution)
, max(sp.cpu_cost)
, max(sp.io_cost)
, max(sp.temp_space)
, max(new_plan.snap_id)
from (select /*+ index(spu) */
distinct
spu.plan_hash_value
, spu.hash_value
, spu.address
, spu.text_subset
, spu.snap_id
from stats$sql_plan_usage spu
where spu.snap_id = l_snap_id
and not exists (select /*+ nl_aj */ *
from stats$sql_plan ssp
where ssp.plan_hash_value
= spu.plan_hash_value
) new_plan
, v$sql s
, v$sql_plan sp
where sp.hash_value = new_plan.hash_value
and sp.address = new_plan.address
and s.hash_value = new_plan.hash_value
and s.address = new_plan.address
and s.hash_value = sp.hash_value
and s.address = sp.address
and s.child_number = sp.child_number
group by
new_plan.plan_hash_value
, sp.id;
END IF; /* snap level >=6 */
END snap_sql;
begin /* Function SNAP */
/* Get instance parameter defaults from stats$statspack_parameter,
or use supplied parameters.
If all parameters are specified, use them, otherwise get values
from the parameters not specified from stats$statspack_parameter.
statspack.qam_statspack_parameter
( p_dbid
, p_instance_number
, i_snap_level, i_session_id, i_ucomment, i_num_sql
, i_executions_th, i_parse_calls_th
, i_disk_reads_th, i_buffer_gets_th, i_sharable_mem_th
, i_version_count_th, i_all_init
, i_pin_statspack
, i_modify_parameter
, l_snap_level, l_session_id, l_ucomment, l_num_sql
, l_executions_th, l_parse_calls_th
, l_disk_reads_th, l_buffer_gets_th, l_sharable_mem_th
, l_version_count_th, l_all_init
, l_pin_statspack);
/* Generate a snapshot id */
select stats$snapshot_id.nextval
into l_snap_id
from dual
where rownum = 1;
/* Determine the serial# of the session to maintain stats for,
if this was requested.
if l_session_id > 0 then
if not GETSERIAL%ISOPEN then open GETSERIAL; end if;
fetch GETSERIAL into l_serial#;
if GETSERIAL%NOTFOUND then
/* Session has already disappeared - don't gather
statistics for this session in this snapshot */
l_session_id := 0;
l_serial# := 0;
end if; close GETSERIAL;
else
l_serial# := 0;
end if;
/* The instance has been restarted since the last snapshot */
if p_new_sga = 0
then
begin
p_new_sga := 1;
/* Get the instance startup time, and other characteristics */
insert into stats$database_instance
( dbid
, instance_number
, startup_time
, snap_id
, parallel
, version
, db_name
, instance_name
, host_name
select p_dbid
, p_instance_number
, p_startup_time
, l_snap_id
, p_parallel
, p_version
, p_name
, p_instance_name
, p_host_name
from sys.dual;
commit;
end;
end if; /* new SGA */
/* Work out the max undo stat time, used for gathering undo stat data */
select nvl(max(begin_time), to_date('01011900','DDMMYYYY'))
into l_max_begin_time
from stats$undostat
where dbid = p_dbid
and instance_number = p_instance_number;
/* Save the snapshot characteristics */
insert into stats$snapshot
( snap_id, dbid, instance_number
, snap_time, startup_time
, session_id, snap_level, ucomment
, executions_th, parse_calls_th, disk_reads_th
, buffer_gets_th, sharable_mem_th
, version_count_th, serial#, all_init)
values
( l_snap_id, p_dbid, p_instance_number
, SYSDATE, p_startup_time
, l_session_id, l_snap_level, l_ucomment
, l_executions_th, l_parse_calls_th, l_disk_reads_th
, l_buffer_gets_th, l_sharable_mem_th
, l_version_count_th, l_serial#, l_all_init);
/* Begin gathering statistics */
insert into stats$filestatxs
( snap_id
, dbid
, instance_number
, tsname
, filename
, phyrds
, phywrts
, singleblkrds
, readtim
, writetim
, singleblkrdtim
, phyblkrd
, phyblkwrt
, wait_count
, time
select l_snap_id
, p_dbid
, p_instance_number
, tsname
, filename
, phyrds
, phywrts
, singleblkrds
, readtim
, writetim
, singleblkrdtim
, phyblkrd
, phyblkwrt
, wait_count
, time
from stats$v$filestatxs;
insert into stats$tempstatxs
( snap_id
, dbid
, instance_number
, tsname
, filename
, phyrds
, phywrts
, singleblkrds
, readtim
, writetim
, singleblkrdtim
, phyblkrd
, phyblkwrt
, wait_count
, time
select l_snap_id
, p_dbid
, p_instance_number
, tsname
, filename
, phyrds
, phywrts
, singleblkrds
, readtim
, writetim
, singleblkrdtim
, phyblkrd
, phyblkwrt
, wait_count
, time
from stats$v$tempstatxs;
insert into stats$librarycache
( snap_id
, dbid
, instance_number
, namespace
, gets
, gethits
, pins
, pinhits
, reloads
, invalidations
, dlm_lock_requests
, dlm_pin_requests
, dlm_pin_releases
, dlm_invalidation_requests
, dlm_invalidations
select l_snap_id
, p_dbid
, p_instance_number
, namespace
, gets
, gethits
, pins
, pinhits
, reloads
, invalidations
, dlm_lock_requests
, dlm_pin_requests
, dlm_pin_releases
, dlm_invalidation_requests
, dlm_invalidations
from v$librarycache;
insert into stats$buffer_pool_statistics
( snap_id
, dbid
, instance_number
, id
, name
, block_size
, set_msize
, cnum_repl
, cnum_write
, cnum_set
, buf_got
, sum_write
, sum_scan
, free_buffer_wait
, write_complete_wait
, buffer_busy_wait
, free_buffer_inspected
, dirty_buffers_inspected
, db_block_change
, db_block_gets
, consistent_gets
, physical_reads
, physical_writes
select l_snap_id
, p_dbid
, p_instance_number
, id
, name
, block_size
, set_msize
, cnum_repl
, cnum_write
, cnum_set
, buf_got
, sum_write
, sum_scan
, free_buffer_wait
, write_complete_wait
, buffer_busy_wait
, free_buffer_inspected
, dirty_buffers_inspected
, db_block_change
, db_block_gets
, consistent_gets
, physical_reads
, physical_writes
from v$buffer_pool_statistics;
insert into stats$rollstat
( snap_id
, dbid
, instance_number
, usn
, extents
, rssize
, writes
, xacts
, gets
, waits
, optsize
, hwmsize
, shrinks
, wraps
, extends
, aveshrink
, aveactive
select l_snap_id
, p_dbid
, p_instance_number
, usn
, extents
, rssize
, writes
, xacts
, gets
, waits
, optsize
, hwmsize
, shrinks
, wraps
, extends
, aveshrink
, aveactive
from v$rollstat;
insert into stats$rowcache_summary
( snap_id
, dbid
, instance_number
, parameter
, total_usage
, usage
, gets
, getmisses
, scans
, scanmisses
, scancompletes
, modifications
, flushes
, dlm_requests
, dlm_conflicts
, dlm_releases
select l_snap_id
, p_dbid
, p_instance_number
, parameter
, sum("COUNT")
, sum(usage)
, sum(gets)
, sum(getmisses)
, sum(scans)
, sum(scanmisses)
, sum(scancompletes)
, sum(modifications)
, sum(flushes)
, sum(dlm_requests)
, sum(dlm_conflicts)
, sum(dlm_releases)
from v$rowcache
group by l_snap_id, p_dbid, p_instance_number, parameter;
/* Collect parameters every snapshot, to cater for dynamic
parameters changable while instance is running
if l_all_init = 'FALSE' then
insert into stats$parameter
( snap_id
, dbid
, instance_number
, name
, value
, isdefault
, ismodified
select l_snap_id
, p_dbid
, p_instance_number
, name
, value
, isdefault
, ismodified
from v$system_parameter;
else
insert into stats$parameter
( snap_id
, dbid
, instance_number
, name
, value
, isdefault
, ismodified
select l_snap_id
, p_dbid
, p_instance_number
, i.ksppinm
, sv.ksppstvl
, sv.ksppstdf
, decode(bitand(sv.ksppstvf,7),1,'MODIFIED',4,'SYSTEM_MOD','FALSE')
from stats$x$ksppi i
, stats$x$ksppsv sv
where i.indx = sv.indx;
end if;
/* To cater for variable size SGA - insert on each snapshot */
insert into stats$sga
( snap_id
, dbid
, instance_number
, name
, value
select l_snap_id
, p_dbid
, p_instance_number
, name
, value
from v$sga;
/* Get current allocation of memory in the SGA */
insert into stats$sgastat
( snap_id
, dbid
, instance_number
, pool
, name
, bytes
select l_snap_id
, p_dbid
, p_instance_number
, pool
, name
, bytes
from v$sgastat;
insert into stats$system_event
( snap_id
, dbid
, instance_number
, event
, total_waits
, total_timeouts
, time_waited_micro
select l_snap_id
, p_dbid
, p_instance_number
, event
, total_waits
, total_timeouts
, time_waited_micro
from v$system_event;
insert into stats$bg_event_summary
( snap_id
, dbid
, instance_number
, event
, total_waits
, total_timeouts
, time_waited_micro
select l_snap_id
, p_dbid
, p_instance_number
, e.event
, sum(e.total_waits)
, sum(e.total_timeouts)
, sum(e.time_waited_micro)
from v$session_event e
where e.sid in (select s.sid from v$session s where s.type = 'BACKGROUND')
group by l_snap_id, p_dbid, p_instance_number, e.event;
insert into stats$sysstat
( snap_id
, dbid
, instance_number
, statistic#
, name
, value
select l_snap_id
, p_dbid
, p_instance_number
, statistic#
, name
, value
from v$sysstat;
insert into stats$waitstat
( snap_id
, dbid
, instance_number
, class
, wait_count
, time
select l_snap_id
, p_dbid
, p_instance_number
, class
, "COUNT"
, time
from v$waitstat;
insert into stats$enqueue_stat
( snap_id
, dbid
, instance_number
, eq_type
, total_req#
, total_wait#
, succ_req#
, failed_req#
, cum_wait_time
select l_snap_id
, p_dbid
, p_instance_number
, eq_type
, total_req#
, total_wait#
, succ_req#
, failed_req#
, cum_wait_time
from v$enqueue_stat
where total_req# != 0;
insert into stats$latch
( snap_id
, dbid
, instance_number
, name
, latch#
, level#
, gets
, misses
, sleeps
, immediate_gets
, immediate_misses
, spin_gets
, sleep1
, sleep2
, sleep3
, sleep4
, wait_time
select l_snap_id
, p_dbid
, p_instance_number
, name
, latch#
, level#
, gets
, misses
, sleeps
, immediate_gets
, immediate_misses
, spin_gets
, sleep1
, sleep2
, sleep3
, sleep4
, wait_time
from v$latch;
insert into stats$latch_misses_summary
( snap_id
, dbid
, instance_number
, parent_name
, where_in_code
, nwfail_count
, sleep_count
, wtr_slp_count
select l_snap_id
, p_dbid
, p_instance_number
, parent_name
, "WHERE"
, sum(nwfail_count)
, sum(sleep_count)
, sum(wtr_slp_count)
from v$latch_misses
where sleep_count > 0
group by l_snap_id, p_dbid, p_instance_number
, parent_name, "WHERE";
insert into stats$resource_limit
( snap_id
, dbid
, instance_number
, resource_name
, current_utilization
, max_utilization
, initial_allocation
, limit_value
select l_snap_id
, p_dbid
, p_instance_number
, resource_name
, current_utilization
, max_utilization
, initial_allocation
, limit_value
from v$resource_limit
where limit_value != ' UNLIMITED'
and max_utilization > 0;
insert into stats$undostat
( begin_time
, end_time
, dbid
, instance_number
, snap_id
, undotsn
, undoblks
, txncount
, maxquerylen
, maxconcurrency
, unxpstealcnt
, unxpblkrelcnt
, unxpblkreucnt
, expstealcnt
, expblkrelcnt
, expblkreucnt
, ssolderrcnt
, nospaceerrcnt
select begin_time
, end_time
, p_dbid
, p_instance_number
, l_snap_id
, undotsn
, undoblks
, txncount
, maxquerylen
, maxconcurrency
, unxpstealcnt
, unxpblkrelcnt
, unxpblkreucnt
, expstealcnt
, expblkrelcnt
, expblkreucnt
, ssolderrcnt
, nospaceerrcnt
from v$undostat
where begin_time > l_max_begin_time
and begin_time + (1/(24*6)) <= end_time;
insert into stats$db_cache_advice
( snap_id
, dbid
, instance_number
, id
, name
, block_size
, buffers_for_estimate
, advice_status
, size_for_estimate
, estd_physical_read_factor
, estd_physical_reads
select l_snap_id
, p_dbid
, p_instance_number
, id
, name
, block_size
, buffers_for_estimate
, advice_status
, size_for_estimate
, estd_physical_read_factor
, estd_physical_reads
from v$db_cache_advice
where advice_status = 'ON';
insert into stats$pgastat
( snap_id
, dbid
, instance_number
, name
, value
select l_snap_id
, p_dbid
, p_instance_number
, name
, value
from v$pgastat;
insert into stats$instance_recovery
( snap_id
, dbid
, instance_number
, recovery_estimated_ios
, actual_redo_blks
, target_redo_blks
, log_file_size_redo_blks
, log_chkpt_timeout_redo_blks
, log_chkpt_interval_redo_blks
, fast_start_io_target_redo_blks
, target_mttr
, estimated_mttr
, ckpt_block_writes
select l_snap_id
, p_dbid
, p_instance_number
, recovery_estimated_ios
, actual_redo_blks
, target_redo_blks
, log_file_size_redo_blks
, log_chkpt_timeout_redo_blks
, log_chkpt_interval_redo_blks
, fast_start_io_target_redo_blks
, target_mttr
, estimated_mttr
, ckpt_block_writes
from v$instance_recovery;
if p_parallel = 'YES' then
insert into stats$dlm_misc
( snap_id
, dbid
, instance_number
, statistic#
, name
, value
select l_snap_id
, p_dbid
, p_instance_number
, statistic#
, name
, value
from v$dlm_misc;
end if; /* parallel */
/* Begin gathering Extended Statistics */
IF l_snap_level >= 5 THEN
snap_sql;
END IF; /* snap level >=5 */
IF l_snap_level >= 10 THEN
insert into stats$latch_children
( snap_id
, dbid
, instance_number
, latch#
, child#
, gets
, misses
, sleeps
, immediate_gets
, immediate_misses
, spin_gets
, sleep1
, sleep2
, sleep3
, sleep4
, wait_time
select l_snap_id
, p_dbid
, p_instance_number
, latch#
, child#
, gets
, misses
, sleeps
, immediate_gets
, immediate_misses
, spin_gets
, sleep1
, sleep2
, sleep3
, sleep4
, wait_time
from v$latch_children;
insert into stats$latch_parent
( snap_id
, dbid
, instance_number
, latch#
, level#
, gets
, misses
, sleeps
, immediate_gets
, immediate_misses
, spin_gets
, sleep1
, sleep2
, sleep3
, sleep4
, wait_time
select l_snap_id
, p_dbid
, p_instance_number
, latch#
, level#
, gets
, misses
, sleeps
, immediate_gets
, immediate_misses
, spin_gets
, sleep1
, sleep2
, sleep3
, sleep4
, wait_time
from v$latch_parent;
END IF; /* snap level >=10 */
/* Record level session-granular statistics if a specific session
has been requested
if l_session_id > 0
then
insert into stats$sesstat
( snap_id
, dbid
, instance_number
, statistic#
, value
select l_snap_id
, p_dbid
, p_instance_number
, statistic#
, value
from v$sesstat
where sid = l_session_id;
insert into stats$session_event
( snap_id
, dbid
, instance_number
, event
, total_waits
, total_timeouts
, time_waited_micro
, max_wait
select l_snap_id
, p_dbid
, p_instance_number
, event
, total_waits
, total_timeouts
, time_waited_micro
, max_wait
from v$session_event
where sid = l_session_id;
end if;
commit work;
RETURN l_snap_id;
end SNAP; /* Function SNAP */
begin /* STATSPACK body */
/* Query the database id, instance_number, database name, instance
name and startup time for the instance we are working on
/* Get information about the current instance */
open get_instance;
fetch get_instance into
p_instance_number, p_instance_name
, p_startup_time, p_parallel, p_version
, p_host_name;
close get_instance;
/* Select the database info for the db connected to */
open get_db;
fetch get_db into p_dbid, p_name;
close get_db;
/* Keep the package
sys.dbms_shared_pool.keep('PERFSTAT.STATSPACK', 'P');
/* Determine if the instance has been restarted since the previous snapshot
begin
select 1
into p_new_sga
from stats$database_instance
where startup_time = p_startup_time
and dbid = p_dbid
and instance_number = p_instance_number;
exception
when NO_DATA_FOUND then
p_new_sga := 0;
end;
end STATSPACK;
Warning: Package Body created with compilation errors.
SQL> show error
Errors for PACKAGE BODY STATSPACK:
LINE/COL ERROR
2045/3 PLS-00201: identifier 'SYS.DBMS_SHARED_POOL' must be declared
2045/3 PL/SQL: Statement ignoredWhen i compiled the package, it compiled with following error.
Warning: Package Body created with compilation errors.
SQL> show error
Errors for PACKAGE BODY STATSPACK:
LINE/COL ERROR
2045/3 PLS-00201: identifier 'SYS.DBMS_SHARED_POOL' must be declared
2045/3 PL/SQL: Statement ignored
SQL> -
File not found error on some computers running the same program
Dim pList As System.Diagnostics.Process
retval = 0
PTRName = "F:\myprogram.exe"
If My.Computer.FileSystem.FileExists(PTRName) Then
System.Disgnostics.Process.Start(PTRName)
pList = System.Diagnostics.Process.GetProcesses
For each proc As System.Diagnostice.Process in pList
If proc.ProcessName = "myprogram" Then
retval = proc.Id
Exit For
End If
Next
If retval > 0 then
'continue
Else
'error message
End If
End If
PTRName = "F:\myprogram.exe"
If My.Computer.FileSystem.FileExists(PTRName) Then
Retval = Shell(PTRName,4)
If Retval > 0 Then
'Continue
Else
'Error message
End If
End IF
I have created a program which:
opens a file
reads the records and massages the records
writes the records to a new file
Launches a program that uses the resultant file.
The program was written on Windows xp MCE using Visual Studio 10. The resulting program works fine.
I places The executable and the input file onto a flashdrive, and then tested it on other machines.
Two of the machines are both Win 7 Pro 64bit with .Net 4. On one machine it works great. On the other I get a "File not found" error when starting the second process. This is the failing code:
The problem is with the Shell command. When I rewrite it as:
it works on both machines
So my question is: Why does exactly the same code (The same flashdrive was used on both machines) work on one machine and not the other (when both machenes appear to be at the same level)?
In both cases I verify the file exists in the correct place before I try to start it.
Any help would be appreciated.
Thanks in advance
JohnThe use of F is just an example. I use:
OutputPath = My.Application.Info.DirectoryPath 'Where app is run from (root)
'Make sure the path ends in \
If VB.Right(OutputPath, 1) <> "\" Then
OutputPath = OutputPath & "\"
End If
to get the correct information.
Then
PTRName = OutputPath & "myprogram.exe"
BTW "myprogram.exe" is not the correct name it is just an example.
Sorry if this caused confusion
However all of this is not the point. If:
My.Computer.FileSystem.FileExists(PTRName)
is true then the file is in the right place. Therefore:
Retval = Shell(PTRName,4)
must also work. However it does not on some machines.
Is the problem in .Net, VB or VS because it is not in my code.
I have also used a routine similar to you (in VB6) to find a particular volume, but used the volume label. That worked better in my case.
John -
Error while inserting into ms access using jsp
i am using the following code to insert values from textboxes into access database
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(url);
Statement stmt=con.createStatement();
//ResultSet rs = null;
//String sql = ("INSERT INTO co-ords VALUES ('" + nam + "','" + lat + "','" + lon + "','"+ latm +"','"+ lonm +"','"+ latmd +"','"+ lonmd +"','"+ latms +"','"+ lonms +"') ");
String sql = "INSERT INTO co-ords (nam ,lat , lon , latm ,lonm , latmd , lonmd ,latms , lonms) VALUES ('" + nam + "','" + lat + "','" + lon + "','"+ latm +"','"+ lonm +"','"+ latmd +"','"+ lonmd +"','"+ latms +"','"+ lonms +"') ";
out.println(sql);
stmt.executeUpdate(sql);
the output i get is
INSERT INTO co-ords (nam ,lat , lon , latm ,lonm , latmd , lonmd ,latms , lonms) VALUES ('cck','28.656529681148545','77.23440170288086','28','77','39','14','23.508','3.8472') Exception:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
can somebody help me?Simple,
Some error in your query right. Unable to understand Quotation stuff.
Well understand it properly else error will follow forever :)
Without String, Straight Away Values
stmt1.executeUpdate("insert into Login_Details values('Example','Exmaple')");This is the query with Login_Id Pass_Word String containing the value
stmt1.executeUpdate("insert into Login_Details values('"+Login_Id+"','"+Pass_Word+"')");Then storing sql as string and pass it in executeUpdate(sql)
String sql="insert into Login_Details values ('example','example') "String + Values in String
String sql="insert into Login_Details values ('"+example+"','"+example+"') "Just first it . Hope this reply solve ur SQL EXCEPTIONG
Sachin Kokcha -
Error when saving custom Datasource on R/3
Hi,
I'm creating a transaction datasource using Extraction by Function Module.
I've created & activated the required extract struct (using Tcode: SE11) and the function module.
However after populating these 2 fields in the datasource screen, when i try to save the DS. I get the following error.
Error message : Units field MEINS for field GWERT of DataSource Z_PURCH_SMI_DATA is hidden
Here GWERT is the field of the structure used in DS definition and in it's property i've mentioned MARA.MEINS as reference fields (it is obligatory else error when activating structure).
The structure got activated successfully, but is giving problem in Datasource.
Fyi, similar message is appearing for other fields of the structure.
Any input would be appreciated.
Regards,
Nagendra.Hi there,
In SE11 where you are creating View or table for Datasource, Just add MEINS field in that as new entry
and for field GWERT in reference fields table, give this MEINS field and reference table should be same table/ View name where you are adding this field.
Regards,
Rajdeep Rane.
Maybe you are looking for
-
How do I add passwords from pages that don't automatically save them.
These days lots of web pages don't respond to Firefox's automatic password saving feature. Even when I use the little "Remember passwords" script that removes autocomplete=off from websites there are still a lot of them where it won't save passwords.
-
Warm greetings to all!, While using Specail GL indicator system is also using payment block field by default.Even if i try to remove it still it picks up the value in payment block field. Pls guide me suitable solution. Immediate reply will be apprec
-
I accidently deleted a saved document how do i restore it?
I accidently deleted a saved document how do i restore it?
-
How to remove the Fade-in or Fade-out of a region?
I just made a fade-in or fade-out with the fade tool, I cant find how to remove it, just change it. How does we make it go away? Thanks
-
IPad 4 32 GB+Celullar lag on iOS 7
Hello everyone, I updating my ipad 4 to ios 7 via OTA...and i have a lot of lag. when im trying to play real racing 3(especially) and other games i have lag wich on ios 6.1.3 never happend.when i close an app its laggy too...when i want to change my