Is there a 'compile time' if/else statement in LabVIEW
I have some LabVIEW software that includes subVIs to read from and write to digital IO lines. However, I need to also be able to run this software on systems which don't have an IO card (or associated drivers) installed and so I want to be able to allow the software to be on PCs that do or don't have the drivers installed.
Optimally, I would like to modify the software so that at runtime, by reading the settings in a configuration file, a boolean is set to determine whether the IO functions are called. I tried this but, unfortunately, am getting error messages when I try and start up the software due to the lack of the 'nidaq32.dll' file on the target PC. I'm guessing this is because the subVIs are only within case structures and so must be loaded into memory regardless of whether they are to be used.
Is there any way around this problem? If I were writing this in C I guess I would use '#if' statements to include/exclude the IO functions at compile time. Is there an equivalent in LabVIEW? I guess my options are:
1. Finding some way of allowing the IO functions to be included at runtime though I'm thinking this might not be possible.
2. Include/exclude the IO functions at compile time with some LabVIEW equivalent of the C '#if' preprocessor directive.
3. Give in and install the nidaq32.dll file with the software.
Just to complicate matters, I'm currently running LabVIEW 5.0.1 (I do plan to upgrade soon) so am limited to the functions available in this version.
Thanks.
CAS wrote:
Just to complicate matters, I'm currently running LabVIEW 5.0.1 (I do plan to upgrade soon) so am limited to the functions available in this version.
That's the main problem.
On newer versions you can:
define simulated devices (http://zone.ni.com/devzone/cda/tut/p/id/3698)
use the conditional disable structure (see e.g.: http://zone.ni.com/devzone/cda/tut/p/id/3046, (see section 6))
Time to upgrade!
Message Edited by altenbach on 06-21-2007 07:32 AM
LabVIEW Champion . Do more with less code and in less time .
Similar Messages
-
OCIBindByPos() and dynamic SQL (not known at compile time)
Hi,
How can I use OCIBindByPos() or OCIBindByName() if the datatyp of the bind variable(s) is unknown at compile time (the SQL statement is entered by the user at run time)? Or which functions should I use instead?
Many thanks in advance
Edited by: user13176357 on 17.04.2012 12:43You could write a single native method (with a defined name like "callNative" below) that accepts the name (string) of the actual native function you want to call, and then locates the function via GetProcAddress and calls it. Argument passing and return values could get tricky if the target native functions aren't guaranteed to all have the same signature, but you could handle that by explicit boxing:
native Object callNative (String name, Object [] args);
-slj- -
Timer event doesn't listen to my if else statements how do stop it?
So I'm building a random generator of just a vector that i imported into flash and everything works just fine, almost. I added a timer to the creation of the vector. I also have some if else statements that are going to govern User Input. I realized that if the UI was initially outside of the parameters i've set it runs fine but once the once the function with the timer starts it never stops regardless of whether or not the UI is in the parameters I set. How do I stop the function when the UI is not what i want it to be?
Heres my code:
//initial universal variable declaration
var kface:Kobbyface;
var UI:Number;
var kfacex:Number;
var kfacey:Number;
var UIold:Number = 0;
var timer:Timer = new Timer(200);
//background rectangle
graphics.beginFill(0xFFFF00, 1);
graphics.drawRect(0,65, stage.stageWidth, stage.stageHeight);
graphics.endFill();
trace (inputnumber);
//eventlistener for click
gobutton.addEventListener(MouseEvent.CLICK, create);
function create(me:MouseEvent):void {
UI = Number(inputnumber.text);
if (isNaN(UI)) {
errormessages.text = "Kobby only responds to numbers"
else if (UI > 500) {
errormessages.text = "You're not ready for that many Kobbys"
else if (UI < 15) {
errormessages.text = "Come on you can handle more than that"
else{
createfaces();
//for loop///
function createfaces ():void {
////////timer for face animation///////
timer.addEventListener(TimerEvent.TIMER, animate);
timer.start();
function animate(evt:TimerEvent):void {
/////keep track of old number/////
if (UIold != 0) {
for (var i: int = 1; i<UIold + 1; i++) {
stage.removeChildAt(1);
/////assign old number to new number////
UIold = UI;
for ( var i:int = 1; i<UI + 1; i++ ) {
trace( i );
////assign values to coordinate varialbes/////
var kfacex:Number = Math.random() * stage.stageWidth;
var kfacey:Number = Math.random() * stage.stageHeight + 65;
//creation of faces///
kface = new Kobbyface();
stage.addChild(kface);
kface.x = kfacex;
kface.y = kfacey;you can apply the stop() method to your timer:
timer.stop(); -
Compilation error with simple if-else statement
package chapterFive;
* Author: Sarab
* Filename: MainClass.java
* Purpose: Try and get my mind around the concept of the selection
* control structures and repetition statements
class MainClass {
public static void main(String [] args)
// some variables and prompt for input
java.util.Scanner scan = new java.util.Scanner(System.in);
System.out.print("Please enter your name: ");
String input = scan.nextLine();
// some repetition statement, for loop
if (input.equals("Sarab"));
System.out.println("Welcome Sarab!");
else
System.out.println("You are in the else statement");
for(int sentinelValue; sentinelValue<5; sentinelValue++)
System.out.println("The following is the numbers 0-4"
+ " printed on separate lines: " + sentinelValue);
System.out.println("This line will print regardless of whether you"
+ " entered the if or the else portion of the selection"
+ " statement.");
}I am getting the following error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error on token "else", delete this token
at chapterFive.MainClass.main(MainClass.java:26)What's the matter? This looked straight forward enough to me.if (input.equals("Sarab"));
// is the same as
if (input.equals("Sarab")) {}
// so what you have amounts to this:
if (input.equals("Sarab")) {}
System.out.println("Welcome Sarab!");
else { ... }You've got an if block that does nothing, then a block that always executes, calling println, and then your else. Since you have that block between if and else, the if has ended and it's not legal to use else.
Get rid of the semicolon after if. -
Is there a compiler switch to prevent mistakes in NSLog statements?
I keep making the same mistake, putting a float argument into an NSLOG statement and using %d to format it which of course returns ZERO.
float val = 123.456;
NSLog (@"my val=%d
", val);
---- the above statement will show 0 in the log, because of the incorrect type!
I realize i should use %0.f to get an integer value, but is there a compiler switch that will check on these parameters and warn you ?Well, there is a compiler switch to detect mismatches in printf statements, and if you make a macro during testing that converts NSLog to printf then you can get the compiler to catch them!
-
Below is code that has a timer countdown that reads off of the computer. Below in bold is code to read "if it reaches the date, go to and play frame (2).
timer.removeEventListener(TimerEvent.TIMER, updateTime);
timer.stop();
gotoAndPlay(2);
Below is code that is manual input- I had set up a dynamic txt field in flash named it : raffle_tix_remain When loaded on to the host I can manulally update the xml code and the change will take effect.
raffle_tix_remain.text = root.loaderInfo.parameters.raffle_tix_remain;
My question: Since the raffle_tix_remain is a manual input from a user to xml Is there a way to tell flash once it refreshes and "raffle_ tix_ remain" goes to (0) zero gotoAndPlay(2); and let it play like a "sold out" sign
i guess that would be a if else statement.
Code Below-----------------
stop();
var year:Number = 2011;
var month:Number = 12;
var day:Number = 30;
var finalDate:Date = new Date(year,month-1,day);
var timer:Timer = new Timer(100);
timer.addEventListener(TimerEvent.TIMER, updateTime);
timer.start();
function updateTime(e:TimerEvent):void{
var now:Date = new Date();
var remainTime:Number = finalDate.getTime() - now.getTime();
if (remainTime >0) {
var secs:Number = Math.floor(remainTime/1000);
var mins:Number = Math.floor(secs/60);
var hours:Number = Math.floor(mins/60);
var days:Number = Math.floor(hours/24);
var secsText:String = (secs%60).toString();
var minsText:String = (mins%60).toString();
var hoursText:String = (hours%24).toString();
var daysText:String = days.toString();
if (secsText.length < 2) {secsText = "0" + secsText;}
if (minsText.length < 2) {minsText = "0" + minsText;}
if (hoursText.length < 2) {hoursText = "0" + hoursText;}
if (daysText.length < 2) {daysText = "0" + daysText;}
day_txt.text = daysText;
hour_txt.text = hoursText;
min_txt.text = minsText;
sec_txt.text = secsText;
else {
timer.removeEventListener(TimerEvent.TIMER, updateTime);
timer.stop();
gotoAndPlay(2);stop();
var year:Number = 2011;
var month:Number = 12;
var day:Number = 30;
var finalDate:Date = new Date(year,month-1,day);
var now:Date = new Date();
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, updateTime);
timer.start();
function updateTime(e:TimerEvent):void{
var remainTime:Number = finalDate.getTime() - now.getTime()-e.currentCount;
if (remainTime >0 || raffle_tix_remain==0) {
var secs:Number = Math.floor(remainTime/1000);
var mins:Number = Math.floor(secs/60);
var hours:Number = Math.floor(mins/60);
var days:Number = Math.floor(hours/24);
var secsText:String = (secs%60).toString();
var minsText:String = (mins%60).toString();
var hoursText:String = (hours%24).toString();
var daysText:String = days.toString();
if (secsText.length < 2) {secsText = "0" + secsText;}
if (minsText.length < 2) {minsText = "0" + minsText;}
if (hoursText.length < 2) {hoursText = "0" + hoursText;}
if (daysText.length < 2) {daysText = "0" + daysText;}
day_txt.text = daysText;
hour_txt.text = hoursText;
min_txt.text = minsText;
sec_txt.text = secsText;
else {
timer.removeEventListener(TimerEvent.TIMER, updateTime);
timer.stop();
gotoAndPlay(2); -
Hi Everyone..
I am getting an Error 1046: Type was not found or was not a compile-time constant: Component Event.
The ComponentEvent class has been imported,and also the event handling code is there. I am not sure what else is wrong, hope somebody can advise me. Thanks. The code is below, the point where the error occurs as indicated by the compiler has been highlighted.
package
import flash.display.Sprite;
import flash.media.Camera;
import flash.media.Microphone;
import flash.media.Video;
import fl.controls.TextArea;
import fl.controls.Button;
import fl.controls.TextInput;
import flash.events.SyncEvent;
import flash.events.MouseEvent;
import flash.events.FocusEvent;
import flash.net.SharedObject;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.NetStatusEvent;
import flash.events.FocusEvent;
import flash.events.ComponentEvent;
public class VideoChat extends Sprite
private var button:Button;
private var text_so:SharedObject;
private var textArea:TextArea;
private var textInput:TextInput;
private var chatName:TextInput;
private var nc:NetConnection;
private var nsOut:NetStream;
private var nsIn:NetStream;
private var rtmpNow:String;
private var msg:Boolean;
private var cam:Camera;
private var mic:Microphone;
private var vid:Video;
public function VideoChat ()
//Set up UI
textArea = new TextArea();
textArea.setSize(500,280);
textArea.move(20,54);
addChild(textArea);
textInput = new TextInput();
textInput.setSize(500,24);
textInput.move(20,340);
textInput.addEventListener(ComponentEvent.ENTER,checkKey);
addChild(textInput);
button = new Button();
button.width=50;
button.label="Send";
button.move(20,370);
button.addEventListener(MouseEvent.CLICK, sendMsg);
addChild(button);
chatName = new TextInput;
chatName.setSize (100,24);
chatName.move (80,370);
chatName.text="<Enter Name>";
chatName.addEventListener (FocusEvent.FOCUS_IN, cleanName);
addChild(chatName);
//Connect
rtmpNow="rtmp:/VideoChat ";
nc=new NetConnection;
nc.connect (rtmpNow);
nc.addEventListener(NetStatusEvent.NET_STATUS,doSO);
cam = Camera.getCamera();
mic=Microphone.getMicrophone();
//Camera Settings
cam.setKeyFrameInterval(15);
cam.setMode (240, 180, 15, false);
cam.setMotionLevel(35,3000);
cam.setQuality(40000 / 8,0);
//Microphone Settings
mic.gain = 85;
mic.rate=11;
mic.setSilenceLevel (25,1000);
mic.setUseEchoSuppression (true);
//Video Setup
vid=new Video(cam.width, cam.height);
addChild (vid);
vid.x=10, vid.y=20;
//Attach local video and camera
vid.attachCamera(cam);
private function doSO(e:NetStatusEvent):void
good=e.info.code == "NetConnection.Connect.Success";
if(good)
//Set up shared object
text_so=SharedObject.getRemote("test", nc.uri, false);
text_so.connect (nc);
text_so.addEventListener(SyncEvent.SYNC, checkSO);
private function checkSO(e:SyncEvent):void
for (var chung:uint; change<e.changeList.length; chng++)
switch(e.chageList[chng].code)
case "clear":
break;
case "success":
break;
case "change":
textArea.appendText (text_so.data.msg + "\n");
break;
private function cleanName(e:FocusEvent): void
chatName.text="";
private function sendMsg(e:MouseEvent):void
noName=(chatName.text=="<Enter Name>" || chatName.text=="");
if (noName)
textArea.appendText("You must enter your name \n");
else
text_so.setProperty("msg", chatName.text +": " + textInput.text);
textArea.appendText (chatName.text +": "+textInput.text +"\n");
textInput.text="";
private function checkKey (e:ComponentEvent):void
noName=(chatName.text=="<Enter Name>" || chatName.text=="");
if (noName)
textArea.appendText("You must enter your name \n");
else
text_so.setProperty("msg", chatName.text +": " + textInput.text);
textArea.appendText (chatName.text +": "+textInput.text +"\n");
textInput.text="";
//Create NetStream instances
private function checkConnect (e:NetStatusEvent):void
msg=e.info.code == "NetConnection.Connect.Success";
if(msg)
nsOut=new NetStream(nc);
nsIn=new NetStream(nc);
//NetStream
nsOut.attachAudio(mic);
nsOut.attachCamera(cam);
nsOut.publish("camstream");
nsIn.play("camstream");Hi Guys...
I have found out what is wrong. I was importing the wrong package the correct one should have been:
import fl.events.ComponentEvent;
instead of
import flash.events.ComponentEvent;
I hope this is helpful for anyone caught in a simillar situation as me...Thanks.. -
Getting compile time errors during gwt application compilation
Hi,
I am getting below compile errors while running ant script for my GWT application.
javac:
[javac] Compiling 32 source files to D:\Projects\workspace\MckSurvey\war\WEB-INF\classes
[javac] D:\Projects\workspace\MckSurvey\src\com\spinsci\survey\client\model\QuestionBean.java:38: type parameters of <X>X cannot be determined; no unique maximal instance exists for type variable X with upper bounds int,java.lang.Object
[javac] return get("questionId");
[javac] ^
I am using JDK 1.6 and ANT 1.7 s/w.
below is the target which is used in the build file:
<javac srcdir="src" includes="**" encoding="utf-8"
destdir="war/WEB-INF/classes"
nowarn="true"
debug="true" debuglevel="lines,vars,source"
includeDestClasses="false"
source="1.5" target="1.5"
>
<classpath refid="project.class.path"/>
<compilerarg value="-Xlint:-unchecked"/>
</javac>
Please suggest me accordingly to overcome this generics compile time errors.
Regards,
Sunder.dannyyates wrote:
There are/have been numerous examples of differences in spec interpretation between Eclipse (ecj) and the Sun compiler. I generally find that Eclipse is more accurate in it's interpretation than Sun! :-)
I would suggest raising this on an appropriate Eclipse forum. The guys there are normally very good at digging into the issue and explaining why they think they are right or else admitting that they've got it wrong.I totally agree on both accounts. I myself have seen at least two compiler bugs and asked both the Sun guys and the Eclipse guys (through their respective bug tracking systems) and both have been resolved (in both cases ecj was actually right, but I wouldn't dare drawing any conclusions from that ;-)). -
Select instance of polymorphi​c vi at compile time
quick question:
I have a fairly significant labview project that i'm deploying to several compactRIOs. However, I have two possible configurations of that code. The difference between the two configurations is a single VI. That is, within my project, there's one VI that I replace with another (same connector pane) for the alternate configuration.
What I want to do is to make that VI into a polymorphic VI, then have the instance of that polymorphic VI be set at compile time. That is, I would have two build specifications. Each build specification would build a configuration of the project by having the selection of which instance of the polymorphic VI to use be included as a parameter of the build specification. If it is possible to do, I can't seem to find the option in the build specification preferences to do so.
Does this make sense? Any help is appreciated.
Cheers.
Solved!
Go to Solution.Keith_W wrote:
yamaeda, i'm unclear about what you're suggesting. are you suggesting that i use the VI scripting VIs to programmatically edit the VI to switch which state is enabled by using a VI that runs before building, but as part of the build process?
The Conditional disable seems to work like a script at compile time. As you stated your problem it sounds like you wanted 2 builds anyway, and this would enable one of the conditional frames when building the exe.
/Y
LabVIEW 8.2 - 2014
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
G# - Free award winning reference based OOP for LV -
OBIEE 10g - high compilation time
Hi All,
While doing performance tuning for one of the request in OBIEE 10g, I realized that the compilation time for the request is very high (almost 50% of total time). Is there any way I can reduce it?
Here's summary stats from the log.
+++administrator:111e0000:111e0024:----2012/02/22 15:28:29
-------------------- Logical Query Summary Stats: Elapsed time 105, Response time 105, Compilation time 50 (seconds)
Thanks in advance.Hi,
Check for the indexes. And if its there then try to change the order(ie the order of the columns in the index) with which the query uses the indexes.
Otherwise you can also make the report run by default in any of the default pages(making it hidden). So what happens is the report gets cached, so when the user tries to view the report, it happens to come fast.
Regards
MuRam.
NOTE-Please mention if this worked/ still facing issue, so that it could be useful for others will similar issue. -
PreparedStatement is About 60 times slower than Statements
I am highly suprised that in my programme a normal statement is a lot faster than a Prepared Statement. I am posting below both the Programmes, in one I am using Prepared Statements and in another I am using normal Statements. My OS is Win NT My Database is SQL Server 7. THe progamme extracts data from a file and inserts records in the database. In the test case I had A file of about 1440 records ie. 1440 inserts are made to the database, The database table is very large ie. It has around 126 Columns.
So for inserting 1440 record froma file the Prepared Statements take around 7 Minutes . And for reading the same file and inserting the same no of records in the same database normal Statements Take only about 7 seconds. Now the JAcva docs clearly Specify that when we need to use the same stmt many times it is better to use Prepared Satements < the results that I am Getting is clear and complete violation of what java docs say.
Here is the code with Prepared Statements
package mps.mpsPTLF;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.Calendar;
import java.util.Date;
import gen.genCommon.genConnectionPool.*;
import gen.genCommon.*;
public class PTLFProcessor
private static clsLogFile moLogFile = new clsLogFile("");
private gen.genCommon.genConnectionPool.SharedConnectionPool mConnPool = SharedConnectionPool.getInstance(2);
FileReader fPTLF = null;
BufferedReader brPTLF = null;
//**************** Begin Constructor declaration ************************
To intialize the class variables for new Fee
public PTLFProcessor(String pathPTLF) throws GenException
try
fPTLF = new FileReader(pathPTLF);
brPTLF = new BufferedReader(fPTLF);
catch (Exception e)
throw new GenException("Error Accessing file : " + pathPTLF + " - " + e.toString(),e );
//**************** End Constructor declaration ************************
public void PTLFGetData() throws GenException
char pcData[];
int HEADERSIZE = 6;
boolean pbEndOfFile = false;
boolean pbisFirstBlock = true;
int piBlocksize = 0;
int piOffset = 0;
int piRecordsize = 0;
String psRecordContent = "";
Connection pConn = null;
try
String psInsSql=" INSERT INTO FILE_PTLF_IN ( " +
" fpi_DAT_TIM , " +
" fpi_REC_TYP , " +
" fpi_CRD_LN , " +
" fpi_CRD_FIID , " +
" fpi_CRD_NUM , " +
" fpi_MBR_NUM , " +
" fpi_MER_LN , " +
" fpi_MER_FIID , " +
" fpi_MER_GRP , " +
" fpi_MER_REGN , " +
" fpi_MER_ID , " +
" fpi_TERM_ID , " +
" fpi_SHIFT_NUM , " +
" fpi_BATCH_NUM , " +
" fpi_TERM_LN , " +
" fpi_TERM_FIID , " +
" fpi_TERM_ID_1 , " +
" fpi_TRAN , " +
" fpi_TERM_ID_2 , " +
" fpi_REC_FRMT , " +
" fpi_MER_ID_1 , " +
" fpi_CLERK_ID , " +
" fpi_DATA_FLAG , " +
" fpi_TYP , " +
" fpi_RTE_STAT , " +
" fpi_ORIGINATOR , " +
" fpi_RESPONDER , " +
" fpi_ISS_CDE , " +
" fpi_ENTRY_TIM , " +
" fpi_EXIT_TIM , " +
" fpi_RE_ENTRY_TIM , " +
" fpi_TRAN_DAT , " +
" fpi_TRAN_TIM , " +
" fpi_POST_DAT , " +
" fpi_ACQ_ICHG_SETL_DAT , " +
" fpi_ISS_ICHG_SETL_DAT , " +
" fpi_SEQ_NUM , " +
" fpi_TERM_NAME_LOC , " +
" fpi_TERM_OWNER_NAME , " +
" fpi_TERM_CITY , " +
" fpi_TERM_ST , " +
" fpi_TERM_CNTRY_CDE , " +
" fpi_BRCH_ID , " +
" fpi_USER_FLD2 , " +
" fpi_TERM_TIM_OFST , " +
" fpi_ACQ_INST_ID_NUM , " +
" fpi_RCV_INST_ID_NUM , " +
" fpi_TERM_TYP , " +
" fpi_CLERK_ID_1 , " +
" fpi_GRP , " +
" fpi_USER_ID , " +
" fpi_RETL_SIC_CDE , " +
" fpi_ORIG , " +
" fpi_DEST , " +
" fpi_TC , " +
" fpi_T , " +
" fpi_AA , " +
" fpi_C , " +
" fpi_CRD_TYP , " +
" fpi_ACCT , " +
" fpi_RESP_CDE , " +
" fpi_AMT_1 , " +
" fpi_AMT_2 , " +
" fpi_EXP_DAT , " +
" fpi_TRACK2 , " +
" fpi_PIN_OFST , " +
" fpi_PRE_AUTH_SEQ_NUM , " +
" fpi_INVOICE_NUM , " +
" fpi_ORIG_INVOICE_NUM , " +
" fpi_AUTHORIZER , " +
" fpi_AUTH_IND , " +
" fpi_SHIFT_NUM_1 , " +
" fpi_BATCH_SEQ_NUM , " +
" fpi_APPRV_CDE , " +
" fpi_APPRV_CDE_LGTH , " +
" fpi_ICHG_RESP , " +
" fpi_PSEUDO_TERM_ID , " +
" fpi_RFRL_PHONE , " +
" fpi_DFT_CAPTURE_FLG , " +
" fpi_SETL_FLAG , " +
" fpi_RVRL_CDE , " +
" fpi_REA_FOR_CHRGBCK , " +
" fpi_NUM_OF_CHRGBCK , " +
" fpi_PT_SRV_COND_CDE , " +
" fpi_PT_SRV_ENTRY_MDE , " +
" fpi_AUTH_IND2 , " +
" fpi_ORIG_CRNCY_CDE , " +
" fpi_AUTH_CRNCY_CDE , " +
" fpi_AUTH_CONV_RATE , " +
" fpi_SETL_CRNCY_CDE , " +
" fpi_SETL_CONV_RATE , " +
" fpi_CONV_DAT_TIM , " +
" fpi_IMP_IND , " +
" fpi_AVAIL_BAL , " +
" fpi_LEDG_BAL , " +
" fpi_AMT_ON_HOLD , " +
" fpi_TTL_FLOAT , " +
" fpi_CUR_FLOAT , " +
" fpi_ADJ_SETL_IMPACT_FLG , " +
" fpi_PBF1 , " +
" fpi_PBF2 , " +
" fpi_PBF3 , " +
" fpi_PBF4 , " +
" fpi_FRWD_INST_ID_NUM , " +
" fpi_CRD_ACCPT_ID_NUM , " +
" fpi_CRD_ISS_ID_NUM , " +
" fpi_ORIG_MSG_TYP , " +
" fpi_ORIG_TRAN_TIM , " +
" fpi_ORIG_TRAN_DAT , " +
" fpi_ORIG_SEQ_NUM , " +
" fpi_ORIG_B24_POST_DAT , " +
" fpi_EXCP_RSN_CDE , " +
" fpi_OVRRDE_FLG , " +
" fpi_ADDR , " +
" fpi_ZIP_CDE , " +
" fpi_ADDR_VRFY_STAT , " +
" fpi_PIN_IND , " +
" fpi_PIN_TRIES , " +
" fpi_PRE_AUTH_TS_DAT , " +
" fpi_PRE_AUTH_TS_TIM , " +
" fpi_PRE_AUTH_HLDS_LVL , " +
" fpi_USER_FLD5 , " +
" fpi_LEN , " +
" fpi_INFO )" +
" VALUES ( " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
pConn = mConnPool.getConnection();
PreparedStatement pStmt = pConn.prepareStatement(psInsSql);
while (!pbEndOfFile)
pcData = new char [HEADERSIZE]; // Reading each Block Header
brPTLF.read (pcData, 0, HEADERSIZE);
piBlocksize = Integer.parseInt (new String (pcData));
piOffset = HEADERSIZE;
while (piOffset < piBlocksize)
{ // Read the records upto end of block
pcData = new char [HEADERSIZE]; // Reading each Record Header
brPTLF.read (pcData, 0, HEADERSIZE);
piRecordsize = Integer.parseInt (new String (pcData));
piOffset += HEADERSIZE;
pcData = new char [piRecordsize - HEADERSIZE]; // Reading each Record Content
brPTLF.read (pcData, 0, piRecordsize - HEADERSIZE);
psRecordContent = new String (pcData);
piOffset += piRecordsize - HEADERSIZE;
moLogFile.writeToLog(psRecordContent);
if (pbisFirstBlock)
if (!psRecordContent.startsWith ("TH"))
throw new GenException ("Invalid File Format, missing 'TH'");
pcData = new char [HEADERSIZE]; // Reading next Record Header
brPTLF.read (pcData, 0, HEADERSIZE);
piRecordsize = Integer.parseInt (new String (pcData));
piOffset += HEADERSIZE;
pcData = new char [piRecordsize - HEADERSIZE];// Reading next Record Content (Must be FH)
brPTLF.read (pcData, 0, piRecordsize - HEADERSIZE);
psRecordContent = new String (pcData);
piOffset += piRecordsize - HEADERSIZE;
if (!psRecordContent.startsWith ("FH"))
throw new GenException ("File Header Not Found");
pbisFirstBlock = false;
else if (psRecordContent.startsWith ("DR"))
psRecordContent = psRecordContent.substring(2);
/* if (psRecordContent.length() != 1820 ) // && psRecordContent.length() != 846)
// insert in error table
continue;
if ( psRecordContent.substring(453-1, 455).equals ("000") || psRecordContent.substring(453-1, 455).equals ("001") )
pStmt.setString (1, psRecordContent.substring(1-1,19));
pStmt.setString (2, psRecordContent.substring(20-1,21));
pStmt.setString (3, psRecordContent.substring(22-1,25));
pStmt.setString (4, psRecordContent.substring(26-1,29));
pStmt.setString (5, psRecordContent.substring(30-1,48));
pStmt.setString (6, psRecordContent.substring(49-1,51));
pStmt.setString (7, psRecordContent.substring(52-1,55));
pStmt.setString (8, psRecordContent.substring(56-1,59));
pStmt.setString (9, psRecordContent.substring(60-1,63));
pStmt.setString (10, psRecordContent.substring(64-1,67));
pStmt.setString (11, psRecordContent.substring(68-1,86));
pStmt.setString (12, psRecordContent.substring(87-1,102));
pStmt.setString (13, psRecordContent.substring(103-1,105));
pStmt.setString (14, psRecordContent.substring(106-1,108));
pStmt.setString (15, psRecordContent.substring(109-1,112));
pStmt.setString (16, psRecordContent.substring(113-1,116));
pStmt.setString (17, psRecordContent.substring(117-1,132));
pStmt.setString (18, psRecordContent.substring(133-1,140));
pStmt.setString (19, psRecordContent.substring(141-1,156));
pStmt.setString (20, psRecordContent.substring(157-1,157));
pStmt.setString (21, psRecordContent.substring(158-1,176));
pStmt.setString (22, psRecordContent.substring(177-1,182));
pStmt.setString (23, psRecordContent.substring(183-1,183));
pStmt.setString (24, psRecordContent.substring(184-1,187));
pStmt.setString (25, psRecordContent.substring(188-1,189));
pStmt.setString (26, psRecordContent.substring(190-1,190));
pStmt.setString (27, psRecordContent.substring(191-1,191));
pStmt.setString (28, psRecordContent.substring(192-1,193));
pStmt.setString (29, psRecordContent.substring(194-1,212));
pStmt.setString (30, psRecordContent.substring(213-1,231));
pStmt.setString (31, psRecordContent.substring(232-1,250));
pStmt.setString (32, psRecordContent.substring(251-1,256));
pStmt.setString (33, psRecordContent.substring(257-1,264));
pStmt.setString (34, psRecordContent.substring(265-1,270));
pStmt.setString (35, psRecordContent.substring(271-1,276));
pStmt.setString (36, psRecordContent.substring(277-1,282));
pStmt.setString (37, psRecordContent.substring(283-1,294));
pStmt.setString (38, psRecordContent.substring(295-1,319));
pStmt.setString (39, psRecordContent.substring(320-1,341));
pStmt.setString (40, psRecordContent.substring(342-1,354));
pStmt.setString (41, psRecordContent.substring(355-1,357));
pStmt.setString (42, psRecordContent.substring(358-1,359));
pStmt.setString (43, psRecordContent.substring(360-1,363));
pStmt.setString (44, psRecordContent.substring(364-1,366));
pStmt.setString (45, psRecordContent.substring(367-1,371));
pStmt.setString (46, psRecordContent.substring(372-1,382));
pStmt.setString (47, psRecordContent.substring(383-1,393));
pStmt.setString (48, psRecordContent.substring(394-1,395));
pStmt.setString (49, psRecordContent.substring(396-1,401));
pStmt.setString (50, psRecordContent.substring(402-1,405));
pStmt.setString (51, psRecordContent.substring(406-1,413));
pStmt.setString (52, psRecordContent.substring(414-1,417));
pStmt.setString (53, psRecordContent.substring(418-1,421));
pStmt.setString (54, psRecordContent.substring(422-1,425));
pStmt.setString (55, psRecordContent.substring(426-1,427));
pStmt.setString (56, psRecordContent.substring(428-1,428));
pStmt.setString (57, psRecordContent.substring(429-1,430));
pStmt.setString (58, psRecordContent.substring(431-1,431));
pStmt.setString (59, psRecordContent.substring(432-1,433));
pStmt.setString (60, psRecordContent.substring(434-1,452));
pStmt.setString (61, psRecordContent.substring(453-1,455));
pStmt.setString (62, psRecordContent.substring(456-1,474));
pStmt.setString (63, psRecordContent.substring(475-1,493));
pStmt.setString (64, psRecordContent.substring(494-1,497));
pStmt.setString (65, psRecordContent.substring(498-1,537));
pStmt.setString (66, psRecordContent.substring(538-1,553));
pStmt.setString (67, psRecordContent.substring(554-1,565));
pStmt.setString (68, psRecordContent.substring(566-1,575));
pStmt.setString (69, psRecordContent.substring(576-1,585));
pStmt.setString (70, psRecordContent.substring(586-1,601));
pStmt.setString (71, psRecordContent.substring(602-1,602));
pStmt.setString (72, psRecordContent.substring(603-1,605));
pStmt.setString (73, psRecordContent.substring(606-1,608));
pStmt.setString (74, psRecordContent.substring(609-1,616));
pStmt.setString (75, psRecordContent.substring(617-1,617));
pStmt.setString (76, psRecordContent.substring(618-1,625));
pStmt.setString (77, psRecordContent.substring(626-1,629));
pStmt.setString (78, psRecordContent.substring(630-1,649));
pStmt.setString (79, psRecordContent.substring(650-1,650));
pStmt.setString (80, psRecordContent.substring(651-1,651));
pStmt.setString (81, psRecordContent.substring(652-1,653));
pStmt.setString (82, psRecordContent.substring(654-1,655));
pStmt.setString (83, psRecordContent.substring(656-1,656));
pStmt.setString (84, psRecordContent.substring(657-1,658));
pStmt.setString (85, psRecordContent.substring(659-1,661));
pStmt.setString (86, psRecordContent.substring(662-1,662));
pStmt.setString (87, psRecordContent.substring(663-1,665));
pStmt.setString (88, psRecordContent.substring(666-1,668));
pStmt.setString (89, psRecordContent.substring(669-1,676));
pStmt.setString (90, psRecordContent.substring(677-1,679));
pStmt.setString (91, psRecordContent.substring(680-1,687));
pStmt.setString (92, psRecordContent.substring(688-1,706));
pStmt.setString (93, psRecordContent.substring(707-1,707));
pStmt.setString (94, psRecordContent.substring(708-1,708));
pStmt.setString (95, psRecordContent.substring(709-1,709));
pStmt.setString (96, psRecordContent.substring(710-1,710));
pStmt.setString (97, psRecordContent.substring(711-1,711));
pStmt.setString (98, psRecordContent.substring(712-1,712));
pStmt.setString (99, psRecordContent.substring(713-1,713));
pStmt.setString (100, psRecordContent.substring(714-1,714));
pStmt.setString (101, psRecordContent.substring(715-1,715));
pStmt.setString (102, psRecordContent.substring(716-1,716));
pStmt.setString (103, psRecordContent.substring(717-1,717));
pStmt.setString (104, psRecordContent.substring(718-1,728));
pStmt.setString (105, psRecordContent.substring(729-1,739));
pStmt.setString (106, psRecordContent.substring(740-1,750));
pStmt.setString (107, psRecordContent.substring(751-1,754));
pStmt.setString (108, psRecordContent.substring(755-1,762));
pStmt.setString (109, psRecordContent.substring(763-1,766));
pStmt.setString (110, psRecordContent.substring(767-1,778));
pStmt.setString (111, psRecordContent.substring(779-1,782));
pStmt.setString (112, psRecordContent.substring(783-1,785));
pStmt.setString (113, psRecordContent.substring(786-1,786));
pStmt.setString (114, psRecordContent.substring(787-1,806));
pStmt.setString (115, psRecordContent.substring(807-1,815));
pStmt.setString (116, psRecordContent.substring(816-1,816));
pStmt.setString (117, psRecordContent.substring(817-1,817));
pStmt.setString (118, psRecordContent.substring(818-1,818));
pStmt.setString (119, psRecordContent.substring(819-1,824));
pStmt.setString (120, psRecordContent.substring(825-1,832));
pStmt.setString (121, psRecordContent.substring(833-1,833));
pStmt.setString (122, psRecordContent.substring(834-1,866));
pStmt.setString (123, psRecordContent.substring(867-1,870));
pStmt.setString (124, psRecordContent.substring(871-1,1070));
// if (pStmt.executeUpdate() != 1)
// throw new GenException ("Insertion failed");
String psMsgType = psRecordContent.substring (184-1, 187);
if (true)//updateTable (conn, pstmt, pstmt1, pstmt2, psRecordContent, out, bw))
if (psMsgType.equals ("0500") || psMsgType.equals ("0520"))
//piSettlementDR++;
if (psMsgType.equals ("0210"))
//piUpdatedDR++;
if (psMsgType.equals ("0220") || psMsgType.equals ("0320") || psMsgType.equals ("0420"))
//reversalDR++;
//validDR++;
//totalDR++;
else if (psRecordContent.startsWith ("FT"))
pcData = new char [HEADERSIZE]; // Reading next Record Header
brPTLF.read (pcData, 0, HEADERSIZE);
piRecordsize = Integer.parseInt (new String (pcData));
piOffset += HEADERSIZE;
pcData = new char [piRecordsize - HEADERSIZE];// Reading next Record Content (Must be TT)
brPTLF.read (pcData, 0, piRecordsize - HEADERSIZE);
psRecordContent = new String (pcData);
piOffset += piRecordsize - HEADERSIZE;
if (!psRecordContent.startsWith ("TT"))
throw new GenException ("Total Trailer not Found.");
pbEndOfFile = true;
} // while (piOffset < piBlocksize)
} // while (!pbEndOfFile)
brPTLF.close();
fPTLF.close();
pStmt.close();
catch (Exception e)
moLogFile.printStackTrace(e);
finally
mConnPool.free(pConn);
public static void main(String args[])
try
PTLFProcessor test=new PTLFProcessor("c:\\test.txt");
test.PTLFGetData();
catch (Exception e)
clsLogFile.printStackTrace(e);
}Here is the code with Normal statements
//package mps.mpsPTLF;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.Calendar;
import java.util.Date;
import gen.genCommon.genConnectionPool.*;
import gen.genCommon.*;
public class PTLFProcessor1
private static clsLogFile moLogFile = new clsLogFile("");
private gen.genCommon.genConnectionPool.SharedConnectionPool mConnPool = SharedConnectionPool.getInstance(2);
FileReader fPTLF = null;
BufferedReader brPTLF = null;
//**************** Begin Constructor declaration ************************
To intialize the class variables for new Fee
public PTLFProcessor1(String pathPTLF) throws GenException
try
fPTLF = new FileReader(pathPTLF);
brPTLF = new BufferedReader(fPTLF);
catch (Exception e)
throw new GenException("Error Accessing file : " + pathPTLF + " - " + e.toString(),e );
//**************** End Constructor declaration ************************
public void PTLFGetData() throws GenException
char pcData[];
int HEADERSIZE = 6;
boolean pbEndOfFile = false;
boolean pbisFirstBlock = true;
int piBlocksize = 0;
int piOffset = 0;
int piRecordsize = 0;
String psRecordContent = "";
Connection pConn = null;
int cnt=0;
try
String psInsSql=" INSERT INTO FILE_PTLF_IN ( " +
" fpi_DAT_TIM , " +
" fpi_REC_TYP , " +
" fpi_CRD_LN , " +
" fpi_CRD_FIID , " +
" fpi_CRD_NUM , " +
" fpi_MBR_NUM , " +
" fpi_MER_LN , " +
" fpi_MER_FIID , " +
" fpi_MER_GRP , " +
" fpi_MER_REGN , " +
" fpi_MER_ID , " +
" fpi_TERM_ID , " +
" fpi_SHIFT_NUM , " +
" fpi_BATCH_NUM , " +
" fpi_TERM_LN , " +
" fpi_TERM_FIID , " +
" fpi_TERM_ID_1 , " +
" fpi_TRAN , " +
" fpi_TERM_ID_2 , " +
" fpi_REC_FRMT , " +
" fpi_MER_ID_1 , " +
" fpi_CLERK_ID , " +
" fpi_DATA_FLAG , " +
" fpi_TYP , " +
" fpi_RTE_STAT , " +
" fpi_ORIGINATOR , " +
" fpi_RESPONDER , " +
" fpi_ISS_CDE , " +
" fpi_ENTRY_TIM , " +
" fpi_EXIT_TIM , " +
" fpi_RE_ENTRY_TIM , " +
" fpi_TRAN_DAT , " +
" fpi_TRAN_TIM , " +
" fpi_POST_DAT , " +
" fpi_ACQ_ICHG_SETL_DAT , " +
" fpi_ISS_ICHG_SETL_DAT , " +
" fpi_SEQ_NUM , " +
" fpi_TERM_NAME_LOC , " +
" fpi_TERM_OWNER_NAME , " +
" fpi_TERM_CITY , " +
" fpi_TERM_ST , " +
" fpi_TERM_CNTRY_CDE , " +
" fpi_BRCH_ID , " +
" fpi_USER_FLD2 , " +
" fpi_TERM_TIM_OFST , " +
" fpi_ACQ_INST_ID_NUM , " +
" fpi_RCV_INST_ID_NUM , " +
" fpi_TERM_TYP , " +
" fpi_CLERK_ID_1 , " +
" fpi_GRP , " +
" fpi_USER_ID , " +
" fpi_RETL_SIC_CDE , " +
" fpi_ORIG , " +
" fpi_DEST , " +
" fpi_TC , " +
" fpi_T , " +
" fpi_AA , " +
" fpi_C , " +
" fpi_CRD_TYP , " +
" fpi_ACCT , " +
" fpi_RESP_CDE , " +
" fpi_AMT_1 , " +
" fpi_AMT_2 , " +
" fpi_EXP_DAT , " +
" fpi_TRACK2 , " +
" fpi_PIN_OFST , " +
" fpi_PRE_AUTH_SEQ_NUM , " +
" fpi_INVOICE_NUM , " +
" fpi_ORIG_INVOICE_NUM , " +
" fpi_AUTHORIZER , " +
" fpi_AUTH_IND , " +
" fpi_SHIFT_NUM_1 , " +
" fpi_BATCH_SEQ_NUM , " +
" fpi_APPRV_CDE , " +
" fpi_APPRV_CDE_LGTH , " +
" fpi_ICHG_RESP , " +
" fpi_PSEUDO_TERM_ID , " +
" fpi_RFRL_PHONE , " +
" fpi_DFT_CAPTURE_FLG , " +
" fpi_SETL_FLAG , " +
" fpi_RVRL_CDE , " +
" fpi_REA_FOR_CHRGBCK , " +
" fpi_NUM_OF_CHRGBCK , " +
" fpi_PT_SRV_COND_CDE , " +
" fpi_PT_SRV_ENTRY_MDE , " +
" fpi_AUTH_IND2 , " +
" fpi_ORIG_CRNCY_CDE , " +
" fpi_AUTH_CRNCY_CDE , " +
" fpi_AUTH_CONV_RATE , " +
" fpi_SETL_CRNCY_CDE , " +
" fpi_SETL_CONV_RATE , " +
" fpi_CONV_DAT_TIM , " +
" fpi_IMP_IND , " +
" fpi_AVAIL_BAL , " +
" fpi_LEDG_BAL , " +
" fpi_AMT_ON_HOLD , " +
" fpi_TTL_FLOAT , " +
" fpi_CUR_FLOAT , " +
" fpi_ADJ_SETL_IMPACT_FLG , " +
" fpi_PBF1 , " +
" fpi_PBF2 , " +
" fpi_PBF3 , " +
" fpi_PBF4 , " +
" fpi_FRWD_INST_ID_NUM , " +
" fpi_CRD_ACCPT_ID_NUM , " +
" fpi_CRD_ISS_ID_NUM , " +
" fpi_ORIG_MSG_TYP , " +
" fpi_ORIG_TRAN_TIM , " +
" fpi_ORIG_TRAN_DAT , " +
" fpi_ORIG_SEQ_NUM , " +
" fpi_ORIG_B24_POST_DAT , " +
" fpi_EXCP_RSN_CDE , " +
" fpi_OVRRDE_FLG , " +
" fpi_ADDR , " +
" fpi_ZIP_CDE , " +
" fpi_ADDR_VRFY_STAT , " +
" fpi_PIN_IND , " +
" fpi_PIN_TRIES , " +
" fpi_PRE_AUTH_TS_DAT , " +
" fpi_PRE_AUTH_TS_TIM , " +
" fpi_PRE_AUTH_HLDS_LVL , " +
" fpi_USER_FLD5 , " +
" fpi_LEN , " +
" fpi_INFO )" +
" VALUES ";
( " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
pConn = mConnPool.getConnection();
Statement Stmt=pConn.createStatemenDear Sir,
The problem with the prepared statement is that it gets prepared once the compilation is over and the program is running in memory, what effectively this means is that at the compilation time the process of putting togather the statement has been discounted and while compiling , only the javac or compiler is in memory while at runtime the user input is required so streams are in memory and also the JVM and obviously your code.
Anyways java is a little slower than other languages and processes your code as and when user interacts with code so it is not the fastest it you want to make it perform calculations or accept user input or as in ur case prepareStatement.
your normal SQL statement is taken care of at compile time and is therefore faster.
regards,
[email protected] -
Charactersitic values to be used in IFTHEN ELSE STATEMENT IN QUERY
scenario: i need to use the characteristic values(not the attributes) to be used in an IF THEN ELSE STATEMENT in query. so i created a formula variable for the characteritic of processing type replacement path, replace with key.The values are not fetched in the result and is displayed as X.
what should i replace with key,lable, constant or other options whereas my requirement is the all the values present in the characteristc should be used.
eg. if char name is xyz and has the values 1,2,3,4,5 till -
20.
then in a calculated key figure :(formulavariable =1)* kefig1keyfig2 +not(formulavariable =1)kef2keyfig3.
this formula variable should have all the values of the characteristic values ie 1,2,3---20.
2. how should i do get the values of characterstics values in the equation give me the steps in detail..
3. i do not want to use the attributes, though i tried initally while creating the formual variable i replaced with attribute value, there is was an error and there were no reult.
i tried to create char. variable for the characteristic of manual entr , not ready for input values and gave all the values 1,2,3 --20 as default values and then created formaul variable and repalce with the variable, however this characteristic variable is not at all displayed from the list of variables which will be displayed while creating the formula variable.
help me out.
Thankshi srini,
i have includedthe char in rows. i want you to explain in detail how to use these values in the if then else statement in query.
i have created a calculated key figure 2= (formual variable =1 & keyfig a =0)* keyfig1kefig2 +not(formual variable =1 & keyfig a =0)keyfig2 *calculated keyfig1.
so this formula variable of replacement path have ref. to then char. and with what value should it replace, key, name, external char or attribut etc so that i should get the values of the char from 1 to20.
i donot to repalce with the attribute. i just want the char. values and not thier attributes (1. description 2. the second attribute has the values say abc1,efg2,ghi3 for respective charteristic values.
ie
char value desc 2nd attrib
1 hi abc1
2 bye defg2
3 ciao ghi3 -
IF ELSE statement / CMOD Code in BEX Query
Hi
I have a requirement in Inventory flow.
Material stock value at the end of each quarter has to be calculator based on cycle count indicator. I have all the values on my cube.
In the report, Calender year and quarter is on the selection screen.
When user enters 2014 and Q2, Data for April, May and June are displaying on the report. But user want data only for June.
At the end of quarter 2 is June, so he wants only Material stock value at the end of June.
If a material stock level is changed in April and May and not changed in June, not data is available for June in my Cube.
In this case for Quarter 2, if June data is missing, it has to look for May data. Even if MAY data is missing, it will have to look for April.
Even if April data is missing, it will have to look for March data.
The result should be
Plant Q1 Q2 Q3 Q4
XYZ 100 100 100 100
If there is no change to stock level in April, May & June - at the end of Quarter 2, the stock value should be 100 as it was in end of Q1.
If no change was dont to stock level until December, the stock level should be 100.
Is there a way out using IF ELSE statements or through CMOD customer exit.
Regards,
Elango MurgesanHI Elango,
the user input on CALQuarter always would be Single value??or can we expect ranges as well?
if single value,
then we can achieve it by having one more dummy KF.
lets say. user input is Q2.
-> in your dummy KF, restrict the Calquarter/Calmonth to last quarter(i.e Q1)using customer exit and make the logic as you said above(last value based on calmonth).(make this KF hidden, as this is not required to display)
-> and in another KF restricted with Q2.Same logic, last value on Calmonth.((make this KF hidden, as this is not required to display)
and now you have 2 KFs in your report. So in a formula, you can have condition-> if Q2 KF is blank, then Q1KF, else Q2 KF.
Hope you are getting my idea.. Please try this and let us know.
** if Q1 also null, then we can extend customer exit logic to may be last one year, and having last value on based on calendar month, we can still achieve i guess.
Regards,
Sakthi. -
How to use IF ELSE statement in one QUERY to MS ACCESS
System.out.println("Enter Final Exam: ");
int f = Integer.parseInt(input.readLine());
command.executeUpdate("UPDATE Students SET Final_Exam='"+f+"',Raw_score=(QT+MT+Final_Exam)/3 WHERE stud_name='"+stdID+"'");
command.executeUpdate("UPDATE Students SET Raw_score=(QT+MT+Final_Exam)/3 WHERE stud_ID='"+stdID+"'");
if (rsf==100)
command.executeUpdate("UPDATE Students SET Final_Grade=1.0 WHERE stud_ID='"+stdID+"'");
else if(rsf < 100 && rsf > 90)
command.executeUpdate("UPDATE Students SET Final_Grade=2.0 WHERE stud_ID='"+stdID+"'");
else
command.executeUpdate("UPDATE Students SET Final_Grade=5.0 WHERE stud_ID='"+stdID+"'");How can I shorten my code using a IF ELSE statement inside a single query or two? Or is it possible?
Edited by: ivatanako on Sep 28, 2007 11:55 PMSun has tutorial trail for JDBC, you might want to browse through that; you'll get more details and samples there than here. Here's the link to the section on PreparedStatement: http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
(Yes I know it's on JavaRanch but I think it applies everywhere)
---------------------------------------------------------------- -
Error msg in IF ELSE statement in jsp page, Need help
Below is my code I am trying to execute, but keep getting an error:
Compilation error occured:
Found 1 errors in JSP file:
D:\\http\\proFolder\\student.jsp:130: Syntax: "}" inserted to complete StatementNoShortIf
<%if (assess.getNumberValue() > 0) {%>
<%if ((assess.getTotalCost(appForm)) <= (assess.getNumberValue())) {%>
<strong><%=assess.getTotalCost(appForm)%></strong>
<%}%>
<%}%>
<%else {%>
<%=assess.getTotalCost(appForm)%>
<%}%>Basically, What I am trying to do is follow this logic:
IF method getNumberValue() is greater then 0, then execute the second IF statement that
is, If method getTotalCost() is less then or equal to getNumberValue() then display value of method getTotalCost()
End Second IF
End First IF
Now if the First IF fails ( that is getNumberValue() is not gether then 0)
then execute the else statement
Could someone please guide me what I am doing wrong, and what would be the correct way of write the IF else code
Thanks,<% if (assess.getNumberValue() > 0) {
if ((assess.getTotalCost(appForm)) <= (assess.getNumberValue())) {
%>
<strong><%=assess.getTotalCost(appForm)%></strong>
<%
%>
<%
else {
%>
<%=assess.getTotalCost(appForm)%>
<%
%>
Maybe you are looking for
-
How to connect my iPhone 4 to MBA 11" via Bluetooth?
how to connect my iPhone 4 to MBA 11" via Bluetooth?
-
Windows and itunes not recognising my ipod video
I bought my ipod video 30gb last thursday and i managed to get it working and downloade my songs to it. Now it is not recommended by windows, itunes or the device manager what can i do?
-
No of days caluculation in report
hai all i am working on Customer aging report in this report i need to calculate no of days, no of days i should get in days in numeric value report running date ( subtract ) due date for example current report running date : 28.07.2006 due date
-
When trying to installing or uninstall quicktime error 2738 comes up Have registered VBScript as per instructions suscessfully but still get error Can anyone help Running Vista
-
Hello colleagues, I have this error when start the Content Server, host:(/directory/apache/bin)(root)#./apachectl start httpd: Syntax error on line 66 of /directory/apache/conf/httpd.conf: Cannot load modules/mod_sapcs22.so into server: /directory/ap