dynamically give value to query
here we have two queries
1.select eno,ename,sal,deptno from emp. we use this query and create view object and
displayed in jsf page like eno ename sal
1 aaa bbb
2 ccc ddd
2. select dname,loc from dept where deptno=:deptno. Here the :deptno comes when we
clicking eno in jsf page(it displayed in the form of link) the deptno of corresponding record
is asigned to second query.After clicking that link the jsf page look like
eno ename sal
1 aaa bbb
dname:marketing loc: newyork (in form type).here emp,dept names used for only example.
This is a simple master table detail form use case. If you define a view link between the emp and the dep table (emp.deptno = dept.deptno), this works out of the box. In your application module you add the dept vo as child under the emp table.
You should check out view criteria. Example :
http://www.adftips.com/2010/10/adf-model-programmatically-executing.html
Related
I have a MSSQL table of entities that looks like
IdMarker Property1 Property2 ...
411 AAA BBB
567 CCC DDD
...
I need to store in this table only unique IdMarkers. What would be the most performant way to add new entries from a quite large set, however, only adding entries with IdMarker values that are not yet present in the table, using Entity Framework Core (in short, I would like to achieve behaviour similar to what REPLACE does in MySQL dialect)?
INSERT INTO Table1(IdMarker, Propety1, Property2)
SELECT IdMarker
, Property1
, Property2
FROM Table2 WHERE NOT EXISTS
(SELECT * FROM Table1 WHERE Table1.IdMarker = Table2.Idmarker )
I have a requirement that requires a table design , where need to maintain the files uploaded for any applications. Is there a simple way I can achieve this with out any trigger/Sproc?
ID AppName FileName fileorder
1 abc file1 1
2 abc file2 2
3 abc file1 3
4 xyz test1 1 - start a fresh
5 xyz test2 2
6 abc file3 4 - resume from previous value of 'abc'
7 xyz test3 3 - resume from previous value of 'xyz'
8 grt file1 1 - start a fresh
No, there is nothing you can write in a CREATE TABLE that will automatically populate the fileorder column this way. The only way you can do this is with some custom coding.
I don't know your reason for wanting to create a column like this in your table, but for most reasons I can think of, you're probably better off not storing this value in your table at all and either calculating it at query time, or making a VIEW that includes the calculation of this column.
Instead of writing a value of fileorder to the table you'd be better off writing a query to read the table that looks like this:
SELECT ID, AppName, FileName, ROW_NUMBER() OVER(PARTITION BY AppName ORDER BY ID) AS fileorder
FROM YOUR_TABLE -- Whatever your table name is
WHERE AppName in ('abc','xyz','grt') -- Any relevant WHERE clause
ORDER BY ID;
Unfortunately, you can't use Window Functions in a computed column, which would be the only way outside of a stored procedure or a trigger to do this.
I am working on a SSRS 2008 Report that when entering a list of ITEM numbers in a multiple data type parameter will return the Item Number, UPC, Description, and Item Status.
It works.
But my problem is that it sorts my data in my report. Example.
If I enter the following Item Numbers in the parameter:
ZZZ
DDD
AAA
HHH
My report shows the Data alphabetic as:
AAA
DDD
HHH
ZZZ
I want my data to be displayed in the order of the ITEM Number how I enter them.
I have One Data Set:
SELECT ItemNo, UPC, Description, Status
FROM Product
WHERE ItemNo IN (#ITEM)
I have One Parameter:
#ITEM
Datatype: Text
Allow multiple values
Please Help!
You need to parse the string into a table and then set an order to the table you've created. Then you have something to sort by.
First - create a function that you can call in your sp. (the answer to this question gives you exactly what you need)
then, in your query you can use the function just like a table.
DECLARE #x VARCHAR(100)
SELECT #x = 'ZZZ DDD AAA HHH'
SELECT * FROM f_split(#x,' ') param
WHERE param.seq > 1
ORDER BY param.val
I created SSRS report which takes 3 input parameters(rpId, rpStartDate, rpEndDate) and dataset return's user details.
When we are displaying the results in a table/grid, i need to show records based on created_date field returned by dataset. I need display to all the records in the order of date for each date between the date range users chooses and display no'of records under the records info.
For Example:
If your chooses to get records(results) for date range between 1/1/2016(jan 1) to 1/5/2016(jan 5)
I need to display like below in table or grid
Created Date: 1/1/2016
First Name Last Name Middle Name Address1 Address2 City
Sam Test M 123 test Drive 1 England
William Adam A 123 Circle Apt 2013 New York
No of records for 1/1/2016 : 2
Created Date: 1/3/2016
First Name Last Name Middle Name Address1 Address2 City
Aaron Silva B 546 Wood Dr Plaza Delhi
Kapil Sam R 750 Parkwoo Circle Los Angles
Asha Tucker C 1234 Main Dr Briar Rd Dallas
No of records for 1/1/2016 : 3
Can some one please let me know to how display in this way?
Thanks in Advance!
The dataset returned from query should have created_date column. So in short you need to group your detail columns by created_date column. In more details:
Drop a tablix and then drag and drop detail columns into the tablix,
such as first_name, last_name, etc.
At the bottom of the design view, right click the entry within Row Groups, and select "Add Group" - "Parent Group", then select Created_date column from drop down list
At this stage your tablix should have one column (created date) added. Right click the content cell of this column, then from context menu select "Insert Row" - "Inside Group Above"
The newly added blank row should be within the parent group (created date).
Now copy the grouped column content by pressing Ctrl + C(it should be like "[created date]")
Right click the grouped column header and select "delete columns"
select newly added empty row and paste copied content by pressing Ctrl + V
Run the report, now the row contents should be grouped by created_date
You can add "no of records" by adding total - after group
I have a SQL Server table which has the following columns:
Id, HeaderText, ContentText, ProposedContentId, Active
I want to maintain two versions of records that are edited by users using a website. For example, user John could edit the HeaderText and ContentText fields of the following record and click save.
Id, HeaderText, ContentText, ProposedContentId, Active
==> 1, Hello, This is a test, NULL, 1
But instead of updating that same record I want to create another record and point from the old record to new record. Now the table looks like this:
Id, HeaderText, ContentText, ProposedContentId, Active
1, Hello, This is a test, 2, 0
==> 2, Hello World, This is a new post, NULL, 1
As you can see, the old record is marked as not active and now the ProposedContentId points to the newly created row.
I don't know whether this is good solution to this problem. Please suggest better ways if there are any.
Edit: I only need to maintain two copies (old and new) and I cannot create extra tables.
I personally would not use this Active flag as a way of tracking the latest record. This type of identifier gets tricky to maintain.
I would add a content identifier to your table. Then, when a record gets changed, simply insert the new data with the same content identifier. The Id field will auto increment, or you could add a datetime field, then you can track the active record by looking at record the highest Id (or latest timestamp) for that given ContentId.
Id, ContentId HeaderText ContentText
1 1 Hello This is a test
2 1 Hello World This is a new post
3 1 Hello again! The content was changed again
4 2 New Content This is some new text
5 2 Newer Content This is that other record, updated
You could add in an active flag to this setup if you want, but it doesn't really have to be any more complex than each record having it's own identifier like a ContentId and knowing the active record by whatever has the highest ID, or latest timestamp. However you'd prefer to do it.
If you wanted to get the "active" records, all you'd need to do is run something like this:
SELECT A.*
FROM YourTable A
JOIN (
SELECT ContentId, MAX(Id) MaxId FROM YourTable GROUP BY ContentId) B
ON A.ContentId = B.ContentId AND A.Id = B.MaxId
That should give you the following:
Id, ContentId HeaderText ContentText
3 1 Hello again! The content was changed again
5 2 Newer Content This is that other record, updated
I hope this helps or at least gives you some food for thought.