Page 1 of 1

handler required "select(MAX).."

Posted: Tue Mar 18, 2014 1:44 am
by blairetabay
i am trying to get the MAX number in my database column and adding 1 on it to create another MAX number on my next select.

i try this one and its working as my sample

http://www.w3schools.com/sql/sql_func_max.asp

The problem is it require a handler and a parameter. I don't have an idea where do I put my handler so far this is my code

Code: Select all


  if connectionID is a number then 
   
   put fld "lblOrderNum" into orderNum
   
   put "Select MAX(orderNumber) from hos_tbldrorders" into tabay
   
   put revDataFromQuery(,,connectionID, tabay) into order
   
   put order + 1 into orderNum
   
   
else 
   answer warning "Cannot conenct to SERVER DATABASE please try again" titled "Connection Error"
   end if
   

any suggestion will do.

thanks,

blaireTabay

Re: handler required "select(MAX).."

Posted: Tue Mar 18, 2014 8:10 am
by bangkok
The problem is it require a handler and a parameter. I don't have an idea where do I put my handler so far this is my code
A handler and a parameter ?

The SQL query looks correct. What's your problem exactly ?

Add some "answer" in order to check the query that is sent, and the result received.

Code: Select all

   put "Select MAX(orderNumber) from hos_tbldrorders" into tabay
   answer tabay
   put revDataFromQuery(,,connectionID, tabay) into order
   answer order
   put order + 1 into orderNum

Furthermore, you could avoir the SELECT with MAX... by giving the property AUTO_INCREMENT to the column orderNumber (if you have MySQL and provided orderNumber is a INTEGER). With such property, when you make an INSERT, MySQL would automatically add 1.

Re: handler required "select(MAX).."

Posted: Tue Mar 18, 2014 3:20 pm
by blairetabay
Bangkok,

I review my codes and something wrong with my code i just get it. no need to check your database.