can't use pgxml_xpath - sql

I'm using PostgreSQL 9.1, I thought it was supposed to support this XML integration but I can't get it to work. I try this query:
select data from ddm_table_data order by pgxml_xpath(data, '//xmltest/col1/text()', '', '');
And it comes up with the following errors:
ERROR: function pgxml_xpath(xml, unknown, unknown, unknown) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Am I missing something?

Am I missing something?
Like the error says - there's no such function. There's one called "xpath" though.
The manuals are your friend.

Related

Undefined function: 'charindex'

I'm trying to use CHARINDEX function to find the occurrence of a char. in Databricks sql (SPARK-SQL).
But seems CHARINDEX is not recognized and throwing the below error.
ERROR:
Undefined function: 'charindex'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.
Kindly help me in this
Tried with the below example given in databricks documentation
Ex: SELECT charindex('bar', 'abcbarbar', 5)
https://docs.databricks.com/sql/language-manual/functions/charindex.html

cypher cast string to integer in Agensgraph

I use the following query, this returns string values:
MATCH (n:artefact) RETURN (n.id)
I'm trying to cast the string to an integer, so I use the following:
MATCH (n:artefact) RETURN toInteger(n.id)
This returns the error:
[FAIL] BadSqlGrammarException->StatementCallback; bad SQL grammar [MATCH (n:artefact) RETURN toInteger(n.id);]; nested exception is org.postgresql.util.PSQLException: ERROR: function tointeger(jsonb) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
I've also tried toInt()
I'm guessing the function tointeger(jsonb) does not exist is the issue, is it trying to convert the entire jsonb in an integer rather than just the n.id?
How do I resolve this?
I'm using Agensgraph, when I start agens browser it states check version of AgensGraph ... v1.2 or under

What is wrong with this ST_CONTAINS statement PostGIS - Find point in polygon

I'm trying the following:
Event.where('ST_Contains(?,ST_SetSRID(location, 4326)::geography)', search_polygon::geography)
add getting the error
*** NoMethodError Exception: undefined method `geography' for
but without that (::geography) I get a message telling me to cast, what do I do?
HINT: No function matches the given name and argument types. You
might need to add explicit type casts.
It looks like you are trying to use ST_Contains on geography types, but that function only works on geometry types.
If you are OK with the intersects spatial relation (see DE-9IM), then use ST_Intersects(geography, geography).

SQL: Agregate function for user defined type

I have user defined type:
create type indeks as integer
And question for my exam says: "Define aggregate function max for type indeks"
create function max(indeks)
returns indeks
source sysibm.max(integer);
Can you help me understand this? Because I know this is some elementary stuff.
create function max(indeks)
returns indeks
These two lines are OK, I'm creating function and return type is also indeks.
source sysibm.max(integer);
But this is what I don't understand. I have no idea what is this line for.
Thanks in advance.
The schema name SYSIBM is used for built-in data types and built-in functions. The function source from the SYSIBM.MAX catalog table is merged into the statement.
The built-in functions cannot simply
be applied to User Defined Types. If they are
required, then UDFs-based on the desired built-in functions must be generated. It means that you need to put this statement there
source sysibm.max(integer);

Oracle DEFAULT clause for create table. "Literal argument"?

I was just reading the documentation for the CREATE TABLE statement and it says this in relation to the DEFAULT clause:
"The DEFAULT expression can include any SQL function as long as the
function does not return a literal argument, a column reference, or a
nested function invocation."
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_7002.htm
What does it mean by the function cannot return a "literal argument". I thought returning literals was OK for DEFAULT?
Yes, it is OK to use literals with DEFAULT, for example DEFAULT 'YES' . What is telling you that text is that if you are using a function in DEFAULT, for example DEFAULT POWER(2,3) , that function POWER must not return a literal argument. You can use SQL built in functions in the clause DEFAULT , but not USER defined PLSQL functions