I have problem with master-details in FireDAC. I have four TFDQueries
master qrPerson
3 details qrAddress, qrPhone, qrEmail
For each of them
SQL is simple query select * from <table>
existing corresponding DataSource
CachedUpdates = true
Connection = conMain
SchemaAdapter = saPerson
Transaction = trMain
UpdateTransaction = trMain
event OnNewRecord for get new ID
For details
FetchOptions.DetailCascade = true
Master = dsPerson
MasterFields = ID_CONTACT
IndexFieldNames = ID_CONTACT
Before save data I get for each of them DataSet.State = dsInsert. I call qrPerson.Post (master) and only one detail (qrEmail) has UpdatesPending = true. The other two details (qrAddress, qrPhone) have UpdatesPending = false. I check events OnAfterPost for details and only one was called, qrEmailAfterPost of course.
And next saPerson.ApplyUpdates and saPerson.CommitUpdates save only data for master and one detail.
Summary of my problem:
I insert record to master and also insert records to each of details. All of them have State = dsInsert. After Post on master, only master and one detail save inserted records into database. Two other details forgot inserted data.
Can you help me with this problem? Thanks
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'm trying to use the column type with OrionMySQLSink. My agent has this code:
cygnusagent.sinks.mysql-sink.type = com.telefonica.iot.cygnus.sinks.OrionMySQLSink
cygnusagent.sinks.mysql-sink.channel = mysql-channel
cygnusagent.sinks.mysql-sink.enable_grouping = false
cygnusagent.sinks.mysql-sink.mysql_host = localhost
cygnusagent.sinks.mysql-sink.mysql_port = 3306
cygnusagent.sinks.mysql-sink.mysql_username = ********
cygnusagent.sinks.mysql-sink.mysql_password = *********
cygnusagent.sinks.mysql-sink.table_type = table-by-destination
cygnusagent.sinks.mysql-sink.attr_persistence = column
cygnusagent.sinks.mysql-sink.batch_size = 1
cygnusagent.sinks.mysql-sink.batch_timeout = 10
I'm having this error when I use the sink:
2015-12-14 08:43:58,118 (SinkRunner-PollingRunner-DefaultSinkProcessor) [ERROR - com.telefonica.iot.cygnus.sinks.OrionSink.process(OrionSink.java:187)] Persistence error (Unknown database 'fiw-serv')
I don't have any problem with row mode, only with column mode.
That's because the column persistence mode of OrionMySQLSink requires the table is created in advance. A detailed explanation can be found here. Basically:
Please observe not always the same number of attributes is notified; this depends on the subscription made to the NGSI-like sender. This is not a problem for the row persistence mode, since fixed 8-fields data rows are inserted for each notified attribute. Nevertheless, the column mode may be affected by several data rows of different lengths (in term of fields). Thus, the column mode is only recommended if your subscription is designed for always sending the same attributes, event if they were not updated since the last notification.
In addition, when running in column mode, due to the number of notified attributes (and therefore the number of fields to be written within the Datastore) is unknown by Cygnus, the table can not be automatically created, and must be provisioned previously to the Cygnus execution. That's not the case of the row mode since the number of fields to be written is always constant, independently of the number of notified attributes.
Something similar occurs with OrionCKANSink, where the resource, datastore and view must be created in advance.
I need a TFDTable object linked to a SQL view (no query, I must use this view!) from a firebird database. The object should accept updates, so I set the UpdateOptions.UpdateTableName property to the underlaying base table:
object fdtPRODUCTS_VIEW: TFDTable
IndexFieldNames = 'PRODUCT_ID'
Connection = FDConnection1
UpdateOptions.UpdateTableName = 'PRODUCTS'
TableName = 'PRODUCTS_VIEW'
Left = 200
Top = 48
end
But UpdateTableName property has no effect: every time I try to update the table I get the message:
[FireDAC][Phys][FB]cannot update read-only view PRODUCTS_VIEW.
According to the documentation wiki page http://docwiki.embarcadero.com/Libraries/XE8/en/FireDAC.Stan.Option.TFDBottomUpdateOptions.UpdateTableName this property is the ideal solution for my problem but I can' get it working.
I've tested this with XE5 and XE8 -> same results.
I want to use the following method to flag people in the Person table so that they can be processed. These people must be flagged as "In Process" so that other threads do not operate on the same rows.
In SQL Management Studio the query works as expected. When I call the method in my application I receive the row for the person but with the old status.
Status is one of many navigation properties off of Person and when this query returns it is the only property returned as a proxy object.
// This is how I'm calling it (obvious, I know)
var result = PersonLogic.GetPeopleWaitingInLine(100);
// And Here is my method.
public IList<Person> GetPeopleWaitingInLine(int count)
{
const string query =
#"UPDATE top(#count) PERSON
SET PERSON_STATUS_ID = #inProcessStatusId
OUTPUT INSERTED.PERSON_ID,
INSERTED.STATUS_ID
FROM PERSON
WHERE PERSON_STATUS_ID = #queuedStatusId";
var queuedStatusId = StatusLogic.GetStatus("Queued").Id;
var inProcessStatusId = StatusLogic.GetStatus("In Process").Id;
return Context.People.SqlQuery(query,
new SqlParameter("count", count),
new SqlParameter("queuedStateId", queuedStateId),
new SqlParameter("inProcessStateId", inProcessStateId)
}
// update | if I refresh the result set then I get the correct results
// but I'm not sure about this solution since it will require 2 DB calls
Context.ObjectContext().Refresh(RefreshMode.StoreWins, results);
I know it is an old question but this could help somebody.
It seems you are using a global Context for your query, EF is designed to retain cache info, if you allways need fresh data must use a fresh context to retrieve it. as this:
using (var tmpContext = new Contex())
{
// your query here
}
This create the context and recycle it. This means no cache was stored and next time it gets fresh data from database not from cache.
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