CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Simple person needs simple answer - please help

Print topic Send  topic

Author Message
Paul
Posted: 01/08/2002, 2:15 AM

I know this is a simple question, i am using ASP with mySQL:

On insert i want to check the highest current vacancy_id then add 1 to this to make a new vacancy_id for the inserted record.

Thanks in advance
Nicole
Posted: 01/08/2002, 3:23 AM

Paul,
MySQL allow you mark fields as 'auto_increment' (like autonumber in Access). In this case when the new record is inserted you don't need to build the new inserted value manually.
Nicole
Posted: 01/08/2002, 3:23 AM

Paul,
MySQL allow you mark fields as 'auto_increment' (like autonumber in Access). In this case when the new record is inserted you don't need to build the new inserted value manually.
Paul
Posted: 01/08/2002, 3:28 AM

MySQL does indeed include an auto increment feature, but I would like to do this manually by select the highest vacancy_id value in the table and then adding 1 to it.

How would this be done... potentially this could lead to more flexibility in the future...

Thanks in advance
Nicole
Posted: 01/08/2002, 4:25 AM

Paul,
once you add primary key field to the record form, mark it as 'Key' field and set its type to Hidden, CC expects it to be autonumber and doesn't include it to generated sql statement. That's why you should add custom code to BeforeExecute event in order to get the new value of primary key and modify sql query. E.g.:
select case sAction
case "insert"
max_id = dLookUp("table_name", "max(primary_key_name)", "1=1")
next_id = max_id+1
sSQL = "insert into table_name primary_key_field, field1, field2 values ("& ToSQL(next_id, "Number") &", "& ToSQL(fldfield1, "Number") &", "& ToSQL(fldfield2, "Text") &")"
end select


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.