sql query to increment a number

i have found this query, but anyone can explain complete syntax for the insert query in sc:

SELECT MAX(IDN) FROM dbo.MyTable

UPDATE dbo.MyTable
SET IDN = IDN + (SELECT MAX(IDN) FROM dbo.MyTable)

Andrea,

Need more information. What are you trying to accomplish?
I am guessing that you might want to investigate auto-increment: http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

reading the query should work, but I read that I have to use the syntax and add, say, $ check_sql = … etc, and 'then sc_lookup (rs, $ check_sql); but as a whole the code with the query. thanks Regards

What is it that u are trying to accomplish?

  1. If you use Mysql database you easily set the the Prime Key (PK ) in your tabel to autoincrement, so then the database will take care of it.
  2. If you need another table in a Foreign Key situation you can use a stored procedure to handle that correcty

then you don’t need any special SQL in scriptcase that.

My example

i have method incnumquoation.

// SQL statement parameters
$update_table = ‘erp.dbo.SEQUENCENUMBER’; // Table name
$update_fields = array(“NEXTREC = ‘{dssec[0][0]}+1’”,);
$update_where = “DATAAREAID=‘dpm’ and NUMBERSEQUENCE =‘QUOTATION’”; // Where clause

// Update record
$update_sql = ‘UPDATE ’ . $update_table
. ’ SET ’ . implode(’, ', $update_fields)
. ’ WHERE ’ . $update_where;
sc_exec_sql($update_sql);