Boolean return value & security aspect

Again in the JCOP specification I read these lines:
In case the Java Card API method returns the boolean value, it should be immediately transferred to a short representation. Now I am having this part of the code:
boolean status = false;
          status = pin.check(buffer, (short) OFFSET_CDATA, (byte) lc);
          crypto.updateCIAPinByP2(p2, pin);
          if (!status) {
               ISOException.throwIt((short) (ISO7816Ext.SW_PIN_INCORRECT_TRIES_LEFT | pin
                         .getTriesRemaining()));
          }Is this optimal regarding to the lines at the beginning of the post. Do I need to do this:
          boolean ret = pin.check(buffer, (short) OFFSET_CDATA, (byte) lc);
          short status = ret ? (short) 0xA5A5; (short) 0x5A5A
          crypto.updateCIAPinByP2(p2, pin);
          if (status == (short) 0x5A5A) {
               ISOException.throwIt((short) (ISO7816Ext.SW_PIN_INCORRECT_TRIES_LEFT | pin
                         .getTriesRemaining()));
          }Also, the specification says that to ensure the security of the system, variables of type Boolean should not be used for storing security relevant data. Instead a short value should be used and a constant for True and a constant for the False. Should be defined and used. It is also said that these short values, representing Boolean values, shall be checked for the integrity in any kind of branching which would have an impact on security function. My question why is that so? Regarding to this text, do I need to modify anything in the first code because the returned variable is the local which value is stored in RAM?

In the code from the first post, in order to have the most secure code, I believe that I need to implement double check of PIN value:
public static final short TRUE = (short) 0xA5A5;
public static final short FALSE = (short) 0x5A5A;
status = pin.check(buffer, (short) dataOffset, (byte) lc) == true ? IASECCUtil.TRUE : IASECCUtil.FALSE;
if(status == IASECCUtil.TRUE) {
     status = pin.check(buffer, (short) dataOffset, (byte) lc) == true ? IASECCUtil.TRUE : IASECCUtil.FALSE;
}In this example, if at the first line, the result of the method check() is false but the fault occurs on the bus (transient fault) between the RAM and CPU register, then the program flow will be able to reach the second line that contains the check. The double check will not be affected by a second fault because the time to charge the laser is much larger. Is this correct?

