You can find some information at:
This is the one I use when I started, but, It was hard to me, and take me some hours to make a simple function to work.
First you must add your function to /lib/db/services.php
Then you must add this function to the externallib.php file (I do it inside scorm/externallib.php but I guess exist somehow to make it in a independent way)
You must create the functions for:
- Function itself
At the end (and this is important and I think the link don't explain it) you should update your moodle version at moodle/version.php and mod/scorm/version.php and click to notifications.
This is the method I use.