Leser: 1
5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
sstr << "UPDATE T_Stock SET Stock=" << amount << " WHERE Article_ID=" << artid << " and Storehouse_ID=" << sthid << ends;
strvar = sstr.str();
//convert string to char*
req_book = new char[strvar.size() + 1];
strcpy(req_book, strvar.c_str());
// free the stringstream object
sstr.str("");
sstr.clear();
state=mysql_query(mysqlconn, req_book); // send SQL-statement to the MYSQL-Server
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
####### Book goods receipt #######
$artid = ???; // value for Article_ID
$amount = ???; // value for Amount
$sthid = ???; // value for Storehouse_ID
SET AUTOCOMMIT = 0;
LOCK TABLES T_Stock WRITE, T_Stocklist WRITE, T_Storehouse WRITE;
SELECT @stock:=Stock FROM T_Stock WHERE Storehouse_ID = $sthid and Article_ID = $artid;
SELECT @tstock:=Total_Stock FROM T_Stocklist WHERE Article_ID = $artid;
UPDATE T_Stock SET Stock =@stock+$amount WHERE Storehouse_ID = $sthid and Article_ID = $artid;
UPDATE T_Stocklist SET Total_Stock =@tstock+$amount WHERE Article_ID=$artid;
UNLOCK TABLES;
COMMIT;
NOTE: LOCK TABLES is not transaction-safe and will implicitly commit any active transactions before attempting to lock the tables.
5 Einträge, 1 Seite |