i've got a few tables in MDS.
One table (clients) ist filled via SQL and the other one is a masterdata table (country) filled by hand.
I have a business rule on table clients:
"Name must be unique" and no b-rule on Country.
I want to validate the data PROGRAMMATICALLY i do not want to CLICK "apply business rules" in explorer window on the webinterface.
I found several threads about how to use the sp mentioned in the title (udpValidateModel) to validate all entities in a model.
well...this thing does nothing. I can see the validationStatus in each of my tables "Awaiting Revalidation" after changing business rules or update data via sql. It doesnt matter what i do the status wont change (neither the validation icons in webui).
i also tried validateentity but the same "nothing" happens.
The SP below:
DECLARE #User_ID int
DECLARE #Model_ID int
DECLARE #Version_ID int
SET #User_ID = (SELECT ID FROM [MasterDataServices].[mdm].[tblUser] where userName = SYSTEM_USER )
SET #Model_ID = (SELECT Top 1 Model_Id FROM [MasterDataServices].[mdm].[viw_SYSTEM_SCHEMA_VERSION]
WHERE Model_MUID = 'MYMODELID')
SET #Version_ID = (SELECT Top 1 VersionNbr FROM [MasterDataServices].[mdm].[viw_SYSTEM_SCHEMA_VERSION]
WHERE Model_MUID = 'MYMODELID'
ORDER BY ID DESC )
EXECUTE [MasterDataServices].[mdm].[udpValidateModel] #User_ID, #Model_ID, #Version_ID, 1
Can anyone help?
SP 'udpValidateModel' works perfectly fine, looks like the parameters you are populating is not correct.
You may correct this as below and try; make sure that the system user has full authorization for the model.
SET #User_ID = (SELECT ID FROM [MasterDataServices].[mdm].[tblUser] where userName = SYSTEM_USER )
SET #Model_ID = (SELECT Top 1 Model_Id FROM [MasterDataServices].[mdm].[viw_SYSTEM_SCHEMA_VERSION]
WHERE Model_MUID = 'MYMODELID')
SET #Version_ID = (SELECT Top 1 VersionNbr FROM [MasterDataServices].[mdm].[viw_SYSTEM_SCHEMA_VERSION]
WHERE Model_MUID = #Model_ID
ORDER BY ID DESC )
Related
Can someone identify why this multi-table join is not accepted? When I bring in the third table, it then fails with invalid table alias. I am not seeing what is wrong:
This works (two table):
select
a.ri as `R_ID`
,oc3.name as `RET`
,a.rch as `RC`
from dev.sl a join dev.codes oc3
on (a.pk_business = oc3.pk_business
and a.pk_data_source = oc3.pk_data_source
and a.pk_frequency = oc3.pk_frequency
and oc3.pk_data_state = '123'
and oc3.code = a.ri and oc3.codeset = 'xyz')
Then add a third table and it fails:
(Three table):
select
a.ri as `R_ID`
,oc3.name as `RET`
,a.rch as `RC`
from dev.sl a join dev.codes oc3
on (a.pk_business = oc3.pk_business
and a.pk_data_source = oc3.pk_data_source
and a.pk_frequency = oc3.pk_frequency
and oc3.pk_data_state = '123'
and oc3.code = a.ri and oc3.codeset = 'xyz') join dev.items b
on (b.pk_business = a.pk_business
and b.pk_data_source = a.pk_data_source
and b.pk_frequency = a.pk_frequency
and b.pk_data_state = '123'
and a.ii = b.item_id
and a.cc = b.country_code)
SemanticException [Error 10009]: Line 1:2920 Invalid table alias 'a':
I have an update - it seems that this was caused by having one table created as an updatable table (TBLPROPERTIES ('transactional'='true')), and one without, and with my session settings of:
SET hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
SET hive.support.concurrency=true;
SET hive.enforce.bucketing=true;
SET hive.exec.dynamic.partition.mode=nonstrict;
This caused the problem. On another session without the settings AND repointing to an identical table "a" created as a non-ACID type table, the multi-table join worked fine. I don't know enough about HIVE to know why - I suspect that a transactional and non-transactional table cannot be joined in the same "transaction" (select statement).
One more update - It may not be due to the transactional table. With additional testing, I now also see it happens with non-transactional tables as well. It seems that the three table join works when I execute it from a putty session directly on the server, but when I use SQL Developer, it will produce the aforementioned error. It appears to be an issue with SQL Developer, but why still is unknown.
I've a report in apex application. Report has filters. I want to add button to run stored procedure. I need to pass filter parameters to stored procedure when button is pressed. How could i do that?
I'm assuming you mean an interactive report? I don't think you need to pass them as parameters - you can look up the filters defined on an interactive report using the apex_application_page_ir_cond table.
Try this example query (copy & pasted below):
SELECT ircond.condition_name, ircond.condition_type, ircol.report_label,
ircond.condition_column_name, ircond.condition_operator,
ircond.condition_expr_type, ircond.condition_expression,
ircond.condition_expression2, ircond.condition_sql,
ircond.condition_display, ircond.condition_enabled
FROM apex_application_page_ir ir
JOIN apex_application_page_ir_rpt irr
ON ir.interactive_report_id = irr.interactive_report_id
JOIN apex_application_page_ir_cond ircond
ON irr.report_id = ircond.report_id
JOIN apex_application_page_ir_col ircol
ON ir.interactive_report_id = ircol.interactive_report_id
AND ircond.condition_column_name = ircol.column_alias
WHERE ir.application_id = TO_NUMBER (:app_id)
AND ir.page_id = TO_NUMBER (:app_page_id)
AND ir.region_name = 'Interactive Report'
AND ircond.condition_type = 'Filter'
AND irr.session_id = :app_session
AND irr.base_report_id =
(SELECT apex_ir.get_last_viewed_report_id (TO_NUMBER (:app_page_id),
ir.region_id)
FROM DUAL)
I want to create basically an update query on Open Office Base (the same way with Ms ACCESS).
Base does not typically use update queries (but see below). Instead, the easiest way to do an update command is to go to Tools -> SQL. Enter something similar to the following, then press Execute:
UPDATE "Table1" SET "Value" = 'BBB' WHERE ID = 0
The other way is to run the command with a macro. Here is an example using Basic:
Sub UpdateSQL
REM Run an SQL command on a table in LibreOffice Base
Context = CreateUnoService("com.sun.star.sdb.DatabaseContext")
databaseURLOrRegisteredName = "file:///C:/Users/JimStandard/Desktop/New Database.odb"
Db = Context.getByName(databaseURLOrRegisteredName )
Conn = Db.getConnection("","") 'username & password pair - HSQL default blank
Stmt = Conn.createStatement()
'strSQL = "INSERT INTO ""Table1"" (ID,""Value"") VALUES (3,'DDD')"
strSQL = "UPDATE ""Table1"" SET ""Value"" = 'CCC' WHERE ID = 0"
Stmt.executeUpdate(strSQL)
Conn.close()
End Sub
Note that the data can also be modified with a form or by editing the table directly.
Under some circumstances it is possible to create an update query. I couldn't get this to work with the default built-in HSQLDB 1.8 engine, but it worked with MYSQL.
In the Queries section, Create Query in SQL View
Click the toolbar button to Run SQL Command directly.
Enter a command like the following:
update mytable set mycolumn = 'This is some text.' where ID = 59;
Hit F5 to run the query.
It gives an error that The data content could not be loaded, but it still performs the update and changes the data. To get rid of the error, the command needs to return a value. For example, I created this stored procedure in MYSQL:
DELIMITER $$
CREATE PROCEDURE update_val
(
IN id_in INT,
IN newval_in VARCHAR(100)
)
BEGIN
UPDATE test_table SET value = newval_in WHERE id = id_in;
SELECT id, value FROM test_table WHERE id = id_in;
END
$$
DELIMITER ;
Then this query in LibreOffice Base modifies the data without giving any errors:
CALL update_val(2,'HHH')
See also:
https://forum.openoffice.org/en/forum/viewtopic.php?f=5&t=75763
https://forum.openoffice.org/en/forum/viewtopic.php?f=61&t=6655
https://ask.libreoffice.org/en/question/32700/how-to-create-an-update-query-in-base-sql/
Modifying table entries from LibreOffice Base, possible?
I'd like to know which is parent/child relationship for task in th TFS datawarehouse or db.
For example the parentID=15662 and childID=15667, where I can find this information in the DW or db?
I think this will get you close to what you need. It just pulls the parent UserStory with a particular ID and all of it's children. The work item types may need to be changed based on your team project template. You can look at the different link types in DimWorkItemLinkType and adjust the query accordingly to get the desired result.
USE Tfs_Warehouse
GO
SELECT story.System_ID AS StoryID
, story.System_Title AS StoryTitle
, task.System_ID AS TaskID
, task.System_Title AS TaskTitle
, linkType.ReferenceName
, linkType.LinkName
FROM CurrentWorkItemView story
LEFT JOIN dbo.vFactLinkedCurrentWorkItem linkToStory
ON story.WorkItemSK = linkToStory.SourceWorkItemSK
LEFT JOIN CurrentWorkItemView task
ON linkToStory.TargetWorkitemSK = task.WorkItemSK
AND task.System_WorkItemType = 'Task'
LEFT JOIN dbo.DimWorkItemLinkType linkType
ON linkToStory.WorkItemLinkTypeSK = linkType.WorkItemLinkTypeSK
WHERE story.System_WorkItemType = 'User Story'
AND story.System_ID = 15662
I am not a experienced programmer, I need to query the Membership User Collection provided in asp.net mvc.
I want the members be able to add other members as friends, I have created a added friend table.
Id,
MemberId,
Friend_MemberId,
DateAdded
I want to display a list of Members which are not added to this list (like filter already existing friends), but unable to query using linq, can anyone suggest a way, links, articles, would it be better to extend memebership class.
There are quite a number of ways you could go about this.
Let's examine one.
You can download the working VS2008 solution here. The example is not an MVC project, but the membership provider works the same regardless.
Stipulations:
You are using default default SqlProviders
You know how to add an ADO.Net Entity Model using the ASPNETDB
Your ASPNETDB serves one application, the default '/'. If this is not the case then you will already have the necessary knowledge to adjust the following guidance.
Create the Friends table in the ASPNETDB:
The following assumes that you are using the default ASPNETDB that is created in app_data. If not, then you have already created and connected to another DB, just take what you need.
Select your project in Solution Explorer, click 'show all files' icon at the top of Solution Explorer, expand 'App_Data' folder and right-click>Open ASPNETDB.MDF.
In Server Explorer you will see your ASPNETDB.
Project>Add New Item>Text File>Friends.sql
Paste query below. Save.
Right click in editor>Connection>Connect>select ASPNETDB
Right click in editor>Execute SQL
Friends.sql
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
CREATE TABLE dbo.Friends
(
Id int NOT NULL IDENTITY (1, 1),
MemberId uniqueidentifier NOT NULL,
Friend_MemberId uniqueidentifier NOT NULL,
DateAdded datetime NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE dbo.Table1 ADD CONSTRAINT
DF_Table1_DateAdded DEFAULT GetDate() FOR DateAdded
GO
ALTER TABLE dbo.Table1 ADD CONSTRAINT
PK_Table1 PRIMARY KEY CLUSTERED
(
Id
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE dbo.Table1 ADD CONSTRAINT
IX_Table1 UNIQUE NONCLUSTERED
(
MemberId,
Friend_MemberId
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE dbo.Table1 SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
Add an ADO.Net Entity Data Model to your project and include, at the minimum, the following:
Tables
Friends
Views
vw_aspnet_MembershipUsers
Query Example:
NOTE: I am by no means a Linq guru. These queries work fine and the generated sql does not seem unreasonable to me, but I am sure there is someone who will have helpful suggestions regarding possible optimizations of the queries.
// there are 3 users: User1, User2 and User3
// User1 has one friend, User2
string username = "User1"; // this would be the User.Identity.Name (currently logged in user)
//
vw_aspnet_MembershipUsers[] friends;
vw_aspnet_MembershipUsers[] notFriends;
using (var ctx = new ASPNETDBEntities())
{
// get the userId
Guid userId = ctx.vw_aspnet_MembershipUsers.First(m => m.UserName == username).UserId;
var usersFriendsQuery = from friend in ctx.Friends
join muser in ctx.vw_aspnet_MembershipUsers on friend.Friend_MemberId equals muser.UserId
where friend.MemberId == userId
select muser;
friends = usersFriendsQuery.ToArray();
Debug.Assert(friends.Count()==1);
Debug.Assert(friends[0].UserName=="User2");
var usersNotFriendsQuery = from muser in ctx.vw_aspnet_MembershipUsers
where ctx.vw_aspnet_MembershipUsers.Any(m =>
ctx.Friends.FirstOrDefault(friend =>
// include self in excluded members
(muser.UserId == userId)
||
// include already friends in excluded members
(friend.MemberId == userId && friend.Friend_MemberId == muser.UserId)
) == null)
select muser;
notFriends = usersNotFriendsQuery.ToArray();
Debug.Assert(notFriends.Count() == 1);
Debug.Assert(notFriends[0].UserName == "User3");
}
// do something interesting with friends and notFriends here