Write Alarm to SQL database

I want to write an alarms to the database. When creating the device format, I need the "Desc" field. 

{date,10}{time,8}{category}{almcomment,80}{fullname,80}{userlocation,15}{state,9}{tag,80}{type,48}{desc,128}

But this word is the key to the DBMS. And the recording is not made. How to get out of this situation?

  • HELP says us: Keywords such as "DATE", "TIME", and "DESC" cannot be used as field names by some database systems. To use fields with these names, you need to append underscores to the names (for example, "TIME_", "DATE_", "DESC_").

     

    Cicode Programming Reference > Cicode Function Categories > SQL Functions > SQLFieldInfo

  • FUNCTION SQL()

    INT hSQL, nErr;

    STRING D1 = Date(10);

    STRING D2 = RealToStr(DATA1,"","");

    STRING D3 = RealToStr(DATA2,"","");

    STRING D4 = RealToStr(DATA3,"","");

    STRING D5 = Date(10);

    STRING D6 = RealToStr(DATA4,"","");

    STRING D7 = RealToStr(DATA5,"","");

    STRING D8 = RealToStr(DATA6,"","");

    hSQL=SQLConnect("DSN=shubham");

    IF hSQL <> -1 THEN

    nErr = SQLSet(hSQL, "INSERT INTO Table_1(F1,F2,F3,F4)";

    nErr = SQLAppend(hSQL, VALUES('"+D1+"','"+D2+"','"+D3+"','"+D4+"');

    nErr = SQLExec(hSQL, "");

    IF nErr <> 0 THEN

    Message("Information", SQLErrMsg(), 48);

    END

    nErr = SQLSet(hSQL, "INSERT INTO Table_2(F1,F2,F3,F4)";

    nErr = SQLAppend(hSQL, VALUES('"+D5+"','"+D6+"','"+D7+"','"+D8+"');

    nErr = SQLExec(hSQL, "");

    IF nErr <> 0 THEN

    Message("Information", SQLErrMsg(), 48);

    END

    nErr = SQLEnd(hSQL);

    nErr = SQLDisconnect(hSQL);

    ELSE

    Message("Information",SQLErrMsg(), 48);

    END

    END

  • You did not understand the question. I do not want to write to the database through cicode. I want to set the format for the alarm so that the Citect writes there automatically.
  • In SQL database, the DESC shoud be used with underscore afetr name "DESC_". However, you could use a SQL device to store alarms in Database without any Cicode Function.

    Please, check the pictures below