For some odd reason, the default values for some of the optional 
arguments are not getting assigned, namely the _dateTime argument. As a 
result, I have to add the "if blahblah.nil?" hacks below. Anyone know 
what's going on here?


  def saveResults(_scriptPoint, \
                  _scriptName, \
                  _testResult=self.RESULTVALUE_SUCCESS, \
                  _seqNo=nil, \
                  _dateTime=Time.now(), \
                  _comments=nil, \
                  _imagePath=nil, \
                  _imageBinary=nil)

    #-- open connection with SQL Server database
    @sqlConnection = SqlClient::SqlConnection.new(@dataSource, 
@initialCatalog)

    #-- determine next sequence number for the current logID if seqNo 
parameter not passed
    _seqNo = self.getMaxSeqNo() + 1 if _seqNo.nil?

    #-- !!hacking starts here!!
    _dateTime = Time.now() if _dateTime.nil?
    _comments = "".to_s() if _comments.nil?
    _testResult = SqlErrorLogger::RESULTVALUE_INFO if _testResult.nil?

    sqlInsert = \
      "INSERT INTO " \
        "qa_loggerresults " \
      "(" \
        "logid, " \
        "seqno, " \
        "logdate, " \
        "scriptpoint, " \
        "scriptname, " \
        "comments, " \
        "testresult"

    #-- append the additional column names if their values were passed
    sqlInsert.concat(", screenimagepath") unless _imagePath.nil?
    sqlInsert.concat(", screenimage") unless _imageBinary.nil?

    #-- append a closing parenthesis
    sqlInsert.concat(") ")

    sqlInsert.concat( \
      "VALUES " \
      "(" \
        "#{self.newLogID}, " \
        "#{_seqNo}, " \
        "'#{self.formatDateTime(_dateTime)}', " \
        "'#{_scriptPoint}', " \
        "'#{_scriptName}', " \
        "'#{_comments}', " \
        "#{_testResult}")

    #-- append the additional column values if they're not nil
    sqlInsert.concat(", '#{_imagePath}'") unless _imagePath.nil?
    sqlInsert.concat(", #{_imageBinary}") unless _imageBinary.nil?

    #-- append a closing parenthesis
    sqlInsert.concat(")")

    puts(sqlInsert)

    @sqlConnection.execute(sqlInsert)

  end #-- SqlErrorLogger.saveResults()

-- 
Posted via http://www.ruby-forum.com/.