Scripting and modules
Friday, 1 December 2017 · 3 messages · last reply 2 Dec 2017
KK
Kristian Kankainen1 Dec 2017 17:30 #
Hello,
I need to run several updating queries in sequel on a database and a good candidate for this should be a simple .bxs script. But is there a convenient way to reference functions defined in an external module? I have all functions defined in an external XQuery module and I would like to be able to write the script in such a way, that I use just the names of the allready defined functions. E.g something like this:
# script.bxs
# open the database
OPEN testdb;
# make backup of the initial state
CREATE BACKUP init;
# run all updating queries
XQUERY updateFunctionA();
XQUERY updateFunctionB();
# etc ...
# make a backup of the final state
CREATE BACKUP final;
I guess I can recap my question with just the following: what would be the most convenient way for me to organize this kind of automation of running allready defined module functions?
Thank you,
Kristian K
KD
Kirsten, Dirk1 Dec 2017 17:44 #
Hello Kristian,
XQUERY just executes actual XQuery code, so you can simply import the module as you normally would. So something like
XQUERY import module namespace up = 'http://your.namespace' at 'your-module-location.xqm'; up:updateFunctionA()
should work fine.
Cheers
Dirk
Senacor Technologies Aktiengesellschaft - Sitz: Eschborn - Amtsgericht Frankfurt am Main - Reg.-Nr.: HRB 105546 Vorstand: Matthias Tomann, Marcus Purzer - Aufsichtsratsvorsitzender: Daniel Gr?zinger
-----Urspr?ngliche Nachricht-----
Quoted text · basex-talk-bounces at mailman.uni-konstanz.de · 20 lines
Von: basex-talk-bounces at mailman.uni-konstanz.de [mailto:basex-talk-bounces at mailman.uni-konstanz.de] Im Auftrag von Kristian Kankainen Gesendet: Freitag, 1. Dezember 2017 17:30 An: BaseX <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] Scripting and modules Hello, I need to run several updating queries in sequel on a database and a good candidate for this should be a simple .bxs script. But is there a convenient way to reference functions defined in an external module? I have all functions defined in an external XQuery module and I would like to be able to write the script in such a way, that I use just the names of the allready defined functions. E.g something like this: # script.bxs # open the database OPEN testdb; # make backup of the initial state CREATE BACKUP init; # run all updating queries XQUERY updateFunctionA(); XQUERY updateFunctionB(); # etc ... # make a backup of the final state CREATE BACKUP final; I guess I can recap my question with just the following: what would be the most convenient way for me to organize this kind of automation of running allready defined module functions? Thank you, Kristian K
KK
Kristian Kankainen2 Dec 2017 20:43 #
Thanks, it works fine.
Kristian
01.12.2017 18:44 Kirsten, Dirk kirjutas:
Quoted text · Kirsten, Dirk · 56 lines
> Hello Kristian, > > XQUERY just executes actual XQuery code, so you can simply import the > module as you normally would. So something like > > XQUERY import module namespace up = 'http://your.namespace' at > 'your-module-location.xqm'; up:updateFunctionA() > > should work fine. > > Cheers > Dirk > > ** > Senacor Technologies Aktiengesellschaft - Sitz: Eschborn - > Amtsgericht Frankfurt am Main - Reg.-Nr.: HRB 105546 > Vorstand: Matthias Tomann, Marcus Purzer - Aufsichtsratsvorsitzender: > Daniel Grözinger > > > -----Ursprüngliche Nachricht----- > Von: basex-talk-bounces at mailman.uni-konstanz.de > [mailto:basex-talk-bounces at mailman.uni-konstanz.de] Im Auftrag von > Kristian Kankainen > Gesendet: Freitag, 1. Dezember 2017 17:30 > An: BaseX <basex-talk at mailman.uni-konstanz.de> > Betreff: [basex-talk] Scripting and modules > > Hello, > > I need to run several updating queries in sequel on a database and a > good candidate for this should be a simple .bxs script. But is there a > convenient way to reference functions defined in an external module? I > have all functions defined in an external XQuery module and I would > like to be able to write the script in such a way, that I use just the > names of the allready defined functions. E.g something like this: > > # script.bxs > # open the database > OPEN testdb; > # make backup of the initial state > CREATE BACKUP init; > # run all updating queries > XQUERY updateFunctionA(); > XQUERY updateFunctionB(); > # etc ... > # make a backup of the final state > CREATE BACKUP final; > > I guess I can recap my question with just the following: what would be > the most convenient way for me to organize this kind of automation of > running allready defined module functions? > > Thank you, > Kristian K >
Written for BaseX 8.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery