El S�b 07 Feb 2004 02:28, escribi�:
> Mr. Alfredo
> Pls, will you give the complete structure as 'create query' of your
> database? that will help us to solve your problem.
> Pradap
This is the structure of the table that holds the sequential numbers for
various documents that need them:
CREATE TABLE `invcorr` (
`empresa` tinyint(2) unsigned zerofill NOT NULL default '00',
`tienda` tinyint(2) unsigned zerofill NOT NULL default '00',
`ultfac` bigint(9) unsigned zerofill NOT NULL default '000000000',
`ultfaccred` bigint(9) unsigned zerofill NOT NULL default '000000000',
`ultconsig` bigint(9) unsigned zerofill NOT NULL default '000000000',
`ultdev` bigint(9) unsigned zerofill NOT NULL default '000000000',
`ultped` bigint(9) unsigned zerofill NOT NULL default '000000000',
`ulting` bigint(9) unsigned zerofill NOT NULL default '000000000',
`ultapar` bigint(9) unsigned zerofill NOT NULL default '000000000',
`ultcoti` bigint(9) unsigned zerofill NOT NULL default '000000000',
`ulttras` bigint(9) unsigned zerofill NOT NULL default '000000000',
`ultreq` bigint(9) unsigned zerofill NOT NULL default '000000000',
`ultajus` bigint(9) unsigned zerofill NOT NULL default '000000000',
`timestamp` timestamp(14) NOT NULL,
`usuario` varchar(20) default NULL,
PRIMARY KEY (`empresa`,`tienda`)
) TYPE=MyISAM;
The condensed extract of the C program tha does the locking is as follows:
SQLinst = "lock tables invcorr write, invfacturas write";
state = mysql_query(connection, SQLinst);
if(state != 0)
{
wxMessageBox(mysql_error(&mysql), "Error:", wxOK |
wxICON_EXCLAMATION,
this);
wxMessageBox(_("Could not lock table!"), _("Error:"), wxOK |
wxICON_EXCLAMATION, this);
return;
}
SQLinst = "select ultfac from invcorr where empresa='"
+ sCodigoEmp
+ "' and tienda='"
+ sFacTienda
+ "' order by tienda";
state = mysql_query(connection, SQLinst);
result = mysql_store_result(connection);
if(mysql_num_rows(result) != 0) // Tiene registros
{
while((row = mysql_fetch_row(result)) != NULL)
{
// Asigno valores
sFacDocu = row[0] ? row[0] : "";
}
}
mysql_free_result(result);
sFacDocu.ToDouble(&dFacDocu);
dFacDocu++;
sFacDocu.Printf("%09.0f", dFacDocu);
SQLinst = "update invcorr set ultfac='"
+ sFacDocu
+ "' where empresa='"
+ sCodigoEmp
+ "' and tienda='"
+ sFacTienda + "'";
state = mysql_query(connection, SQLinst);
SQLinst = "unlock tables";
state = mysql_query(connection, SQLinst);
This final update is what seems to sleep and not react inmediately. The
application resides in one central server with dual Xeon 2.8 Ghz CPU's and 6
Gb RAM. All users run the application at the server connecting either via
ssh, VNC or Linux Terminal Server Project.
During the day, I will get 3 or 4 duplicate numbers per store. Given the fact
that reporting sales tax received, depends on a correct sequence of invoices,
my company could get into big trouble if authorities think we are trying to
avoid sales tax reporting.
Thank you for your help.
--
Alfredo J. Cole
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]