Ignore:
Timestamp:
Sep 6, 2001, 5:07:32 AM (24 years ago)
Author:
bird
Message:

Design note improovments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/database/db.cpp

    r6651 r6663  
    1 /* $Id: db.cpp,v 1.24 2001-09-05 13:59:03 bird Exp $ *
     1/* $Id: db.cpp,v 1.25 2001-09-06 03:07:32 bird Exp $ *
    22 *
    33 * DB - contains all database routines.
     
    11721172 * @param       pszTitle        Design note title.
    11731173 * @param       pszText         Design note text.
     1174 * @param       lLevel          Level of the note section. 0 is the design note it self.
    11741175 * @param       lSeqNbr         Sequence number (in dll). If 0 the use next available number.
    1175  * @param       lSeqNbrFile     Sequence number in file.
     1176 * @param       lSeqNbrNote     Sequence number in note.
    11761177 * @param       lLine           Line number (1 - based!).
     1178 * @param       fSubSection     TRUE if subsection FALSE if design note.
     1179 *                              if TRUE *plRefCode will hold the reference id of the note.
     1180 *                              if FALSE *plRefCode will receive the reference id of the note being created.
     1181 * @param       plRefCode       Pointer to reference id of the design note. see fSubSection for more info.
    11771182 */
    11781183BOOL            _System dbAddDesignNote(signed long lDll,
     
    11801185                                        const char *pszTitle,
    11811186                                        const char *pszText,
     1187                                        signed long lLevel,
    11821188                                        signed long lSeqNbr,
    1183                                         signed long lSeqNbrFile,
    1184                                         signed long lLine)
    1185 {
     1189                                        signed long lSeqNbrNote,
     1190                                        signed long lLine,
     1191                                        BOOL        fSubSection,
     1192                                        signed long *plRefCode)
     1193{
     1194    int         rc;
    11861195    char        szQuery[0x10200];
    11871196    MYSQL_RES * pres;
     
    11891198
    11901199    assert(lDll >= 0 && lFile >= 0);
    1191     assert(lSeqNbrFile >= 0);
     1200    assert(lSeqNbrNote >= 0);
    11921201
    11931202    /*
    11941203     * If no lSqlNbr the make one.
    11951204     */
    1196     if (lSeqNbr == 0)
    1197     {
    1198         sprintf(&szQuery[0], "SELECT MAX(seqnbr) + 1 FROM designnote WHERE dll = %ld", lDll);
     1205    if (lSeqNbr == 0 && !fSubSection)
     1206    {
     1207        sprintf(&szQuery[0], "SELECT MAX(seqnbr) + 1 FROM designnote WHERE dll = %ld AND level = 0", lDll);
    11991208        if (mysql_query(pmysql, &szQuery[0]) >= 0)
    12001209        {
     
    12031212            {
    12041213                MYSQL_ROW parow = mysql_fetch_row(pres);
    1205                 if (parow != NULL)
     1214                if (parow != NULL && parow[0])
    12061215                    lSeqNbr = getvalue(0, parow);
    12071216                else
     
    12171226
    12181227    /*
    1219      * Create update query.
     1228     * Create insert query.
    12201229     */
    1221     sprintf(&szQuery[0], "INSERT INTO designnote(dll, file, seqnbrfile, seqnbr, line, title, note) "
    1222                          "VALUES (%ld, %ld, %ld, %ld, %ld, ",
    1223             lDll, lFile, lSeqNbrFile, lSeqNbr, lLine);
     1230    if (!fSubSection)
     1231        sprintf(&szQuery[0], "INSERT INTO designnote(dll, file, level, seqnbrnote, seqnbr, line, name, note) "
     1232                             "VALUES (%ld, %ld, %ld, %ld, %ld, %ld, ",
     1233                lDll, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);
     1234    else
     1235        sprintf(&szQuery[0], "INSERT INTO designnote(refcode, dll, file, level, seqnbrnote, seqnbr, line, name, note) "
     1236                             "VALUES (%ld, %ld, %ld, %ld, %ld, %ld, %ld, ",
     1237                *plRefCode, lDll, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);
     1238
    12241239    if (pszTitle != NULL && *pszTitle != '\0')
    12251240        sqlstrcat(&szQuery[0], NULL, pszTitle);
     
    12281243    sqlstrcat(&szQuery[0], ", ", pszText == NULL ? "" : pszText, ")");
    12291244
    1230     return mysql_query(pmysql, &szQuery[0]) >= 0;
     1245    if (mysql_query(pmysql, &szQuery[0]) >= 0)
     1246    {
     1247        if (!fSubSection)
     1248            *plRefCode = mysql_insert_id(pmysql);
     1249        return TRUE;
     1250    }
     1251    return FALSE;
    12311252}
    12321253
Note: See TracChangeset for help on using the changeset viewer.