Similar Messages

  • Boolean return value

    public boolean isFull(){  //generally full
             if(parcelIsFull() || hcparcelIsFull() || noSharingParcel())
                  return true;
        }I want to know why i get this error missing return statementI have the value written as 'true' boolean as the returning value.

    Nickd...... wrote:
    parcelIsFull()
    hcparcelIsFull()
    noSharingParcel()
    All these are boolean values. What i am trying to do is if any of them is true, then return true.
    But i still dont understand why it is giving me errorsIt's the
    return true;
    that's the problem.
    You must make sure that every logical paths through the method ends with a return statement. In your case it doesn't if
    if(parcelIsFull() || hcparcelIsFull() || noSharingParcel())
    is false. So add
    return false;
    just before the method ends.
    Or, as an experience programmer would, do this instead,
    return parcelIsFull() || hcparcelIsFull() || noSharingParcel();

  • Query Formula with boolean return values

    Hi,
    In my query, I have a  formula column which returns a boolean value 0 or 1. I need to add these values, but I cannot add them as boolean.  Is there a way that I could convert the boolean values to number/integer so I can add them?
    Thanks in advance
    Best Regards,
    Rose

    Hi Rose,
    please change 'Calaculate Result as' in properties of affected formula to 'Summation'.
    If this sould not help put formula in brackets and multiply by value 1 or create a new formula like
    (yourformula = 0 + yourformula = 1) * 1
    this should provide an integer.
    Regards
    Joe

  • Getting Return values from RFC function call with visual basic

    Hi,
    I am creating a sample app to connect to a SAP system which call its RFC functions created with ABAP. It was known that the function will return more than 1 return values.
       SAP Function name ==> "ZFMTP_RFC_GET_RESULT"
            Export parameters (to SAP):
                    - Student Name [char 10]         ==> "STUNAME"
                    - Student ID         [char 20]        ==> "STUID"
           Return values (From SAP):
                    - Results [char 10]        ==> "RESULT"
                    - Remarks [char 200]        ==> "REMARKS"
    i have managed to get sample codes for connecting and call a RFC function with vb but they only get a return value. How do i retrieve multiple return values like the above function "RESULT" and "REMARKS"?
    Here's my vb code to accessing the function
            Dim R3 As Object
            Dim FBFunc As Object
            Dim returnFunc As Boolean
            Dim connected As Boolean
            R3 = CreateObject("SAP.Functions")
            R3.Connection.Client = "000"
            R3.Connection.User = "BCUSER"
            R3.Connection.Password = "minisap"
            R3.Connection.Language = "DE"
            R3.Connection.System = "dtsystem"
            R3.Connection.Applicationserver = "xxx.xxx.xxx.xxx" 
            connected = R3.Connection.Logon(0, True)
            If connected <> True Then
                MsgBox("Unable to connect to SAP")
            End If
            FBFunc = R3.add("ZFMTP_RFC_GET_RESULT")
            FBFunc.exports("STUNAME") = "Jonny"
            FBFunc.exports("STUID") = "12345"
            returnFunc = FBFunc.Call() <<== How do i get the return value? or RESULT and REMARKS of the RFC Function?
    thanks alot.
    Edited by: Eugene Tan on Mar 4, 2008 7:17 AM

    Hi Gregor,
    Thanks for the link....i am having some doubts with the codes, hope you can clarify them for me if you know the codes..
    Below is the code snippet.
    Set impReturn = CHPASS_FN.Imports("RETURN")  <<=== is RETURN the standard keyword to get a                                                                                return object?
      expPassword.Value = currpass
      expNewPass.Value = newpass
      expFillRet.Value = "1"
    ''' Call change password function
      If CHPASS_FN.Call = True Then
        outFile.Write (", Called Function")
        Message = impReturn("MESSAGE") <<==== So if i have 3 return values..i just replace with the return                                                               value variable names?
        outFile.WriteLine " : " & Message
      Else
        outFile.Write (", Call to function failed")
      End If
    thanks alot...all your help is very appreciated.

  • How to set the returned value of CFL in a matrix

    dear all,
    I got a matrix binded to a DataSource and two CFLs are in this matrix. The codes for handling AfterChooseFromList is as following.  It works almost fine. But when a docoment containing more than two
    rows in the matrix and I reselect the CFL cell values more than two times, an error occured sometimes, not everytime. The error message is "This entry already exists in the following tables @CYW_PRROW [Message 131-183]"
    I have tried to find out what kind of situation to cause this error, but still in the mud.
    Can anybody give me some suggestion? Thanks.
    Public Sub OnAfterChooseFromList_Matrix(ByVal pVal As SAPbouiCOM.ItemEvent)
            Dim ActionSuccess As Boolean = pVal.ActionSuccess
            Dim oform As SAPbouiCOM.Form = SBO_Application.Forms.Item(pVal.FormUID)
            Dim oitem As SAPbouiCOM.Item = oform.Items.Item("mtx_0")
            Dim omatrix As SAPbouiCOM.Matrix = CType(oitem.Specific, SAPbouiCOM.Matrix)
            Dim oDataTable As SAPbouiCOM.DataTable
            oDataTable = pVal.SelectedObjects
            Dim val As String
            Try
                val = oDataTable.GetValue(0, 0)
            Catch ex As Exception
            End Try
            omatrix.GetLineData(pVal.Row)
            oform.DataSources.DBDataSources.Item("@CYW_PRROW").Offset = pVal.Row - 1
            If pVal.ColUID = "col_0" Then
                Try
                    oform.DataSources.DBDataSources.Item("@CYW_PRROW").SetValue("U_PRItemCode", pVal.Row - 1, CStr(val))
                Catch ex As Exception
                    SBO_Application.MessageBox(ex.Message)
                End Try
            Else
                Try
                    oform.DataSources.DBDataSources.Item("@CYW_PRROW").SetValue("U_PRSupp", pVal.Row - 1, CStr(val))
                Catch ex As Exception
                    SBO_Application.MessageBox(ex.Message)
                End Try
            End If
            omatrix.SetLineData(pVal.Row)
            If pVal.FormMode = "1" Then
                oform.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE
            End If
        End Sub
    Another quesion, can I assign the returned value of CLF directly to the cell?

    Hello  Chao-Yi Wu,
    I don't have a real solution for you - just a few comments:
    1. At
            Try
                val = oDataTable.GetValue(0, 0)
            Catch ex As Exception
            End Try
    I would add
            Try
                if oDataTable Is Nothing Then Exit Sub ' If the User cancels the CFL
                val = oDataTable.GetValue(0, 0)
            Catch ex As Exception
            End Try
    2. At
       If pVal.ColUID = "col_0" Then
    I would make the branch by the pVal.ChooseFromListUID instead of the ColUID
    and the 2nd not with "Else" but with "Else If ....."
    3. It may work with EditText.String/Value of a cell but I never do that because of performance-reasons.
    I always do it the same way as you in principle - I don't really know what the problem is.
    4. Maybe some unique indexes on your table (although this should give an error at the update and not at CFL when "the unique-law is broken"...)?
    Sorry - that's all for the moment.
    Cheers,
    Roland

  • Operations Manager Installation Error - Return Value 3

    Hello, I am having issues installing Operations Manager Reporting 2007 R2. The installation hangs with no status update a little more then midway through. I am receiving the following exception below. I am trying to install this on a named reporting instance.
    013-12-16T16:00:00.0547063-08:00 Debug:
     *** Trace Started ***
    2013-12-16T16:00:00.0859563-08:00 Debug:
    ConfigureOverridesForDWRules: Root Management Server is: CORP32-VS
    2013-12-16T16:30:01.7422063-08:00 Error:
    ConfigureOverridesForDWRules error: System.TimeoutException : The requested operation timed out.
    Exception thrown by custom action:
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.WindowsInstaller.InvalidHandleException: The handle is invalid.
       at Microsoft.WindowsInstaller.SessionProperties.set_Item(String name, String value)
       at Microsoft.Reporting.Setup.ReportingManagedCAs.ConfigureOverridesForDWRules(Session session)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
       at Microsoft.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint)
    CustomAction _ConfigureOverridesForDWRules.9B663534_CD9B_41CC_9D93_4E84D3C5E165 returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
    MSI (s) (1C:FC) [16:30:01:804]: NOTE: custom action _ConfigureOverridesForDWRules.9B663534_CD9B_41CC_9D93_4E84D3C5E165 unexpectedly closed the hInstall handle (type MSIHANDLE) provided to it. The custom action should be fixed to not close that handle.
    Action ended 16:30:01: InstallFinalize. Return value 3.
    MSI (s) (1C:80) [16:30:01:804]: User policy value 'DisableRollback' is 0
    MSI (s) (1C:80) [16:30:01:804]: Machine policy value 'DisableRollback' is 0
    MSI (s) (1C:80) [16:30:01:882]: Executing op: Header(Signature=1397708873,Version=500,Timestamp=1133543036,LangId=1033,Platform=589824,ScriptType=2,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=1)
    MSI (s) (1C:80) [16:30:01:882]: Executing op: DialogInfo(Type=0,Argument=1033)
    MSI (s) (1C:80) [16:30:01:882]: Executing op: DialogInfo(Type=1,Argument=System Center Operations Manager 2007 R2 Reporting Server)
    MSI (s) (1C:80) [16:30:01:882]: Executing op: RollbackInfo(,RollbackAction=Rollback,RollbackDescription=Rolling back action:,RollbackTemplate=[1],CleanupAction=RollbackCleanup,CleanupDescription=Removing backup files,CleanupTemplate=File: [1])
    Action 16:30:01: Rollback. Rolling back action:

    Niki,
    I verified the data warehouse SQL server authentication account is indeed blank. I just tried running the installation again and received the following errors in the SQL log.
    12/18/2013 07:43:28,spid177,Unknown,Error 777970008<c/> severity 16<c/> state 1 was raised<c/> but no message with that error number was found in sys.messages. If error is larger than 50000<c/> make sure the user-defined message is
    added using sp_addmessage.
    12/18/2013 07:43:28,spid177,Unknown,Error: 18054<c/> Severity: 16<c/> State: 1.
    12/18/2013 07:43:28,spid88,Unknown,Error 777970008<c/> severity 16<c/> state 1 was raised<c/> but no message with that error number was found in sys.messages. If error is larger than 50000<c/> make sure the user-defined message is added
    using sp_addmessage.
    12/18/2013 07:43:28,spid88,Unknown,Error: 18054<c/> Severity: 16<c/> State: 1.
    12/18/2013 07:43:28,spid173,Unknown,Error 777970008<c/> severity 16<c/> state 1 was raised<c/> but no message with that error number was found in sys.messages. If error is larger than 50000<c/> make sure the user-defined message is added
    using sp_addmessage.
    12/18/2013 07:43:28,spid173,Unknown,Error: 18054<c/> Severity: 16<c/> State: 1.
    12/18/2013 07:43:18,spid173,Unknown,Error 777970008<c/> severity 16<c/> state 1 was raised<c/> but no message with that error number was found in sys.messages. If error is larger than 50000<c/> make sure the user-defined message is added
    using sp_addmessage.
    12/18/2013 07:43:18,spid173,Unknown,Error: 18054<c/> Severity: 16<c/> State: 1.
    12/18/2013 07:43:15,spid13s,Unknown,AppDomain 9702 (OperationsManager.dbo[ddl].9701) unloaded.
    12/18/2013 07:43:14,spid21s,Unknown,AppDomain 9701 (OperationsManager.dbo[ddl].9700) unloaded.
    Also, please see error in the MOMReporting log below:
    2013-12-18T07:41:54.8239565-08:00 Debug: ConfigureOverridesForDWRules: Root Management Server is: COR32
    2013-12-18T08:11:56.1874277-08:00 Error: ConfigureOverridesForDWRules error: System.TimeoutException : The requested operation timed out.
    Exception thrown by custom action:
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.WindowsInstaller.InvalidHandleException: The handle is invalid.
       at Microsoft.WindowsInstaller.SessionProperties.set_Item(String name, String value)
       at Microsoft.Reporting.Setup.ReportingManagedCAs.ConfigureOverridesForDWRules(Session session)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
       at Microsoft.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint)
    CustomAction _ConfigureOverridesForDWRules.9B663534_CD9B_41CC_9D93_4E84D3C5E165 returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
    MSI (s) (38:4C) [08:11:56:281]: NOTE: custom action _ConfigureOverridesForDWRules.9B663534_CD9B_41CC_9D93_4E84D3C5E165 unexpectedly closed the hInstall handle (type MSIHANDLE) provided to it. The custom action should be fixed to not close that handle.
    Action ended 8:11:56: InstallFinalize. Return value 3.
    MSI (s) (38:6C) [08:11:56:359]: User policy value 'DisableRollback' is 0
    MSI (s) (38:6C) [08:11:56:359]: Machine policy value 'DisableRollback' is 0
    MSI (s) (38:6C) [08:11:56:624]: Executing op: Header(Signature=1397708873,Version=500,Timestamp=1133657144,LangId=1033,Platform=589824,ScriptType=2,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=1)

  • Trying to write an if statement around the return value of a CANCEL_OPTION

    I am writing a program that takes an input String using JOptionPane. The String can be made of only letters of the A-Z alphabet and the space character. I have written an error-checking loop that will pop another input box up along with an error message if any invalid character is detected. The input box has an 'ok' button and a 'cancel' button. As it is, if you hit cancel, the program crashes and you get a NullPointerException. All I want to do is place an if statement inside of the error-checking loop, immediatly after the code to pop up the second input box, that simply does System.exit() and exits the program correctly(rather than crashing) if 'cancel' is clicked.
    My attempt at such an if statement is visible in the following code(letter is a boolean variable defined earlier, and message is the input String that has already been read in):
                   letter = isValidMessage(message);
              while(!letter)
                   message = JOptionPane.showInputDialog(null, "Message must contain only A-Z, a-z, or space character...");
                            if(JOptionPane.CANCEL_OPTION > 0  //or ==0 or ==1 or ==2, nothing works//)
                                JOptionPane.showMessageDialog(null, "No valid message entered - program will terminate...");
                                System.exit(JOptionPane.CANCEL_OPTION);
                   letter = isValidMessage(message);
                    }The if statement doesn't work correctly. If you click 'cancel' when the input box comes up, the program does terminate as it is supposed to. The problem is that if I type something in the box and click 'ok', it also causes the program to terminate rather than continuing. I've tried changing the > to ==. I've tried changing 0 to 1 to 2 to -1(I really am not sure which int return value of CANCEL_OPTION corresponds to which event). I think once I got to do the exact opposite...that is to say, it would continue on with the program whether I clicked 'cancel' or 'ok'. Which is equally bad. I don't know what I'm doing wrong.
    It's probably something simple that I'm just overlooking.

    Well, here's what CANCEL_OPTION is, according to the JOptionPane class:
    /** Return value from class method if CANCEL is chosen. */
        public static final int         CANCEL_OPTION = 2;However, I believe you're going about this in the wrong way.
    With JOptionPane, whenever you show a dialog, it usually returns whatever OPTION the user chose.
    For instance,
        int choice = JOptionPane.showConfirmDialog(parentComponent, "hello");That will bring up a dialog centered on parentComponent, with a message of "hello".
    It will have the default options (YES_NO_OPTION).
    What it returns is the option the user chose.
    There are 4 possible things it can return:
    YES_OPTION, when user clicks "Yes"
    NO_OPTION, when user clicks "No"
    ERROR_OPTION, when an unforseen error occurs and the dialog closes
    CANCEL_OPTION, when the user clicks "Cancel" (if that OPTION type were being used), or if they close the dialog
    So this is how you would check for CANCEL_OPTION:
        int choice = JOptionPane.showConfirmDialog(parentComponent, "hello");
        if (choice == JOptionPane.CANCEL_OPTION) {
            // User cancelled
        else if (choice == JOptionPane.YES_OPTION) {
            // User chose yes
        // EtcSo you see, going about it like this:
    if(JOptionPane.CANCEL_OPTION > 0  //or ==0 or ==1 or ==2, nothing works//)Is really the wrong way, because you're not checking what the user DID, but just what the constant variable "CANCEL_OPTION" is.
    However, it seems as if you're in a unique situation where you don't want the OPTION chosen by the user, but an input String.
    This is all well and good, but I think this limits how you can interact with the user, as the "showInputDialog" methods return the String the user input- not the OPTION they chose, and you need to use both.
    What I've done in the past is created a simple JPanel with its own JTextField.
    I pass the JPanel in as the "message" parameter of a showConfirmDialog call, and get both the user input and their chosen OPTION based off a getText call to the JTextField and the OPTION constant returned by showConfirmDialog.
    Basically,
    JPanel promptPanel = new JPanel(new BorderLayout());
    JTextField promptField = new JTextField();
    promptPanel.add(promptField, BorderLayout.CENTER);
    int choice = JOptionPane.showConfirmDialog(parentComponent, promptPanel, "Input", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (choice == JOptionPane.OK_OPTION) {
       // User chose OK, see if invalid characters were entered
       String input = promptField.getText();
    else if (choice == JOptionPane.CANCEL_OPTION) {
       // User cancelled
    }Hope that helps.
    (note that I'm unsure if showConfirmDialog can accept OK_CANCEL_OPTION as its OPTION parameter, as it says only YES_NO_OPTION and YES_NO_CANCEL_OPTION can be used, but I seem to remember using it in the past. if OK_CANCEL_OPTION doesn't want to work, then use one of the other two and adjust your if statements accordingly)
    Cheers!
    Edited by: LukeFoss on Oct 9, 2007 10:39 PM

  • Problem with return value of stored function

    Hi,
    I've made a stored function that insert a new row in a table and return the primary key (see at the end of the message the function script).
    In VS 2005 with Visual basic, using the designer, I've created a dataset containing a tableAdapter to be able to use the Pl/SQL function.
    My problem is I can't get the proper return value. The VB code below works without error except that I get 0 as value.
    What's wrong?
    Cheers,
    Sebastien
    VB code
    Dim myAddSession As New ICISDataSetTableAdapters.AddSessionTableAdapter
    Dim intSessionId As Integer
    intSessionId = myAddSession.ADD_SESSION(tbxUsername.Text, _
    tempFolder.Substring(tempFolder.LastIndexOf("\") + 1), _
    "toto", Environment.GetEnvironmentVariable("COMPUTERNAME"), _
    myLevelAccess.icisUserId, myLevelAccess.levelId)
    The debugger tells me that the ADD_SESSION function return value is Object.
    add_session PL/SQL script:
    CREATE OR REPLACE FUNCTION ICISSEC.add_session (
    orausername IN icis_session.ora_user_name%TYPE,
    ctxsessionid IN icis_session.ctx_session_id%TYPE,
    ctxsessionname IN icis_session.ctx_session_name%TYPE,
    ctxservername IN icis_session.ctx_server_name%TYPE,
    icisuserid IN icis_session.icis_user_id%TYPE,
    startlevelid IN icis_session.start_lvl_id%TYPE
    RETURN icis_session.ICIS_SESSION_ID%TYPE
    IS
    tmpvar icis_session.ICIS_SESSION_ID%TYPE;
    BEGIN
    INSERT INTO icis_session
    (ora_user_name, ctx_session_id, ctx_server_name,
    icis_user_id, start_lvl_id, ctx_session_name
    VALUES (orausername, ctxsessionid, ctxservername,
    icisuserid, startlevelid, ctxsessionname
    RETURNING icis_session_id
    INTO tmpvar;
    COMMIT;
    RETURN tmpvar;
    EXCEPTION
    WHEN OTHERS
    THEN
    RAISE;
    END add_session;

    naama wrote:
    that if a value is null to convert it to 0 ? . i mean in the part of the declaration of parameter
    Nope, can't do that in the signature. You'll need to handle that by validating the passed parameters at the start of the function.
    It's simple enough. In your case you might just as well test for NULL and fail the function like this:
        FUNCTION date_post_message(
                user_lock_in IN NUMBER,
                form_type_in IN NUMBER DEFAULT 0 ,
                date_in      IN DATE)
            RETURN BOOLEAN
        IS
            v_num NUMBER(1);
        BEGIN
            dbms_output.put_line('Value of parameters : user_lock_in : '||user_lock_in || ' : form_type_in : '||form_type_in||' : date_in : '||date_in );
            IF user_lock_in = 1 THEN
                RETURN FALSE;
            END IF;
            IF form_type_in IS NULL THEN
                RETURN FALSE;
            ELSIF form_type_in NOT IN (1,2) THEN
                RETURN FALSE;
            END IF;
            RETURN TRUE;
        EXCEPTION
        WHEN NO_DATA_FOUND THEN
            RETURN FALSE;
        END;In other use cases I would declare a local variable and process it like this:
            IF form_type_in IS NULL THEN
                l_form_type := 0;
            ELSE
                 l_form_type := form_type_in;
            END IF;Obviously the code should use the local variable rather than the parameter.
    Validating the values passed in parameters at the start of a function is good practice. If you really want to go to town, read about Design By Contract.
    Cheers, APC
    Edited by: APC on Nov 9, 2011 1:36 PM
    Added example, as requested by OP

  • Formatting the return value of: File(myFile).lastModified()

    I'm checking file date and time stamps:
    myDate = File(myFile).lastModified()Is there a way to format the return value?
    myDate equals: 1205166439145I'd like to see something like:
    03/10/2008  12:27 PMI'm using the following code to print the value:
    System.out.println(myDate);

    Awesome! I really, really appreciate the help and the sample code!
    Successful Output:
    K:\COMMON\ITS\STEVEB\java\CompareFileDates>java CompareFileDates
    execution continuing...
    test1.steve (3/10/08 12:27 PM) is older than test2.steve (3/10/08 1:33 PM)Error free code:
    import java.io.File;
    import java.lang.Object;
    import java.util.Date;
    import java.text.Format;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    public class CompareFileDates {
      public static void main(String[] args) {
        String file1_stat = null;
        String file2_stat = null;
        String file1 = "test1.steve";
        String file2 = "test2.steve";
        long date1 = 0;
        long date2 = 0;
        String finalDate1 = null;
        String finalDate2 = null;
        boolean file1Exists = (new File(file1)).exists();
        if (file1Exists) {
            // File or directory exists
            file1_stat = "does exist";
            // Get the timestamp from file 1 and format it
            date1 = (new File(file1)).lastModified();
         Date newDate1 = new Date(date1);
         DateFormat df = new SimpleDateFormat();
         finalDate1 = df.format(newDate1);
         //System.out.println(file1 + " date: " + finalDate1);
        else {
            // File or directory does not exist
            file1_stat = "does not exist";
        boolean file2Exists = (new File(file2)).exists();
        if (file2Exists) {
            // File or directory exists
            file2_stat = "does exist";
            // Get the timestamp from file 2 and format it
            date2 = (new File(file2)).lastModified();
         Date newDate2 = new Date(date2);
         DateFormat df = new SimpleDateFormat();
         finalDate2 = df.format(newDate2);
         //System.out.println(file2 + " date: " + finalDate2);
        else {
            // File or directory does not exist
            file2_stat = "does not exist";
        if ((file1Exists == false) || (file2Exists == false)) {
                System.out.println("aborting program...");
        else { 
           System.out.println("execution continuing...");
           String relation;
           if (date1 == date2)
             relation = "the same age as";
           else if (date1 < date2)
             relation = "older than";
           else
             relation = "newer than";
           System.out.println(file1 + " (" + finalDate1 + ")" + " is " + relation + ' ' + file2 + " (" + finalDate2 + ")");
    }

  • Double Quotes In LOV Return Value Being Replaced With &qu ot; By APEX 4

    My company recently upgraded our development and test boxes to APEX 4.0.2, which we have been wanting for a while now. We discovered that since the upgrade some of our checkboxes and radio groups no longer work as expected. What I mean by this is that the return values being checked for were not correct, and on several occasions we received PL/SQL errors related to numeric to character conversion issues.
    After debugging some it turns out that we have the following LOV query for one of our Checkboxes:
    select
    statement d,
    stmt_id || '" title="&P20_FORM_STMT. ' || statement || '.' r
    from
    stmts
    The return value for the LOV is setup so that it would return a 508 compliant checkbox. We were told we needed a title for each value of a checkbox or radio group to be 508 compliant. These titles must also be relevant to the selection being made, hence the substitution string being used in the return value.
    What I discovered in all of this is that APEX 3.2 did not convert the double quotes in our return value to &qu ot;, but APEX 4.0.2 does. This causes the value of any given checkbox or radio group to look like the following:
    value="1&qu ot; title=&qu ot;This is the statement that I have made."
    And what we are looking for, and what APEX used to do is this:
    value="1" title="This is the statement that I have made."
    Does anyone know a way to prevent APEX from converting the double quotes to &qu ot;, or is there a way to insert an element attribute for each checkbox or radio group value that contains a substitution string?
    Thanks in advance!
    Pastey

    ryansun wrote:
    4.2.1
    Hi,
    I have a classic report, which has a count column that is hyperlinked. using the standard apex column hyperlink option. In that we have the option of passing values. I noticed that when I am passing a value which has "/" in it, it replaces the / with & #x2F;
    I have created a application item which I am populating with the report column.
    Because of which I cannot use that value in the report query.
    Any suggestions?Yes. Don't pass string values in URLs. Especially where it is possible for these strings to contain URI reserved or APEX sensitive characters. This might work for a while but your application can be broken months from now by users including a "&" or ":" in data that gets passed as a URL parameter. Whilst it is possible to escape strings to make them URL- and APEX parameter-safe, it is much better practice to avoid the problem altogether.
    Exposing data in the URL may also introduce security vulnerabilities. Also note that the maximum length of a URL in Microsoft Internet Explorer is about 2KB, which can easily be exceeded by throwing a few string values at it.
    Only use discrete alphanumeric key values as URL parameters. In target pages/regions, use these key values to retrieve the required data using item source attributes and processes.

  • Not able to get Oracle stored procedure return value passed to Powerbuilder

    I have an Oracle Stored Procedure that receives a string value and returns a string value..  When I call it from Powerbuilder, it executes but does not send the return value of a string back.  I am trying to encrypt a string in Powerbuilder, pass it to a .net web page and then decrypt so I can check the security tables for permissions to view the web page.  I have tried creating a simple stored procedure that takes a string and returns a string to Powerbuilder; but even that is not working.  Any suggesstions?
    Oracle Procedure:
    CREATE OR REPLACE
    PROCEDURE               TESTINOUT_VARCHAR
    ( P_STRING IN VARCHAR2, P_OUT OUT VARCHAR2)
    IS
       BEGIN  
          P_OUT := P_STRING || 'TESTING';
    END TESTINOUT_VARCHAR;
    Powerbuilder Call:
    string p_string ='                                 '
    Declare TestingString procedure for TESTINOUT_VARCHAR(:ls_group, :p_out) using SQLCA
    Execute TestingString;
    IF SQLCA.CODE = 0 THEN
    FETCH TestingString into:p_out;
    End If
    p_string = p_out;

    Hello John,
    I'm not sure if you already found a solution using an ODBC connection.
    Below the solution with an RPC call:
    Create a user object (uo_trans) of type transaction with the following local external function:
    subroutine TESTINOUT_VARCHAR(string P_STRING,ref string P_OUT) RPCFUNC
    Execute this script
    uo_trans l_transaction
    string ls_outparam
    l_transaction = CREATE uo_trans
    // Profile ODBC_ORA
    l_transaction.DBMS = "ODBC"
    l_transaction.AutoCommit = False
    l_transaction.DBParm = "ConnectString='DSN=ODBC_ORA;UID=system;PWD=<xxxxxx>'"
    connect using l_transaction;
    ls_outparam = space (30)
    l_transaction.testinout_varchar( sle_1.text, ls_outparam)
    messagebox("OUT parameter", ls_outparam)
    disconnect using l_transaction;
    DESTROY l_transaction

  • Use of boolean returning functions in a project

    Hello all gurus,
    in my project, we have a fairly important packaged functions that return boolean values. Working with these ones in pl/sql is very fine. But sometimes we need to reuse these functions in SQL, but no luck because bools are usable under pl/sql only and can't interact in any way in SQL statements. So the workaround should be to use these functions to return us some Y/N or 1/0 to emulate boolean behavior in SQL statements.
    Here what i tested with not luck:
    -- not work
    select r.role, sys.diutil.bool_to_int(dbms_session.is_role_enabled(r.role)) as is_role_enabled
    from   dba_roles r;
    -- not work
    select r.role
    from   dba_roles r
    where  sys.diutil.bool_to_int(dbms_session.is_role_enabled(r.role)) = 1;
    -- not work
    select t1.id,
           bool_to_char(my_bool_func(t1.x, t1.y, ...)) as is_something
    from   t1;
    -- not work
    select t1.id,
           sys.diutil.bool_to_int(my_bool_func(t1.x, t1.y, ...)) as is_something
    from   t1;The odd wrapping trick as a last resort solution is working....
    -- Works! Seems the only way, but a lot of wrapping work...
    create or replace function my_bool_func_wrap(p_x number, p_y number, ...) return varchar2 as
    begin
       return bool_to_char(my_bool_func(p_x, p_y, ...));
    end;
    select t1.id,
           my_bool_func_wrap((t1.x, t1.y, ...)) as is_something
    from   t1;I read a lot, but no elegant and working way.
    Is there a more standard, elegant universal way to call bool functions from SQL?
    Is creating a custom type visible and usable from both pl/sql and sql, if possible, a way to go?
    Any other pointers?
    For new development, is it good to make my boolean type returning functions using SQL compatible type like CHAR (Y/N) or NUMBER (1/0) ? It will make us less wrapping job, but more and less elegant bool handling code on the pl/sql side.
    What is the goal to have bool only in pl/sql and not usable in SQL? It's kind of a feature incompatibility in the same product. Strange...
    Thanks a lot
    Bruno

    brlav wrote:
    Finally, I'll have to dump the BOOLEAN return type to all our boolean functions and return char instead. With this I will be able to call then from SQL.... From this perspective, BOOLEAN is useless.I would not say that. Let's assume that you implement boolean in SQL as a single byte character string containing either Y or N, enforce that with a constraint and also add a not-null constraint to it.
    You simply define two PL functions (not usable from SQL) that deals with the conversion. You use the one function to change boolean to char before hitting the SQL engine, and the other to convert char to boolean when getting data from the SQL engine.
    As I/O routines are modularised, it means that you need to deal with these conversions once only when writing and once only when reading (per module).
    Simple example:
    SQL> create or replace function to_bool( c varchar2 ) return boolean is
      2  begin                                                            
      3          return( c = 'Y' );                                       
      4  end;                                                             
      5  /                                                                
    Function created.
    SQL>
    SQL> create or replace function bool_to_char( b boolean ) return varchar2 is
      2  begin
      3          if b then
      4                  return( 'Y' );
      5          else
      6                  return( 'N' );
      7          end if;
      8  end;
      9  /
    Function created.
    SQL>
    SQL> declare
      2          i       integer;
      3          b       boolean;
      4          flag    all_tables.temporary%type;
      5          tab     all_tables%rowtype;
      6  begin
      7          flag := bool_to_char(true);  
      8          select count(*) into i from all_tables where temporary = flag;
      9
    10          select t.* into tab from all_tables t where rownum = 1;
    11          b := to_bool( tab.temporary );
    12  end;
    13  /
    PL/SQL procedure successfully completed.
    SQL>

  • Calling a BOOLEAN returning function from SQL

    Hello All,
    I have created below function which return BOOLEAN value :
    CREATE OR REPLACE FUNCTION FUNC_1
    P_EMPID IN emp.empno%type
    )RETURN BOOLEAN
    AS
    L_VAR NUMBER;
    BEGIN
    SELECT 1 INTO L_VAR
    FROM EMP
    WHERE EMPNO = P_EMPID;
    IF L_VAR = 1 THEN
    RETURN TRUE;
    ELSE
    RETURN FALSE;
    END IF;
    END;Now I want to call this function from SELECT but I know that SQL does not support BOOLEAN value so I tried in other way i.e. via CASE
    SELECT CASE FUNC_1(7788)
           WHEN TRUE THEN 'TRUE'
           WHEN FALSE THEN 'FALSE'
           ELSE 'NULL'
           END CASE
    FROM DUALBut it is giving me error "ORA-00904: "FALSE": invalid identifier'
    How can I achieve this ?
    Thanks & Regards,
    Rakesh

    Hi Rakesh,
    Why cant you try something like this, When BOOLEAN type is not supported in SQL.
    Here I have made the return value a number. And, at case comparison, we get the BOOLEAN
    result as TRUE of FALSE.
    CREATE OR REPLACE FUNCTION func_1 (p_empid IN emp.empno%TYPE)
       RETURN NUMBER
    AS
       l_var   NUMBER;
    BEGIN
       SELECT count(*)
         INTO l_var
         FROM emp
        WHERE empno = p_empid;
       IF l_var = 1
       THEN
          RETURN 1;
       ELSE
          RETURN 0;
       END IF;
    END;And,
    SELECT CASE func_1 (55656)
              WHEN 1
                 THEN 'TRUE'
              WHEN 0
                 THEN 'FALSE'
           END
      FROM DUAL;Which return TRUE if the Employee Number Exists and FALSE if doesnot.
    Thanks,
    Shankar.

  • Return value for Direct OBPM SQL Query in OBPM 10GR3

    Hi all,
    I use a direct SQL Query provided by OBPM 10GR3 in my automatic activity to select certain elements from the db. The query is as follows:-
    foreach (element in
    SELECT id FROM TESTTABLE WHERE requestId = 732 and status = 1 )
    // statements
    logMessage("-- The id is-->" +element.id);
    This only returns when the id is found in the db but returns nothing when not found in db?
    How can I always get a return value? atleast a true or false, so that I can put IF statements?
    Because if it returns nothing, the loop does not execute {}? So we cannot put something like:-
    foreach (element in
    SELECT id FROM TESTTABLE WHERE requestId = 732 and status = 1 )
    logMessage("-- The id is-->" +element.id);
    if(element.id == null)
    logMessage("-- Id Not Found -->" );
    else
    logMessage("-- Id Found -->");
    How can I always get a return value from my OBPM direct query ?
    Remember , I am not using DynamicSQL in this case?

    Hi,
    Set a Boolean flag value to False before the SQL query.
    Some thing like:
    boolean flag = false;
    foreach (element in
    SELECT id FROM TESTTABLE WHERE requestId = 732 and status = 1 )
    logMessage("-- The id is-->" +element.id);
    flag = true;
    if(flag) {
    logMessage("-- Id Found -->" );
    else
    logMessage("-- Id Not Found -->");
    Hope the above logic would work fine.
    Bibhu
    Edited by: Bibhuti Bhusan on Sep 2, 2011 11:48 AM

  • How to stop SQL Server Agent Job if Stored Procedure returns value 0

    I have SQL Server 2012 SSIS.
    I have 2 SSIS packages.
    I have created SQL Server Agent Job for running packages.
    I have created steps. If first step have run succesfully next step is run.
    I have need to add new logic.
    I have validation stored procedure, which validate DB table values and returns 1 or 0.
    I would like to create logic where first of all this SP is runned. Return value of SP determines if steps are run or not.
    I was thinking to use Execute SQL Task for running SP.
    If value 1 is returned, then run rest of Tasks is run.
    If value 0 is returned, what should I do so that Job is stopped? I need assistance! 
    I want current step to stop never moved to next step.
    Is there any SSIS tasks, which can stop the Job?
    Or should I make Step for running validation SP?
    How to do so that if value 0 is returned stop Job.
    Kenny_I

    Please refer the below link:
    http://technet.microsoft.com/en-us/library/aa260308(v=sql.80).aspx
    Please read Remarks carefully!!!
    Remarks
    If a job is currently executing a step of type CmdExec, the process being run (for example, MyProgram.exe) is forced to end prematurely. Premature ending can result in unpredictable behavior such as files in use by the process being held open. Consequently,
    sp_stop_job should be used only in extreme circumstances if the job contains steps of type CmdExec.
    Permissions
    Execute permissions default to the public role in the
    msdb database. A user who can execute this procedure and is a member of the
    sysadmin fixed role can stop any job. A user who is not a member of the
    sysadmin role can use sp_stop_job to stop only the jobs he/she owns.
    When sp_stop_job is invoked by a user who is a member of the
    sysadmin fixed server role, sp_stop_job will be executed under the security context in which the SQL Server service is running. When the user is not a member of the
    sysadmin group, sp_stop_job will impersonate the SQL Server Agent proxy account, which is specified using
    xp_sqlagent_proxy_account. If the proxy account is not available,
    sp_stop_job will fail. This is only true for Microsoft® Windows® NT 4.0 and Windows 2000. On Windows 9.x, there is no impersonation and
    sp_stop_job is always executed under the security context of the Windows 9.x user who started SQL Server.

Maybe you are looking for

  • View creation and populating key figure to datasource appended field

    Hi the data we want is like in 4 tables J_3GVERSI  +  EQUZ + ILOA+ ANLC HOW should i create a view on these four tables . j_3gversi _ equnr equz - equnr, iloan iloa- iloan(key), comp code,asset no,asset subno anlc- comp code asset no asset sub no my

  • Problem in opening an image file sent as attachment in mail

    Hi Friends, I have a requirement of sending a image file (.jpg) through email attachment. I am getting the attachment using the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'. But i am unable to open the file in the attachment. It is givin a message

  • OSX *****. I'm sick of this crap.

    I don't know what happened, must have been from one of those OSX software updates. But now OSX thinks it's ok to hide all my windows if they aren't part of the active application. So much for being able to watch a video, while working in another appl

  • Help I have done all the things on this site and can't fix face time

    Could any one tell me how can I fix Face time ?? I have reset the settings ..turned it off and back on, all the things on the page and it is not working ..used to work perfect but always after an update it doesn't work anymore...and the phone company

  • Report query with multiple selects

    On some of my Report Queries (that have multiple selects) it sometimes changes the rowset when I edit the specific SQL. For example, I have 2 selects in my Report Query andnd when I download the XML my first select's data goes into <ROWSET1> and my s