Config Record

I need to create a single record form with some configuration settings. The from will be called directly from the menu (no grid) and will always open and update one (and the same) record. How you handle this ?
there will be to scenarios:

  1. there is no config record yer (so it must be added)
  2. record exists so it has to be red, changed then saved

here is a starting fragment of code

// Check for record
$check_sql = "SELECT UID, smtpserver, smtpuser, smtppassword, emailaccount, assigmentmode, publicticketsopening, definedparameters, broadcastmessages, defaultpriority, smtpsecurityflag, smtpport, urltrackingscreen, urlconfirmationscreen, defaultlanguage, companyname, urlimgok, urlimgfail, sys_version, sys_release, random_activation_code, timezone, syspa, sysad" 
   . " FROM G_systemsettings"
   . " WHERE UID = 1";
sc_lookup(rs, $check_sql);

if (isset({rs[0][0]}))     // Row found
{
    {UID} = {rs[0][0]};
    {companyname} = {rs[0][22]};
}
		else     // No row found
{
		    {UID} = 0;
    {companyname} = 'Error';
}

the p.2 is rather easy but I’m confused how to handle adding a new config record. Normally the record is saved then the user clicks SAVE (or UPDATE) button. When the form opens however UID (which is in my case Autonumbered,identification column with the Primary key on it) is empty so the app complains about UID not being autonumbered. I tried to prime UID with number 1 like

UID=1;

although wherever I place this code I still see UID is empty.
Any clues or suggestions ?

thanks - Arthur

Have you set autonumbering to automatic in the edit fields section?
If you are using MySQL issue 2 is simply solved by using replace into your table fields… see sql syntax for that. It will updat if the record exists, insert if it doesn’t. ON other databases you need to do a select first and then depending on the result do an insert or update.

Thanks - Albert.
Yes I have PRIMARY key set on UID (unique column) which is autonumbered. I wasn’t sure if I should use a primary key at all for a single record table. Lie I sais I see not problem with updates. The only problem is to handle the case when the record does not exist yet.

ARTHUR

In this scenario I wouldn’t use an,autoincrement id, if you know,just 1 record will/should,exists.
But, this is not,really a problem.

You call this form probably from other side. Create a php (for reutilization if,needed), and SELECT your configuration table. If dont returns anything, create a new record and return the generated I’d. If returns one record, return the I’d of this record.
Sc_redir to your configuration form passing as parameter id=previouslyreturnedid

Done.

• if not using autoincrement, just define your ID. 1, 999, number or text you prefer.