the table is not registered or you do not have access to it (documentum) - dql

I am using documentum data storage and and I have an object table called dm_user . I can fetch data from the table by running a DQL query like :
select * from dm_user where user_name = 'dkfloza'
However when I run a query to update my table such as :
update dm_user set user_email = 'dkfloza#gmail.com' where user_name ='dkfloza'
I recieve an error saying that :
the table is not registered or you do not have access to it

The correct syntax for DQL update in this case is:
UPDATE dm_user OBJECT
SET user_email = 'dkfloza#gmail.com'
WHERE user_name = 'dkfloza'
If you do not provide OBJECT, the parser thinks that you are trying to update a registered table instead of an object.
Please note: DQL does not deal with tables directly (apart from registered tables, which is an exception to this rule). Instead, it deals with objects. Objects consist of several tables that are joined together automatically by the Documentum Content Server. Therefore it is incorrect to state that you have a row in a table called dm_user. Instead, you should say that you have an object of type dm_user.

Related

How to force mapping in copy activity of Azure Data Factory

I am trying to copy data from a cosmosdb container to an Azure SQL database table using Azure Data Factory.
Some of my columns in cosmosdb are not mandatory and might not be defined. The issue is that for every of these columns, I get the following error when running the copy activity :
Data type of column 'MyProperty' can't be inferred from 1st row of data, please specify its data type in mappings of copy activity or structure of DataSet.
However I checked in the mapping tab and the types of these properties are correctly infered to string, and they are well nullable in my SQL stored procedure table type.
I also have the same problem for optional decimal properties where the errors says that the value can't be parsed to Int64, though the infered type in the mapping tab is set to number and not integer...
Here is the mapping I currently have :
And the stored procedure with the table type
CREATE TYPE [dbo].[MyTableType] AS TABLE
(
[Id] varchar(256) NOT NULL PRIMARY KEY,
[SupplierId] varchar(256) NOT NULL,
[SupplierClientId] varchar(256) NULL,
[BuyerId] varchar(256) null
)
CREATE PROCEDURE [dbo].[UpsertItems]
#itemsTable MyTableType readonly
AS
BEGIN
MERGE MyTable AS target
USING #itemsTable AS source
ON (target.Id = source.Id)
WHEN MATCHED THEN
UPDATE SET
SupplierId = source.SupplierId,
SupplierClientId = source.[SupplierClientId],
BuyerId = source.[BuyerId]
WHEN NOT MATCHED THEN
INSERT (Id, SupplierId, SupplierClientId, BuyerId)
VALUES (
source.Id,
source.SupplierId,
source.[SupplierClientId],
source.[BuyerId]);
END
I can't find a way to force the datatype of this property either in the dataset directly of in the mapping tab of the copy activity. How can I fix the issue ?
You can specify the data types if you are creating a new table while copy. But if you are adding or copying to an already existing table, the data type is inferred automatically.
While, auto creating table in copying
If this does not help, please share sample source data and some snips

Need to get data from a table using database link where database name is dynamic

