Loading failure at launch

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
Rob van der Sloot
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 71
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: 11411
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: 71
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: 11411
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: 71
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: 11411
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.

Post Reply

Return to “Databases”