What does the function fn:data() do in exist-db? - database

I would like to know what the fn:data() function does in exist-db. I can't find the answer anywhere on the web.

It seems you have found one documentation of the data function, however, that is part of the MS SQL Server XQuery support.
In general, the W3C XQuery/XPath/XSLT functions are specified in https://www.w3.org/TR/xpath-functions/, so the data function in https://www.w3.org/TR/xpath-functions/#func-data.
Or use the eXist-db documentation if you want an eXist-db specific documentation, searchable at http://www.exist-db.org/exist/apps/fundocs/index.html: for the data function http://www.exist-db.org/exist/apps/fundocs/view.html?uri=http://www.w3.org/2005/xpath-functions&location=java:org.exist.xquery.functions.fn.FnModule&details=true#data.1
For the data function it might not matter but in general the "XQuery" support in non-XML databases like MS SQL is often not complete and/or not based on the current/latest spec so I would start with the W3C specification and then look at vendor specific documentation for the XQuery implementation in use instead of using third party documentation.

I just found the answer to my own question. If anyone else is wondering about this, you can find more here: https://learn.microsoft.com/en-us/sql/xquery/data-accessor-functions-data-xquery?view=sql-server-ver15

Related

How to call database function using AdonisJS?

I’ve got a database in PostgreSQL containing GeoData,
and I need to invoke PostGIS functions such as ST_AsGeoJSON, ST_AsText etc. using the lucid ORM but can’t seem to find a way around.
Can anybody provide me with any example or docs related to it ?
Thanks,

How to use Regex in a tsql query

I have a column called link, which can hold different types of link. I'd like to retrieve only those that have a urls, i.e. www.google.com, so that I can apply something.
SELECT *
FROM UserAlert
WHERE Link = ...// check whether it's a url
Thanks for helping
This is almost 100% likely to be a job better suited to the front-end application, not the database. It will require code execution on the server.
Here is a thread here on StackOverflow about url detection regexes, from which you can select any of a number of reasonably good expressions: What is the best regular expression to check if a string is a valid URL?
To use regexes in MSSQL, you need to first use MSSQL 2005 or later. Assuming that is the case... you have to wrap regex functionality in a custom CLR object, enable CLR interaction on your whole database, and then you can use that custom CLR object in your WHERE clause.
Here is a detailed article about doing exactly that with examples and step-by-step instructions.
I hope you're REALLY SURE that you want code execution to be part of your database. Good luck!

DB Comparison tool that I can schedule

I'm after a DB Comparison tool for SQL Server that allows me to do the following:
Schedule a comparison to happen on a recurring schedule
Email me the results (in a nice readable format and not the generated script)
Allow me to exclude/include certain object names (for example exclude table names containing %test%. That's not a real example but there is a good reason why that would come in useful.)
As well as the obvious:
Have the usual options for ignoring things like comments, identity seeds etc
Options for selecting different types of objects
If it was free or at least didn't cost a forture that would be an extra bonus of course.
I have tried out RedGate's SQL Compare and also the built-in DB Comparison in Visual Studio but neither seem able to do the first 3 points above. I also looked at other tools recommended in various threads on here but again they don't mention in their features the 3 points above.
One option I found is RedGate's SQL Comparison SDK with which I think I could write something to do what I want.
I just wanted to investigate tools that might do all of the above out of the box.
Thank you!
SQL Compare Pro comes with a command line, which will be easier to set up than the SDK. If you call this via the Windows Scheduler or in an Agent Job you can achieve what you're looking for.
An example of how to invoke the command line from Powershell it can be found here:
http://www.simple-talk.com/sql/database-administration/auditing-ddl-changes-in-sql-server-databases/
This article also covers how to send an email in Powershell. SQL Compare can also be passed a filter using the /filter switch to exclude objects based on various rules.
http://www.red-gate.com/supportcenter/Content/SQL_Compare/help/10.0/sc_cl_Switches_in_the_cl
Do please email support#red-gate.com should you have trouble getting this working.
I don't think any tool would do all of this out of the box. Have you had a chance to look at
sp_CompareDB. I had a similar requirement and ended up writing my own routine based on the same.
http://www.sql-server-performance.com/2001/database-comparison-sp/

SQL Server Cursor Reference (Syntax, etc)

I don't use SQL Server Cursors often but when I do, I always have to look up the syntax and options.
So I wanted to ask, what is the best SQL Server Cursor reference on the web?.
I'm looking for a reference that explains all of the (major?) options (I.E. FAST_FORWARD) and also shows quick snippets of how to use it. (I.E. How to implement looping though a cursor and with a good practice for checking the ##FETCH_STATUS variable.)
Best Regards,
Frank
Quick Update: I'm looking for a balance of quick-reference but detailed enough to see my options. As an example. MSDN is a great reference guide but it has too much detail. The reference, ideally, should be concise.
Further update: I'm still looking for sources. If someone posts a good source that fits my criteria of concise, I will accept that answer...
How to Perform SQL Server Row-by-Row Operations Without Cursors:
http://www.sql-server-performance.com/articles/per/operations_no_cursors_p1.aspx
SQL Server Cursor Examples (with Cursor Alternatives):
http://www.mssqltips.com/tip.asp?tip=1599
I'd start out with the MSDN help page for cursors...
http://msdn.microsoft.com/en-us/library/ms180169.aspx
I always use the built in "Transact-SQL Reference" help within management studio. I find the examples on everything there to be more than enough for what I need.

Apache module FORM handling in C

I'm implementing an Apache 2.0.x module in C, to interface with an existing product we have. I need to handle FORM data, most likely using POST but I want to handle the GET case as well.
Nick Kew's Apache Modules book has a section on handling form data. It provides code examples for POST and GET, which return an apr_hash_t of the key+value pairs in the form. parse_form_from_POST marshalls the bucket brigade and flattens it into a buffer, while parse_form_from_GET can simply reference the URL. Both routines rely on a parse_form_from_string routine to walk through each delimited field and extract the information into the hash table.
That would be fine, but it seems like there should be an easier way to do this than adding a couple hundred lines of code to my module. Is there an existing module or routines within apache, apr, or apr-util to extract the field names and associated data from a GET or POST FORM into a structure which C code can more easily access? I cannot find anything relevant, but this seems like a common need for which there should be a solution.
I switched to G-WAN which offers a transparent ANSI C scripts interface for GET and POST forms (and many other goodies like charts, GIF I/O, etc.).
A couple of AJAX examples are available at the GWAN developer page
Hope it helps!
While, on it's surface, this may seem common, cgi-style content handlers in C on apache are pretty rare. Most people just use CGI, FastCGI, or the myriad of frameworks such as mod_perl.
Most of the C apache modules that I've written are targeted at modifying the particular behavior of the web server in specific, targeted ways that are applicable to every request.
If it's at all possible to write your handler outside of an apache module, I would encourage you to pursue that strategy.
I have not yet tried any solution, since I found this SO question as a result of my own frustration with the example in the "Apache Modules" book as well. But here's what I've found, so far. I will update this answer when I have researched more.
Luckily it looks like this is now a solved problem in Apache 2.4 using the ap_parse_form_data funciton.
No idea how well this works compared to your example, but here is a much more concise read_post function.
It is also possible that mod_form could be of value.

Resources