create polygon in mapbasic mapinfo - mapinfo

Create Table "parsel" (Parsel_Adi Char(10)) file "D:\data\parsel\parsel.tab" TYPE NATIVE
Charset "WindowsLatin1"
Create Map For parsel CoordSys Earth Projection 8, 28,"m", 33, 0, 0.9996, 500000, 0
Map from parsel
Set Map Layer parsel Editable On
Create Region Into Variable obj_parsel 0
Alter Object obj_parsel Node Add ( 417000, 4401000)
Alter Object obj_parsel Node Add ( 418000, 4401000)
Alter Object obj_parsel Node Add ( 417000, 4403000)
Alter Object obj_parsel Node Add ( 418000, 4400300)
Insert Into parsel(Object, Parsel_Adi) Values (obj_parsel, "SEMIH")
Commit Table parsel Interactive
this is my code. I try to create parsel table but it does not work?

As far as I can see there is no valid end node for a region. A region is closed by a node the same as the start node. try adding;
Alter Object obj_parsel Node Add ( 417000, 4401000)

Related

How to add existing table column in existing projection segmented by hash clause in vertica db?

I have created one table and have one projection of that table. I have to add existing table column in existing projection segmented by hash clause in vertica db.
"I have to add SBS_ALERT_ID column in existing projection segmented by hash clause without creating new projection."
CREATE TABLE public.ALERT
(
AS_OF_DATE date,
ALERT_ID int,
LOAN_NUMBER varchar(20),
SERVICER_LOAN_NUMBER varchar(20),
SBS_LOAN_NUMBER varchar(20),
SBS_ALERT_ID int,
ALERT_TYPE_ID varchar(25),
);
CREATE PROJECTION public.ALERTTT_SEG /*+createtype(D)*/
(
AS_OF_DATE ENCODING RLE,
ALERT_ID ENCODING DELTARANGE_COMP,
LOAN_NUMBER ENCODING ZSTD_FAST_COMP,
SERVICER_LOAN_NUMBER,
SBS_LOAN_NUMBER ENCODING RLE,
SBS_ALERT_ID ENCODING DELTARANGE_COMP,
ALERT_TYPE_ID,
)
AS
SELECT ALERT.AS_OF_DATE,
ALERT.ALERT_ID,
ALERT.LOAN_NUMBER,
ALERT.SERVICER_LOAN_NUMBER,
ALERT.SBS_LOAN_NUMBER,
ALERT.SBS_ALERT_ID,
ALERT.ALERT_TYPE_ID,
FROM public.ALERT
ORDER BY ALERT.LOAN_NUMBER,
ALERT.SBS_LOAN_NUMBER
SEGMENTED BY hash(ALERT.LOAN_NUMBER, ALERT.SBS_LOAN_NUMBER) ALL NODES;
Do you mean something like this?
Initial situation:
CREATE TABLE segby (
fullname varchar(12),
dob date
);
CREATE PROJECTION segby_super /*+basename(segby),createtype(A)*/ (
fullname,
dob
)
AS
SELECT segby.fullname,
segby.dob
FROM segby
ORDER BY segby.fullname,
segby.dob
SEGMENTED BY hash(segby.dob, segby.fullname) ALL NODES OFFSET 0;
Then, you add a column and initialise it with a DEFAULT ...
ALTER TABLE segby ADD id INT NOT NULL DEFAULT HASH(dob,fullname);
And subsequently, you make sure the table is segmented by that new column, by creating such a projection:
CREATE PROJECTION segby_id
AS SELECT
id
, fullname
, dob
FROM segby
ORDER BY id
SEGMENTED BY HASH(id) ALL NODES;
And finish by running a REFRESH on your table ...
SELECT REFRESH('segby');
-- out REFRESH
-- out -
-- out Refresh completed with the following outcomes:
-- out Projection Name: [Anchor Table] [Status] [Refresh Method] [Error Count] [Duration (sec)]
-- out ----------------------------------------------------------------------------------------
-- out "dbadmin"."segby_id": [segby] [refreshed] [scratch] [0] [0]
For your specific question: It looks as if you would like to be able to fire a command like:
ALTER PROJECTION public.ALERTTT_SEG
SEGMENTED BY hash(ALERT.LOAN_NUMBER, ALERT.SBS_LOAN_NUMBER,ALERT.SBS_ALERT_ID) ALL NODES;
This simply does not work.
You will have to create a new projection, segmented the new way, refresh the table, and drop the original projection

