<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On Wednesday, 16 April, 2014 01:18 PM,
      Allan E. Registos wrote:<br>
    </div>
    <blockquote
cite="mid:1311257214.10257.1397625530649.JavaMail.zimbra@smpc.steniel.com.ph"
      type="cite">
      <div style="font-size: 12pt; color: rgb(0, 0, 0);">
        <div>Hi all,<br>
        </div>
        <div><br>
        </div>
        <div>Another noob db question, is there anything I can do make
          this error more friendly?:<br>
        </div>
        <div><br>
        </div>
        <div>>In file 'ink_settings_unit1.pas' at line 65:<br>
          >INK_SQL.SQL.Text := 'INSERT INTO ink_settings(id,
          setting_type, basebalance_date, latest_data) ' +</div>
        <div>?<br>
        </div>
        <div><br>
        </div>
        <div>I have this code structure for updating/inserting data:<br>
        </div>
        <div><br>
        </div>
        <div>try<br>
              result := false;<br>
               Try<br>
               InitializeDB();<br>
                //Not using StartTransaction for db is already active<br>
               SQLStr:='UPDATE ink_settings SET latest_data=0 WHERE
          setting_type=''%s''';<br>
               SQLStr:= Format(SQLStr,[INK_SETTING_TYPE]);<br>
               INK_SQL.SQL.Text := SQLStr;<br>
               INK_SQL.ExecSQL;<br>
          <div><br>
          </div>
               DateSTR:=FormatDateTime('MM-DD-YYYY
          hh:mm:ss',NewBaseDate);<br>
          <div><br>
          </div>
               NEW_INK_SETTINGID := GetTablePrimaryID('ink_settings') +
          1;<br>
        </div>
      </div>
    </blockquote>
    <br>
    Ok, the culprit is the above line! My bad.  Removing the line fixes
    my problem, it was using the same update and insert connections.<br>
    <br>
    <blockquote
cite="mid:1311257214.10257.1397625530649.JavaMail.zimbra@smpc.steniel.com.ph"
      type="cite">
      <div style="font-size: 12pt; color: rgb(0, 0, 0);">
        <div>     //Insert new base date<br>
               INK_SQL.SQL.Text := 'INSERT INTO ink_settings(id,
          setting_type, basebalance_date, latest_data) ' +<br>
                       ' VALUES
          (:NEWID,:SETTING_TYPE,:NEWDATE,:LATEST_DATA)';<br>
               INK_SQL.Params.ParamByName('NEWID').AsInteger :=
          NEW_INK_SETTINGID;<br>
               INK_SQL.Params.ParamByName('SETTING_TYPE').AsString :=
          INK_SETTING_TYPE;<br>
               INK_SQL.Params.ParamByName('NEWDATE').AsString :=
          DateSTR;<br>
               INK_SQL.Params.ParamByName('LATEST_DATA').AsInteger :=
          INK_LATEST_DATA;<br>
               INK_SQL.ExecSQL;<br>
          <div><br>
          </div>
               INK_TRANSACTION.Commit;<br>
          <div><br>
          </div>
               result := True;<br>
          <div><br>
          </div>
               except<br>
               on e: exception do // Catch my exception<br>
                  begin<br>
                   raise exception.Create('Error: ' + e.Message);<br>
                  end;<br>
              end;<br>
            finally<br>
              FreeDB();<br>
            end;    </div>
        <div><br>
        </div>
        <div>Where InitializeDB() code:<br>
        </div>
        <div><br>
        </div>
        <div>procedure InitializeDB();<br>
           begin<br>
            INK_DB := TPQConnection.Create(nil);<br>
            INK_SQL := TSQLQuery.Create(nil);<br>
            INK_TRANSACTION := TSQLTransaction.Create(nil);<br>
            INK_DATASOURCE := TDatasource.Create(nil);<br>
            if not INK_DB.Connected then<br>
            begin<br>
              INK_DB.HostName := DATABASE_HOST;<br>
              INK_DB.DatabaseName := DATABASE_NAME;<br>
              INK_DB.UserName := DATABASE_USER;<br>
              INK_DB.Password := DATABASE_PASSWORD;<br>
              INK_DB.Connected := True;<br>
          <div><br>
          </div>
              INK_SQL.database := INK_DB;<br>
              INK_TRANSACTION.DataBase := INK_DB;<br>
              INK_TRANSACTION.Active := True;<br>
              INK_DATASOURCE.DataSet := INK_SQL;<br>
              INK_SQL.Transaction := INK_TRANSACTION;<br>
            end;<br>
           end;</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Thank you for any ideas...<br>
        </div>
        <div><br>
        </div>
        <div>Regards,<br>
        </div>
        <div>Allan<br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">--
_______________________________________________
Lazarus mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a>
</pre>
    </blockquote>
  </body>
</html>