Loading failure at launch

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Rob van der Sloot
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Sat Apr 17, 2010 9:21 am

Loading failure at launch

Post by Rob van der Sloot » Tue Jan 14, 2020 12:58 pm

I have the following problem:

When my runtime startsup, everything seems to be ok.
But when I do a specific action on the mysql database, insert and delete, then that action is not performed properly.
When I do it the second time, there is no problem, insert and delete work as programmed.

So I have the feeling that I miss something in the opening script of the stack.
Should there be any insert and delete scripting at the startup?

Thanks,
Rob van der Sloot

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Loading failure at launch

Post by Klaus » Tue Jan 14, 2020 1:35 pm

Dag Rob,

"on startup" LC did not load any library yet, so your db actions etc. will fail.
You should do this on openstack with a little delay:

Code: Select all

on openstack
  ## Your stuff here
  ## ...
  send "your_db_stuff_here" to this stack in 1
end openstack
Then you can be sure everything will work out as exspected.


Groetjes

Klaus

Rob van der Sloot
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Sat Apr 17, 2010 9:21 am

Re: Loading failure at launch

Post by Rob van der Sloot » Thu Jan 16, 2020 12:09 pm

Hi Klaus,

I don't understand fully.

In the "openStack" script there is already a lot of db_stuff, because a lot of data from the database is loaded into the main screen.
But then when I do an action for a new insert, I open a substack with all possible options to choose, which are all loaded from the database.
From this substack data are put into fields and also a number of insert and delete actions are performed.

I don't see what extra library has to be opened.

Its probably some variable missing the first time. But I havent found that yet.

thanks
Rob

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Loading failure at launch

Post by Klaus » Thu Jan 16, 2020 1:00 pm

Dag Rob,

sorry, looks like I misunderstood this one:
When my runtime startsup...
that you are doing this "on startup", which is obviously not the case. 8)
Please post your script.


Best

Klaus

Rob van der Sloot
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Sat Apr 17, 2010 9:21 am

Re: Loading failure at launch

Post by Rob van der Sloot » Thu Jan 16, 2020 3:55 pm

OK, here are the 2 scripts where the problem is situated.
Its about setting up meals based on certain input.
By the creation of the "treatment plan" all meals are preset to "Full" (that means breakfast, lunch & diner). These are invoicelines created for every day of the duration of the treatment plan.

But when a "special type of treatment" is prescribed, then also specific meal types are included. Those mealtypes are connected to the "special type of treatment" . That means that the "Full" type needs to be deleted, and the others are inserted. So the "full" invoiceline is deleted, and there are a breakfast, lunch and diner invoiceline created.

This works usually fine, only when its the first time, after the treatment plan is opened, this delete of the "full" invoiceline does not work. The script "E01_procesMeals" processes this and works ok, only the last one "D04_DeleteInvoiceLineProductType", does not delete the "Full" invoiceline in the "doc07_invoicelinesmav" table when its the first time. If I do it again a second time, after controlling the invoicelines, it works. But that means that the user has to check the invoicelines and remove or create again. This is not very user friendly.

I hope you can follow this.

All the best,
Rob

# Updates the Breakfast, Lunch and Diner fields in the table: pt13_products
# Creates Invoicelines in the MAV invoicelines table

on E01_procesMeals
# proces Prep
E02_procesPrepBreakfast

# proces Lunch
E03_procesLunch

# proces Diner
E04_procesDiner

# Delete Full Invoice Record
put "Full" into tProductType
D04_DeleteInvoiceLinesProductType
end E01_procesMeals

----------------------------------

# Delete Invoicelines based on bgID, RowNr,ProductType & TreatColumn
on D04_DeleteInvoiceLinesProductType
put "DELETE FROM doc07_invoicelinesmav WHERE bgID=" & bgID & \
" and DayNr = " & gRowNr & " and ProductType = " & quote & \
tProductType & quote & " and TreatColumn = " & tTreatColumn into tSQL
put "mamsdocument" into tDBName
ConnectToDatabase
revExecuteSQL gConID, tSQL
revCloseDatabase gConID
put the result into tResult
handleRevDBerror
end D04_DeleteInvoiceLinesProductType[/indent]

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Loading failure at launch

Post by Klaus » Thu Jan 16, 2020 4:01 pm

Is tProductType (and the other variables) local or global?
Since you are not passing it to the handler "D04_DeleteInvoiceLinesProductType".

And it is always a good idea to:

Code: Select all

...
put .... into tSQL
ANSWER tSQL
...
So you can check the SQL string.

Rob van der Sloot
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Sat Apr 17, 2010 9:21 am

Re: Loading failure at launch

Post by Rob van der Sloot » Sat Jan 18, 2020 5:51 pm

I am practically only using globals.
What use is it to declare locals anyway, since they always work without declaration?
I have checked all my tSQL strings. If there would be a variable missing, it would'nt work at all.
I have already sorted out that maybe a variable is not yet declared the first time, but I can't find any.

Thanks
Rob

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Loading failure at launch

Post by bogs » Sat Jan 18, 2020 6:06 pm

Rob van der Sloot wrote:
Sat Jan 18, 2020 5:51 pm
What use is it to declare locals anyway, since they always work without declaration?
Erm, I think you are confusing 'local' variables with 'temporary' variables, i.e. -

Code: Select all

#declared local variable at top of script is available to all handlers below it....
local thisVar

on mouseDown
# this temporary variable is different than the one in mouseUp...
	put 1 into tmpField
# the script local variable thisVar will hold "1" to be used anywhere else in this script, 
#   such as the next handler that adds to it...
	put 1 into thisVar
end mouseDown

on mouseUp
# temporary variable declared without 'local' is only available during the scope of this handler...
	put field 1 into tmpField
# declared local variable available wherever it is called from if created within handler...
	put "Foo" && "Bar" into local fooBar
	put fooBar after thisVar # will contain "1 Foo Bar"
	-- other stuff
end mouseUp
Image

Post Reply

Return to “Databases”