I'm trying to create an edge of class 'from' using SQL query. But it fails.
I'm guessing the 'from' confuses it with the SQL.
CREATE CLASS from IF NOT EXISTS EXTENDS relation
Exception:
com.orientechnologies.orient.core.exception.OCommandExecutionException:
Invalid script:Encountered \" \"CREATE \"\" at line 22,
column 1.\nWas expecting one of:\n ...\n \";\" ...\n
...\n \r\n\tDB name=\"xagon\"
You should backtick from:
CREATE CLASS `from` IF NOT EXISTS EXTENDS relation
Related
I'd like to create a generated tsvector column using npgsql / dotnet on a shadow property. I do not want to place the tsvector column in the entity class as I'd like to keep the domain entities agnostic of any specific database.
One way that may work is to use a shadow property for the tsvector column. I am able to create the tsvector column and index, but have not been able to figure out how to create generated column definition.
If the property exists in the domain entity, I can use the following:
builder
.HasGeneratedTsVectorColumn(
c => c.SearchVector,
"english",
c => new { c.Number, c.Name })
.HasIndex(p => p.SearchVector)
.HasMethod("GIN");
If the property is not in the domain, but rather a shadow property, I tried something like the foolowing:
builder
.Property<NpgsqlTsVector>("search_vector");
builder
.HasGeneratedTsVectorColumn(
c => EF.Property<NpgsqlTsVector>(c, "search_vector"),
"english",
c => new { c.ClientId, c.Name })
.HasIndex("search_vector")
.HasMethod("GIN");
Unfortunately, this does not work and, when generating the migrations, issues the following error:
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.ArgumentException: The expression 'c => Property(c, "search_vector")' is not a valid member access expression. The expression should represent a simple property or field access: 't => t.MyProperty'. (Parameter 'memberAccessExpression')
Is it possible to create the definition of the generated column for a shadow property?
Of course, also interested if there are other ways to accomplish this besides using a shadow property.
Thanks for any help,
Eric
I am trying to create a composite type which contains a variable of table column type as below
create type gp_core.rec_key_transaction as(
CODE_TRANSACTION transaction_.CODE_TRANSACTION%TYPE
);
I get the below error
ERROR: syntax error at or near "%"
LINE 2: ... TYPE_TRANSACTION TRANSACTION_.TYPE_TRANSACTION%TYPE
SQL state: 42601
Character: 99
I have no idea what could be the problem...
The reason for the error is, that the syntax simply isn't supported.
If you want to create type where one attribute is a record of a "table type", there is no need for the %type to begin with. For every table (and view) a type with the same name is created. So if transaction_.code_transaction is an existing table, you can create your type as:
create type gp_core.rec_key_transaction as
(
CODE_TRANSACTION transaction_.CODE_TRANSACTION
);
But I honestly fail to see the usefulness of this approach. Why not just use the "table type" directly instead of wrapping it with another type?
I have a Postgresql (version 10) database, hosted on Amazon RDS. I was trying to experiment with the earthdistance module - everything I read says that the module should be available, but the server is acting like it doesn't exist.
=> select earth_distance(ll_to_earth(42.1, 19.1), ll_to_earth(42.2, 19.2));
ERROR: function ll_to_earth(numeric, numeric) does not exist
LINE 1: select earth_distance(ll_to_earth(42.1, 19.1), ll_to_earth(4...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
=> select ll_to_earth(42.1, 19.1) ;
ERROR: function ll_to_earth(numeric, numeric) does not exist
LINE 1: select ll_to_earth(42.1, 19.1) ;
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
=> select earth() ;
ERROR: function earth() does not exist
LINE 1: select earth() ;
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
I ran SHOW rds.extensions, and earthdistance does show up in the list. So what am I missing? Do I have to do something to activate this module?
You have to do create extension earthdistance in order to use it. Just because the binaries and scripts exist doesn't mean they are active.
I'm trying to work out how to expand a JSONB field with a jsonb_to_recordset and a custom type.
Postgres 11.4.
This is just a test case, but for the minute I'm trying to work out the syntax. I've got a table named data_file_info with a JSONB field named table_stats. The JSONB field always includes a JSON array with the same structure:
[
{"table_name":"Activity","record_count":0,"table_number":214},
{"table_name":"Assembly","record_count":1,"table_number":15},
{"table_name":"AssemblyProds","record_count":0,"table_number":154}
]
The following code works correctly:
from data_file_info,
jsonb_to_recordset(table_stats) as table_stats_splat (
table_name text,
record_count integer,
table_number integer
)
What I would like to do is pass in a custm type definition instead of the long-form column definition list shown above. Here's the matching type:
create type data.table_stats_type as (
table_name text,
record_count integer,
table_number integer)
Some examples I've seen, and the docs say, that you can supply a type name using a null:row_type casting in the first parameter to jsonb_to_recordset. The examples that I've found use in-line JSON, while I'm trying to pull stored JSON. I've made a few attempts, all have failed. Below are two of the trials, with errors. Can someone point me towards the correct syntax?
FAIL:
select table_stats_splat.*
from data_file_info,
jsonb_populate_recordset(null::table_stats_type, data_file_info) as table_stats_splat;
-- ERROR: function jsonb_populate_recordset(table_stats_type, data_file_info) does not exist
-- LINE 4: jsonb_populate_recordset(null::table_stats_type, dat...
^
-- HINT: No function matches the given name and argument types. You might need to add explicit type casts. (Line 4)
FAIL:
select *
from jsonb_populate_recordset(NULL::table_stats_type, (select table_stats from data_file_info)) as table_stats_splat;
-- ERROR: more than one row returned by a subquery used as an expression. (Line 2)
I'm doubtlessly missing something pretty obvious, and am hoping someone can suggest what that is.
Use the column as the second parameter:
select table_stats_splat.*
from data_file_info,
jsonb_populate_recordset(null::table_stats_type, table_stats) as table_stats_splat;
I have the following statement that I need to run on a table which has a geometry column. I am getting a WKT from Oracle using my C# program and then attempting to insert it into PostgreSQL using an npgsql connection.
highways=# INSERT INTO cluster_125m (CELL_GEOM)
VALUES(ST_GeomFromWKT('POLYGON ((80000.0 17280.0, 80125.0 17280.0, 80125.0 17405.0, 80000.0 17405.0, 80000.0 17280.0))'));
I get the following error:
ERROR: function st_geomfromwkt(unknown) does not exist
LINE 1: INSERT INTO cluster_125m (CELL_GEOM) VALUES(ST_GeomFromWKT('...
^
HINT: No function matches the given name and argument types. You might need to
add explicit type casts.
What is the issue here and what can be done about it?
Use function ST_GeomFromText instead of ST_GeomFromWKT.