I am working on a system where I need to create a view.I have two databases
1.CDR_DB
2.EMS_DB
I want to create the view on the EMS_DB using table from CDR_DB. This I am trying to do via dblink.
The dblink is created at the runtime, i.e. DB Name is decided at the time user installs the database, based on the dbname dblink is decided.
My issue is I am trying to create a query like below to create a view from a table which name is decided at run time. Please see below query :
select count(*)
from (SELECT CONCAT('cdr_log#', alias) db_name
FROM ems_dbs a,
cdr_manager b
WHERE a.db_type = 'CDR'
and a.ems_db_id = b.cdr_db_id
and b.op_state = 4 ) db_name;
In this query cdr_log#"db_name" is the runtime table name(db_name get's created at runtime).
When I'm trying to run above query, I'm not getting the desired result. The result of the above query is '1'.
When running only the sub-query from the above query :
SELECT CONCAT('cdr_log#', alias) db_name
FROM ems_dbs a,
cdr_manager b
WHERE a.db_type = 'CDR'
and a.ems_db_id = b.cdr_db_id
and b.op_state = 4;
i'm getting the desired result, i.e. cdr_log#cdrdb01
but when i'm trying to run the full query, getting result as '1'.
Also, when i'm trying to run as
select count(*) from cdr_log#cdrdb01;
I'm getting the result as '24' which is correct.
Expected Result is that I should get the same output similar to the query :
select count(*) from cdr_log#cdrdb01;
---24
But the desired result is coming as '1' using the full query mentioned initially.
Please let me know a way to solve the above problem. I found a way to do it via a procedure, but i'm not sure how can I invoke this procedure.
Can this be done as part of sub query as I have used above?
You're not going to be able to create a view that will dynamically reference an object over a database link unless you do something like create a pipelined table function that builds the SQL dynamically.
If the database link is created and named dynamically at installation time, it would probably make the most sense to create any objects that depend on the database link (such as the view) at installation time too. Dynamic SQL tends to be much harder to write, maintain, and debug than static SQL so it would make sense to minimize the amount of dynamic SQL you need. If you can dynamically create the view at installation time, that's likely the easiest option. Even better than directly referencing the remote object in the view, particularly if there are multiple objects that need to reference the remote object, would probably be to have the view reference a synonym and create the synonym at install time. Something like
create synonym cdr_log_remote
for cdr#<<dblink name>>
create or replace view view_name
as
select *
from cdr_log_remote;
If you don't want to create the synonym/ view at installation time, you'd need to use dynamic SQL to reference the remote object. You can't use dynamic SQL as the SELECT statement in a view so you'd need to do something like have a view reference a pipelined table function that invokes dynamic SQL to call the remote object. That's a fair amount of work but it would look something like this
-- Define an object that has the same set of columns as the remote object
create type typ_cdr_log as object (
col1 number,
col2 varchar2(100)
);
create type tbl_cdr_log as table of typ_cdr_log;
create or replace function getAllCDRLog
return tbl_cdr_log
pipelined
is
l_rows typ_cdr_log;
l_sql varchar(1000);
l_dblink_name varchar(100);
begin
SELECT alias db_name
INTO l_dblink_name
FROM ems_dbs a,
cdr_manager b
WHERE a.db_type = 'CDR'
and a.ems_db_id = b.cdr_db_id
and b.op_state = 4;
l_sql := 'SELECT col1, col2 FROM cdr_log#' || l_dblink_name;
execute immediate l_sql
bulk collect into l_rows;
for i in 1 .. l_rows.count
loop
pipe row( l_rows(i) );
end loop;
return;
end;
create or replace view view_name
as
select *
from table( getAllCDRLog );
Note that this will not be a particularly efficient way to structure things if there are a large number of rows in the remote table since it reads all the rows into memory before starting to return them back to the caller. There are plenty of ways to make the pipelined table function more efficient but they'll tend to make the code more complicated.

Find unused labels

Is there any way I can find labels which are not used in D365 FO (labels which dont have references)?
The cross references are stored in database DYNAMICSXREFDB. You can use a sql query to generate a list of labels that have no references.
This query uses two tables in the database:
Names holds an entry for each object in the application that can be referenced.
The Path field of the table holds the name of the object (e.g. /Labels/#FormRunConfiguration:ViewDefaultLabel is the path of the ViewDefaultLabel in the FormRunConfiguration label file.
Field Id is used to reference a record in this table in other tables.
References holds the actual references that connect the objects.
Field SourceId contains the Id of the Names record of the object that references another object identified by field TargetId.
The actual query could look like this:
SELECT LabelObjects.Path AS UnusedLabel
FROM [dbo].[Names] AS LabelObjects
WHERE LabelObjects.Path LIKE '/Labels/%'
AND NOT EXISTS
(SELECT *
FROM [dbo].[References] AS LabelReferences
WHERE LabelReferences.TargetId = LabelObjects.Id)
Make sure to compile the application to update the cross reference data. Otherwise the query might give you wrong results. When I run this query on a version 10.0.3 PU27 environment, it returns one standard label as a result.

Unable to create a field of type Attachement with SQL script in Access database

I'm trying to create a table in an access database.
I've tried the following query but without success:
CREATE TABLE Test ([id] COUNTER (1,1),[AttachedFile] Attachment, [FolderId] Long))
The field of type Attachment seems to be very special. Am'I wrong with the field type ?
Any ideas ?
The workaround was to embed the database in Resources

linq to sql "Contains"

if i have a field in my table that i want to verify exists, how do i use the contains method to determine if it exists.
i would have thought the contains method just takes in a string but it seems to take in my whole linq data object
Contains is an extension method for IEnumerable that determines whether a given object is present in the enumerable. That's not what you want here.
I'm guessing that you have a LINQ query like this:
IEnumerable<string> productNames = from p in db.Products select p.ProductName;
And now you want to verify that the ProductName field actually exists to avoid run-time errors. There is actually no need to check that. Try replacing p.ProductName by a field that doesn't exist. The compiler will complain.
Of course, this assumes that the actual database schema matches the one used to generate the database class with MSLinqToSQLGenerator.
Not sure how to do it with LINQ but you could do:
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE _NAME ='MyTable' and COLUMN _NAME='MyColumn'
then based on the count returned from the query you will know if the column exists or not.

Resources