neo4j delete nodey with children and without

I have simple graph and i want to find category and delete it. If category has children, than delete category and all children. I've made deletion category with children with this command:
MATCH path = (c:Category)-[*]->(cc:Category)
WHERE c.id = "95bec604-5da2-4297-b792-5a866e292df4"
DETACH DELETE path
But this comamnd does not work for single node, without children. How i can achieve it?
Add a 0 as the lower bound for the variable-length pattern. By default it's 1, but when it's 0 (provided the label used for the end node is also on the start node) this will allow it to match even when there are no relationships from the start node.
MATCH path = (c:Category)-[*0..]->(cc:Category)
WHERE c.id = "95bec604-5da2-4297-b792-5a866e292df4"
DETACH DELETE path
In general, this approach would work if you want to delete the entire path:
MATCH path = ( some path )
FOREACH (node IN nodes(path) |
DETACH DELETE node
)

UPDATE table SET column=DEFAULT not working

What is the correct way to UPDATE a column to the DEFAULT value?
The documentation suggests that it can be used only in INSERT statements.
drop table if exists testjulian;
create table testjulian(
jul REAL NOT NULL DEFAULT ( julianday('now'))
,whatever STRING);
insert into testJulian values(null,"a"); --null not allowed
insert into testJulian(whatever) values("b"); --default value is used
update testjulian set jul= DEFAULT ; --syntax error
update testjulian set jul= NULL ; --null not allowed
The DEFAULT keyword is limited to being used when creating a table and it is designed for when inserting.
It cannot be used for an update, hence the syntax error.
In your case you could use :-
update testjulian set jul = julianday('now');
Or if you really wanted to dynamically get the DEFAULT value you could extract it from the sql column of sqlite_master.
e.g. using
SELECT sql FROM sqlite_master WHERE name = 'testjulian';
gives you :-
CREATE TABLE testjulian(jul REAL NOT NULL DEFAULT (
julianday('now')),whatever STRING)

How to create multiple vertex in SAP HANA Graph

