handler required "select(MAX).."

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

handler required "select(MAX).."

Post by blairetabay » Tue Mar 18, 2014 1:44 am

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

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

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

Post by bangkok » Tue Mar 18, 2014 8:10 am

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.

blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

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

Post by blairetabay » Tue Mar 18, 2014 3:20 pm

Bangkok,

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”