I am creating a point geometries in a view from an x,y column in a postgresql/postgis table.
I do:
create or replace view my_points as
select
ST_SetSRID(ST_MakePoint(geo.x,geo.y), 2154) as geom,
pg_typeof(geom) as type
from table1
join table2 geo on table1.id = geo.id
Everything works fine in postgresql and I can see that this returns a view with a geometry in the column geom. Just for the sake of checking the type there is a second column type that checks if the format of geom is a geometry.
Now when I am in QGIS and try to bring the view in my layer list the following message appears:
Layer is not valid: The layer dbname='x' host=x port=5432 user='x' password='x' sslmode=x key='geom' srid=2154 type=POINT table="public"."my_points" (geom) sql= is not a valid layer and can not be added to the map
What is happening? Is not possible to create a geom in a query to be imported in QGIS?
ps: I use QGIS 2.8.1
You can load a PostGIS view in QGIS. However, your view needs to have a column with unique values for each row that can act as primary key. In QGIS, in the "Add PostGIS Table(s)" dialog, you need to specify this column in the "Primary Key" menu (in the screenshot below, this column is called id_tronc; the menu shows all available columns).
EDIT: The above solution will work, but the answer is not completely correct. QGIS does not need a Primary Key, at least newer versions. Problem was probably column type, see #tommaso-di-bucchianico's answer.
The problem is the field geom which is of type regtype. I don't know why exactly do this disturb Qgis but it does.
Change it to text and the view will work:
create or replace view my_points as
select
ST_SetSRID(ST_MakePoint(geo.x,geo.y), 2154) as geom,
pg_typeof(geom)::TEXT as type
from table1
join table2 geo on table1.id = geo.id
While specifying the primary key column in the "Add PostGIS Table(s)" dialog will certainly work, I wanted the convenience of a simple drag and drop (from Browser Panel to Layer Panel). What worked for me was to reorder the columns in the view definition so that the primary key column is first. Then I was able to simply drag the view from the Browser Panel directly into Layers Panel without error.
Related
I have a small problem during the creation of a database using MS Access. I know that setting right "row source" field (setting "Display control: Combo Box" in "Lookup" label), it is possible to have a Combo Box with the possibilty to choose field from another table (in a many-to-one relationship). For example I have these two tables:
"bank_account":
"client":
Having idclient as foreign key of client table. Setting "row source" to this field in this way:
SELECT client.IDclient, [client].[c_name] FROM client;
I should have a combobox with the list of "client.c_name" field of "client" table, connected by "IDclient". But I have just a list with "IDclient":
I would something like that:
How should I do?
And in "relationship" view, I had to create all the relationships by hand, I thought that in this way were created automatically. However, in "relationship" view I don't have the directions (many, or 1):
But it is a many-to-one relationship. I would something like that:
How should I do?
The reason you're only seeing the IDClient rather than the name is because even though you're using a lookup, you need to be sure you're setting your column count=2 and set the column widths so that the first column is 0cm, second column a suitable amount to display the client name. There are a host of issues with using lookups, but I won't cover that here.
As far as relationships go, go to your relationships window, right click on the connection between the tables you have an interest in editing to relationship of, and appropriately select the one-to-many relationship you're expecting.
Hei,
I want to display in EA a data model for an existing database containing about 150 tables, the primary objective being to show the relations between the tables and the logic of the database.
I imported first the tables definition using the EA ODBC import function, so far so good. But now, to display a simpler diagram, I would like to hide all non primary/foreign key columns. How can I do that?
Tried the following:
Right click in the diagram and go to "Properties/Elements/Show Compartments" I can deselect "Attributes" - but ALL columns will be hidden
Same as above and select "Operations", this display the operation associated with the primary/foreign, NOT the columns themselves
I dont want to manually remove the columns because first it is a lot of work and 2nd I still want to be able to access the columns properties when selecting a table. Any idea how to do that?
You can manually hide the attributes (columns) on a diagram.
Right click on an element and select Features & Properties|Feature and Compartment visibility
Then click on the custom button in the Attributes section and select only those that you want to show/hide
I have original data as shown above with a single record. I have name of the field in one column and value in another column. I need to transform make the heading dynamic as shown below.
I tried with table pivot table and trellis, not no success.
You should be able to do this in a pivot table in OBIEE.
Please see my below screenshot. I was able to get my column originally named 'Total Contracted Cases' to now be called 'USD' because that is the value in the column 'Currency Code'. So for you, you should be able to get the column 'PARAM_VAL1' to be called 'COUNTRY' because that is the value in the column 'PARAM_CD1'. See below for my example:
In the second image, be sure to click on the 'Measure Lables' properties to hide the value.
For columns that are not metrics (no aggregation rule set) that will be used in the 'Measures' section of the pivot table, you will have to define an aggregation rule in the column properties dialog box to keep the value from being converted to null. If your data is as you say it is (a single record), then this should not be an issue; you should be able to pick any aggregation rule and not have to worry about dropping data.
I like working on my schema directly within a database diagram. From there, you can set table properties, column properties, add columns, remove, etc. (in addition to, of course, being able to easily define relationships).
However, it doesn't seem to be possible to insert a column at the end of a table's columns or to reposition existing columns. I can insert a column by selecting an existing column and right-clicking > "Insert Column", but that column always appears above the selected column. When I do this and create the column, I cannot drag it to reposition the column despite the drag cursor appearing.
Is there a workaround?
I like to use database diagrams too. If you right click on the header of the table and select Table View -> Standard you will be presented with an editable grid which allows you to add a column to the end of the table.
I should also say that you can also use Table View -> Modify Custom to allow you to modify all attributes of a column such identity etc. Once you have done this you can use Table View -> Custom to be able to update these.
Step 1: User right click on table
Step 2: User left click on "Standard (menu item)"
Step 3: User left click
Step 4: User keyboard input to enter new column
Thank You
I have a small question regarding access. When you create two tables and specify a particular relationship (e.g. one to many) and enforce referential integrity, when you access the table that corresponds to the "one" you get a small "+" icon on the side that will show you all the entries in the "many" table that correspond to the "one".
Is there any way to emulate this in designing a query? such that for each entry, you can expand them to show the results of a subquery involving each individual result of the main query?
You can do something similar already, but it would look like this
Assuming Table1Entry1 corresponds to Table2Entry1 and Table2Entry2 while Table1Entry2 corresponds to Table2Entry3 and Table2Entry4
this is what it would look like once you view the query results
Table1Entry1 Table2Entry1
Table1Entry1 Table2Entry2
Table1Entry2 Table2Entry3
Table1Entry2 Table2Entry4
when what I want is something like
Table1Entry1
-> Table2Entry1
-> Table2Entry2
Table1Entry2
-> Table2Entry3
-> Table2Entry4
If it's not possible when designing a Query, that's fine. But is it possible to generate something like this for reports or forms?
I know this is mainly a cosmetic thing, but it would be much nicer and intuitive compared to the alternatives
It's termed Subdatasheet
In Datasheet view, open the table or query where you want to add the
subdatasheet.
On the Home tab, in the Records group, click More, point to
Subdatasheet, and then click Subdatasheet.
In the Insert Subdatasheet dialog box, select the tab (Tables,
Queries, or Both) that corresponds to the type of object that you
want to insert as a subdatasheet.
In the Link Child Fields box, click the field that you want to use
as the foreign key or matching field that will provide data for the
subdatasheet.
In the Link Master Fields box, click the field that you want to use
as the primary key or matching field for the main table or query,
and then click OK.
NOTE The values in the Link Child Fields and Link Master Fields boxes create a one-to-many join on the specified fields.
To display the subdatasheet that you added to your table, query, or
form, click the + sign.
NOTE The child (foreign key) field does not appear as a column of the subdatasheet. When you add a new record in the subdatasheet, Access automatically inserts the primary key value of the selected base-table.