I'm trying to create 2 (multiple) vertex in SAP HANA like -
Create two table for vertex ITEM and DATASET
CREATE COLUMN TABLE "GREEK_MYTHOLOGY"."ITEM" (
"ITEM_ID" VARCHAR(100) PRIMARY KEY,
"ITEM_NAME" VARCHAR(100)
);
CREATE COLUMN TABLE "GREEK_MYTHOLOGY"."DATASET" (
"DATASET_ID" VARCHAR(100) PRIMARY KEY,
"DATASET_NAME" VARCHAR(100)
);
And creating edge as REFERENCES
CREATE COLUMN TABLE "GREEK_MYTHOLOGY"."REFERENCES" (
"REF_ID" INT UNIQUE NOT NULL,
"SOURCE" VARCHAR(100) NOT NULL
REFERENCES "GREEK_MYTHOLOGY"."ITEM" ("ITEM_ID")
ON UPDATE CASCADE ON DELETE CASCADE,
"TARGET" VARCHAR(100) NOT NULL
REFERENCES "GREEK_MYTHOLOGY"."DATASET" ("DATASET_ID")
ON UPDATE CASCADE ON DELETE CASCADE,
"TYPE" VARCHAR(100)
);
Now I would like to connect both vertex (ITEM and DATASET) with edge REFERENCES like below
CREATE GRAPH WORKSPACE "GREEK_MYTHOLOGY"."GRAPH"
EDGE TABLE "GREEK_MYTHOLOGY"."DATASET"
SOURCE COLUMN "SOURCE"
TARGET COLUMN "TARGET"
VERTEX TABLE "GREEK_MYTHOLOGY"."ITEM" KEY COLUMN "ITEM_ID"
VERTEX TABLE "GREEK_MYTHOLOGY"."DATASET"KEY COLUMN "DATASET_ID"
KEY COLUMN "REF_ID";
But it throws this exception at line VERTEX TABLE "GREEK_MYTHOLOGY"."DATASET"KEY COLUMN "DATASET_ID":
sql syntax error: incorrect syntax near "VERTEX": line 6 col 1 (at pos 200)
Is it possible to create multiple vertex in SAP HANA graph ? If yes then what is the right way to do this.
There's a misunderstanding here. The REFERENCES clause in the CREATE TABLE statement has nothing to do with the graph structure you want to represent.
Instead, it defines a foreign key constraint between the two tables.
The CREATE GRAPH WORKSPACE command only accepts one EDGE TABLE and one VERTEX TABLE as parameters.
However, you can also pass in synonyms or views here.
That way, you could create a view "ALL_ITEMS" like this:
CREATE VIEW "GREEK_MYTHOLOGY"."ALL_ITEMS" as
SELECT "ITEM_ID" as "ID", "ITEM_NAME" as "NAME" FROM "GREEK_MYTHOLOGY"."ITEM"
UNION
SELECT "DATASET_ID" as "ID", "DATASET_NAME" as "NAME" FROM "GREEK_MYTHOLOGY"."DATASET";
and then reference this view:
CREATE GRAPH WORKSPACE "GREEK_MYTHOLOGY"."GRAPH"
EDGE TABLE "GREEK_MYTHOLOGY"."DATASET"
SOURCE COLUMN "SOURCE"
TARGET COLUMN "TARGET"
VERTEX TABLE "GREEK_MYTHOLOGY"."ALL_ITEMS"
KEY COLUMN "NAME";
Using this approach is possible, but you now have to make sure that the "NAME" values are unique and not NULL across both tables.

SQLite trigger to update row gets stuck

I'm trying to set on insert, or update, an attribute of a point layer with an attribute derived from a polygon layer (12-digit watershed identifier) in the same database. So this is using SpatiaLite (a spatial extension of SQLite), but that's a detail and this should simply be a SQL problem.
So, I created two triggers below. The UPDATED_ON portion where it sets the timestamp of the action works great. But the spatial parts always assign the same value regardless of where the point occurs as illustrated in the attached example. It seems to be performing the same test for all the rows, with input from one row, but applying to the wrong row. So, something in the SQL of the trigger must be grabbing the wrong point to perform the operation with. Is it the new.rowid part?
CREATE TRIGGER INSERT_UDT_HUC12 AFTER INSERT ON mypoints
BEGIN
UPDATE mypoints SET UPDATED_ON = DATETIME('NOW') WHERE rowid = new.rowid;
UPDATE mypoints SET WBD_HUC12 =
(SELECT HUC_12 FROM cumberland_huc12, mypoints
WHERE st_intersects(mypoints.Geometry, cumberland_huc12.Geometry))
WHERE mypoints.rowid = new.rowid;
END;
CREATE TRIGGER UPDATE_UDT_HUC12 AFTER UPDATE ON mypoints
BEGIN
UPDATE mypoints SET UPDATED_ON = DATETIME('NOW') WHERE rowid = new.rowid;
UPDATE mypoints SET WBD_HUC12 =
(SELECT HUC_12 FROM cumberland_huc12, mypoints
WHERE st_intersects(mypoints.Geometry, cumberland_huc12.Geometry))
WHERE mypoints.rowid = new.rowid;
END
The subquery that returns the new watershed identifier is as follows:
SELECT HUC_12 FROM cumberland_huc12, mypoints
WHERE st_intersects(mypoints.Geometry, cumberland_huc12.Geometry)
Note that this returns all watersheds that intersect any point in mypoints.
Therefore, your trigger will receive the one that happens to be the first in this query.
You have to use the filter WHERE mypoints.rowid = new.rowid also in the subquery.

Resources