If-elseif-else
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
Similar Messages
-
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";
?> -
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 -
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> -
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 -
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 -
Best way to test each if else statement
Hey everyone I have a few scripts that have many different if ,elseif, else blocks. The problem is that they are hard to test and some are rarely triggered. However I need to check to make sure the contents triggered by one of the statements works. I know
there is a whatif switch but from my understanding it is only used for specific commands and doesn't actually trigger them.
So is there some way to debug them or force the script to meet a condition of an if statement?
Thanks for any help!!Hi,
I generally put a Write-Output in each branch that will tell me where I am. Here's an example:
$trigger = 1
If ($trigger -eq 1) {
Write-Output 'Found #1'
} ElseIf ($trigger -eq 2) {
Write-Output 'Found #2'
} ElseIf ($trigger -eq 3) {
Write-Output 'Found #3'
} Else {
Write-Output 'Found something else'
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing) -
Hi Guys
I have two csv files with the following headers and I need to import both files into the script to check whether the StaffCode is present in the Creation/Renewal of Contract csv in a DisableAccount Script so I can stop any action to disable the account as
the staff has renewed the contract with the company so the account should not be disabled.
However my accounts are still being disabled. I am not sure now to construct the query so that it detects that the account is to be left alone if the staffcode is present in both files
I does recognize that the $staffcodeN in the renewal file matches the $staffcode in the termination file
but still proceeds to disable or set an expiry date to the account anyway based on the termination file.
How do I stop it from doing that?
1)In the Creation/Renewal of contract file the following headers are present
- TranCode,StaffCode,LastName,FirstName,SocialSecurityNo,DateJoin,Grade,Dept,LastUpdateDate,EffectiveDate
2)In the Disable of contract file the following headers are present
- TranCode,StaffCode,LastName,FirstName,SocialSecurityno,LastDateWorked,Grade,Dept,LastUpdateDate,
My data is not very clean , I have a-lot of special characters such as = , ' ,/ and \ characters to remove first before i can compare the data
Thanks for the help in advance.
Yours Sincrely
Vicki
The following is a short snippet of the code
$opencsv = import-csv "D:\scripts\Termination.csv"
$opencsv2 = import-csv "D:\scripts\RenewContractandNewStaff.csv"
foreach ($usertoaction in $opencsv)
$Trancode = $usertoactionTranCode
$StaffCode = $usertoaction.StaffCode.replace("=","").replace('"','')
$LastName = [string]$usertoaction.LastName.Replace("/","\/").Replace(",","\,")
$FirstName = [string]$usertoaction.FirstName.Replace("/","\/").Replace(",","\,")
$socialsecurityno = $usertoaction.SocialSecurityNo.replace("=","").replace('"','')
$DateJoin = $usertoaction.DateJoin.replace("=","").replace('"','')
$LastDateWorked = $usertoaction.LastDateWorked.replace("=","").replace('"','')
$Grade = [string]$usertoaction.Grade
$Dept = [string]$usertoaction.Dept
$LastUpdateDate = $usertoaction.LastUpdateDate.replace("=","").replace('"','')
$AccountExpiry = [datetime]::Now.ToString($LastDateWorked)
foreach ($usertoaction2 in $opencsv2)
$TrancodeN = $usertoaction2.TranCode
$StaffCodeN = $usertoaction2.StaffCode.replace("=","").replace('"','')
$socialsecurityNoN= $usertoaction2.SocialSecurityNo.replace("=","").replace('"','')
$DateJoinN = $usertoaction2.DateJoin.replace("=","").replace('"','')
$GradeN = [string]$usertoaction2.Grade
$DeptN = $usertoaction2.Dept
$LastUpdateDate = $usertoaction.LastUpdateDate.replace("=","").replace('"','')
$EffectiveDate = $usertoaction.EffectiveDate.replace("=","").replace('"','')
$LastName2 = [string]$usertoaction2.LastName.Replace(",", "").Replace("/","").trim()
$FirstName2 = [string]$usertoaction2.FirstName.Replace("/","").trim()
# Use DirectorySearcher to find the DN of the user from the sAMAccountName.
$Domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$Root = $Domain.GetDirectoryEntry()
$Searcher = [System.DirectoryServices.DirectorySearcher]$Root
$Searcher.Filter = "(sAMAccountName=$samaccountname)"
$doesuserexist1 = $Searcher.Findall()
if ($doesuserexist1 -eq $Null)
{Write-Host $samaccountname "account does not exist"}
elseif ($StaffCodeN -match $staffcode)
write-host "user has renewed the contract, no action taken"
else
if(($lastupdatedate -ne $null)-or($LastDateWorked -ne $null))
write-host "Setting Account Expiry to"$accountexpirydate
#$ChangeUser.AccountExpires = $accountexpirydate
#$Changeuser.setinfo()
if ($UserMailforwarding -ne $null)
#Set Account expiry date to Last Date Worked
# $ChangeUser.AccountExpires = $accountexpirydate
# $Changeuser.setinfo()
write-host "staff" $displayname "with staff employee no" $samaccountname "has
mailforwarding"
Write-host "Please disable the account manually via Active Directory Users & Computers and
Elseif ($accountexpirydate -lt $todaysdate)
#disable the accountHi Vicki,
This Forum has an insert-codeblock function. Using it will make your script far more readable
Your script is missing some parts, it is impossible to follow the problem.
You are performing the same string cleaning action on $opencsv2 for each element in $opencsv, when doing it once should suffice. Why not start it all by cleaning the values and storing the cleaned values in new arrays?
The Compare-Object function is great, why not take it out for a stroll on these lists, it might just safe you lots of unnecessarily complicated code ...
You are creating a new $Domain, $Root and $Searcher object each iteration, when doing it once should suffice. Probably not much of a time-saver, but every little thing contributes.
Try pinpointing the problem by doing extensive logging, not only by writing which action was taken, but writing the inidividual information (variables, mostly) before evaluation occurs. Your if/elseif/else looks sound, so if it's still not doing what you
want, the ingoing data must be different from what you think should be there.
Cheers,
Fred
There's no place like 127.0.0.1 -
Login with conditions problems
What is wrong with this function? I am trying to create a
user login that
checks to make sure the user is in the database first, then
check the active
level. If the level is 1 then set sessions and redirect, if 2
then redirect
to the login page and send a URL variable of
account=suspended, if 0 then
redirect to the login page sending a URL variable of
account=inactive, etc.
I want to query the db first to see if the user is in the
datasbase. If yes,
then check the active number. I am getting this error in the
conditional
statement to check the 'active' column.
'You have attempted to dereference a scalar variable of type
class
java.lang.String as a structure with members'
What am I missing?
<cffunction name="UserLogin" access="remote"
returntype="void">
<cfargument name="username" type="string"
required="yes">
<cfargument name="password" type="string"
required="yes">
<cfquery name="login" datasource="***">
Select username, password, priv FROM users_database
WHERE username='#arguments.username#' AND
password='#arguments.password#'
</cfquery>
<cfif login.recordcount NEQ 0>
<cfif login.active EQ 1>
<cflock scope="session" timeout="30" type="exclusive">
<cfset Session.MM_Username = #arguments.username#>
<cfset Session.SitePriv = #login.priv#>
</cflock>
<cflocation url="/clinic/contribute/main/index.cfm"
addtoken="no">
<cfelseif login.active EQ 0>
<cflocation
url="/clinic/contribute/index.cfm?account=inactive"
addtoken="no">
<cfelseif login.active EQ 2>
<cflocation
url="/clinic/contribute/index.cfm?account=suspended"
addtoken="no">
<cfelseif login.active EQ 3>
<cflocation
url="/clinic/contribute/index.cfm?account=banned"
addtoken="no">
</cfif>
<cfelse>
<cflocation
url="/clinic/contribute/index.cfm?login=failed" addtoken="no">
</cfif>
</cffunction>Sabaidee as covered why your code didn't work. here's some
more pointers
where your code could be improved...
> <cffunction name="UserLogin" access="remote"
returntype="void">
Set output="false" on all methods unless you actually are
outputting stuff
from them (which generally you should not).
I doubt this method would be appropriate for calling as a
webservice (given
it ends with a <cflocation>), so don't expose it as
one. access="public".
Add hints to all your <cffunction> and
<cfargument> tags. It assists
sanity checking and code documentation.
> <cfquery name="login" datasource="***">
You have not VARed the login variable. This is poor practice
unless you
explicitly mean to not VAR it.
> WHERE username='#arguments.username#' AND
password='#arguments.password#'
Always use <cfqueryparam> tags. It improves performance
and reduces memory
consumption on your DB server.
> <cflock scope="session" timeout="30"
type="exclusive">
> <cfset Session.MM_Username = #arguments.username#>
> <cfset Session.SitePriv = #login.priv#>
> </cflock>
There's no need to lock this sort of variable assignment.
> <cflocation url="/clinic/contribute/main/index.cfm"
addtoken="no">
It's pretty poor practice to use <cflocation> within a
function. You CFM
page should call a method, and get a response back from it.
And then the
CFM page should decide whether to <cflocation> or not.
Possibly your
function should set the URL for the <cflocation> and
return the value.
Then the calling code should use than in a <cflocation>
call.
> <cfelseif login.active EQ 0>
This if/elseif/else construct would be better done as a
switch. Rule of
thumb: evaluating the same variable for many conditions:
switch.
evaluating different variables for many conditions:
if/elseif/else.
Adam -
Hello,
I have to create a decision tree which has to be called within a BAPI.
This tree finally has to return 1 single value.
Can you tell me what's the best solution for this ?
Should I do this with abap, or should I call a webapplication which provides this tree for me ?
It would be great if you could provide some example-code for me.
Kind regards,
Gert-JanI am not sure I understood what you meant by decision tree. If you are simply talking about arriving at an answer based on one or more inputs, then it is a simple IF ELSEIF ELSE statements or CASE statements.
Can you please elaborate/give example of what you mean by decision tree? -
Process InfoPackage based on a condition in Process Chain
Hi,
I would like to include a Function Module in my Process Chain.Based on the output of the Function Module (example Flag - 'A','B','C') I would like to load data from Infopackage.
Could you please suggest the best possible solution.
Thanks,
Nimaithen you need a decision step...
as you want to use a FM to get the outcome, you can't use the standard decision step as you can only use a formula...
so you need to implement a new decision step...look on sdn for the how to paper 'Enhanced Decision Process Type for BW Process Chains'...
this how to paper will lead you to create a process step of the type decision but you can use abap forms (take a look at it and it will become clear)...once you have done this, drag/drop the step in your chain. within the variant, you can define the result of the if, elseif, else...you can add as much elseif as you want (a lot in any case)...you need to create for every 'if' the form using the FM... back in the process chain you can link this step to all the infopackages, and indicate the result of the decision step leading to the infopackage execution...
that's the nice way...
the easy way :
create for every infopackage a single process chain (you can easily copy them)...they should start after event EV_A, EV_B, and so on...every chain after another event...now create an abap program and call the function module...now depending on the outcome of your FM you can trigger one of the events and the corresponding chain will start, leading to the correct infopackage being loaded.
look on abap forum on more info about event triggering, how to create event,... -
Not getting correct output for smatform in spool file
Hi All,
I am using smartform to print some letter. In the smartform under main window I have put some layouts. For each layout I am displaying some particular fields in spool file. In the line editor I have given some conitions (if -elseif-else) to display different fields.
<b>My code in line editor is like:</b>
/: if <condition1>
&var1&
/: elseif <condition2>
&var2&
/: else
&var3&
So it should display diffent output according to the conditions. But when I am trying to execute form, its showing var1, var2 & var3 all in spool file.
Does it means there is no effect of if conition??
Could u please help me in solving this issue.
Thanks in advance.
Regards,
VijayWhy don't u try at Program lines instead of editor.
-
Hi all,
I want to add to this code with an elseif
Will it work to put in before the else in the udf.cfm code
below the following? TIA:
elseif (referer contains 'yahoo.com')
StartPos=ReFindNoCase('q=.',referer);
if (StartPos GT 0) {
EndString=mid(referer,StartPos+2,Len(referer));
Keywords=ReReplaceNoCase(EndString,'&.*','','ALL');
Keywords=URLDecode(Keywords);
return Keywords;
udf.cfm
<cfscript>function getGoogleKeywords(referer) {
var Keywords='';
var StartPos=0;
var EndString='';
if (referer contains 'google.com') {
StartPos=ReFindNoCase('q=.',referer);
if (StartPos GT 0) {
EndString=mid(referer,StartPos+2,Len(referer));
Keywords=ReReplaceNoCase(EndString,'&.*','','ALL');
Keywords=URLDecode(Keywords);
return Keywords;
else {
return '';
}</cfscript>quote:
Originally posted by:
cf_dev2
> Will it work to put in before the else
Did you try it? An if / elseif / else works the same as a
cfif/cfelseif/cfelse.
Really?
I always use two words, "else if"
Guess there's always more than one way that works.
Maybe you are looking for
-
Using IPsec in solaris 10 with zones - in the zones.
I manage to set up the IPsec feature in the global zone , However, i need to use it in one of the zones, How can i do it?????
-
Can you set up a search specifically for Bookings in BC?
I have a dive client who wants to have the next 3 months of events setup on the website so this could mean 30 - 50 events in advance. So I am going to build the events in the Bookings Module and link the payments form to each event BUT I would also l
-
Trying to export to .swf but keep getting an .html format file
Surprise surprise, I'm confused again. I am trying to export a Keynote '08 slide presentation to .swf to enable it to play in my web site. When I look at the exported files, it has the .swf extension but the info for the file shows it as a html docum
-
" Send Masterdata Changes to APO" Job failure
Hi All, We are facing issues where there are changes in Material Description in R/3 and those changes were reverted again. When these changes were sent to APO through background job, the job due to stuck queue. it shows the error "The ABAP/4 Open SQL
-
Hi All, I have OS version - Red Hat Enterprise Linux Server release 6.4 and kernel is 2.6.32-358.el6.x86_64 #1. I want to install ASMLib for rhel6 but when I searched for ASLMib download then it showing upto Red Hat Enterprise Linux 5 AS. Can any one