IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2006, 2:07:55 PM (20 years ago)
Author:
jhoblitt
Message:

implement comparison operation selection for S32 & psTime types in psDBGenerateConditionalSQL()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/db/psDB.c

    r9748 r9751  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.108 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-10-26 02:57:33 $
     14 *  @version $Revision: 1.109 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-10-27 00:07:55 $
    1616 *
    1717 *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
     
    16381638    }
    16391639
     1640    // select the by of comparasion to use.  currently the comparision
     1641    // op value is only used by PS_DATA_S32 & PS_DATA_TIME
     1642
     1643    // default to exact match ('=')
     1644    char *op = "=";
     1645    if (item->comment) {
     1646        // arbitrary semantic, precedence is: >=, <=, >, <, = (default)
     1647        if (strstr(item->comment, ">=")) {
     1648            op = ">=";
     1649        } else if (strstr(item->comment, "<=")) {
     1650            op = "<=";
     1651        } else if (strstr(item->comment, ">")) {
     1652            op = ">";
     1653        } else if (strstr(item->comment, "<")) {
     1654            op = "<";
     1655        }
     1656    }
     1657
    16401658    switch (item->type) {
    16411659    case PS_DATA_S32:
    1642         psStringAppend(&query, "%s=%d", itemName, (int)(item->data.S32));
     1660        psStringAppend(&query, "%s %s %d", itemName, op, (int)(item->data.S32));
    16431661        break;
    16441662    case PS_DATA_F32:
     
    16491667        break;
    16501668    case PS_DATA_BOOL:
    1651         psStringAppend(&query, "%s=%d", itemName, (int)(item->data.B));
     1669        psStringAppend(&query, "%s = %d", itemName, (int)(item->data.B));
    16521670        break;
    16531671    case PS_DATA_STRING:
     
    16681686        }
    16691687        break;
     1688    case PS_DATA_TIME: {
     1689            psString timeStr = psTimeToISO(item->data.V);
     1690            psStringAppend(&query, "%s %s '%s'", itemName, op, timeStr);
     1691            psFree(timeStr);
     1692
     1693            break;
     1694        }
    16701695    default:
    16711696        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
Note: See TracChangeset for help on using the changeset viewer.