IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17855


Ignore:
Timestamp:
May 29, 2008, 12:08:43 PM (18 years ago)
Author:
jhoblitt
Message:

add runMultipleStatments() function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/pxadmin.c

    r17854 r17855  
    22 * pxadmin.c
    33 *
    4  * Copyright (C) 2006  Joshua Hoblitt
     4 * Copyright (C) 2006-2008  Joshua Hoblitt
    55 *
    66 * This program is free software; you can redistribute it and/or modify it
     
    2929
    3030bool deleteMode(pxConfig *config);
     31static bool runMultipleStatments(pxConfig *config, const char *query);
    3132
    3233int main(int argc, char **argv)
     
    9495    }
    9596
     97    if (!runMultipleStatments(config, query)) {
     98        if (!psDBRollback(config->dbh)) {
     99                psError(PS_ERR_UNKNOWN, false, "database error");
     100        }
     101        psError(PS_ERR_UNKNOWN, false, "database error");
     102        psFree(query);
     103        return false;
     104    }
     105    psFree(query);
     106
     107    // COMMIT
     108    if (!psDBCommit(config->dbh)) {
     109        psError(PS_ERR_UNKNOWN, false, "database error");
     110        return false;
     111    }
     112
     113    return true;
     114}
     115
     116static bool runMultipleStatments(pxConfig *config, const char *query)
     117{
     118    PS_ASSERT_PTR_NON_NULL(config, false);
     119    PS_ASSERT_PTR_NON_NULL(query, false);
     120
    96121    // loop over all statements in string
    97122    psList *statements = psStringSplit(query, ";", false);
    98     psFree(query);
    99123
    100124    psString q = NULL;
     
    102126    while ((q = psListGetAndIncrement(iter))) {
    103127        if (!p_psDBRunQuery(config->dbh, q)) {
    104             if (!psDBRollback(config->dbh)) {
    105                 psError(PS_ERR_UNKNOWN, false, "database error");
    106             }
    107128            psError(PS_ERR_UNKNOWN, false, "database error");
    108129            psFree(iter);
     
    114135    psFree(statements);
    115136
    116     // COMMIT
    117     if (!psDBCommit(config->dbh)) {
    118         psError(PS_ERR_UNKNOWN, false, "database error");
    119         return false;
    120     }
    121 
    122137    return true;
    123138}
Note: See TracChangeset for help on using the changeset viewer.