Summing correctly when multiple records exist.
I am building an aging report that will age the documents based on the document date and the date the report is run. Part of the requirement for the report is to display the expense accounts used in the documents being aged. As a result there
can be one or more records for each document. This depends on the number of expense accounts.
The problem I'm running into is when I aggregate the documents by vendor the sum is not correct. This is caused by the additional records for the expense accounts.
How can I get the total correct?
Any thoughts would be appreciated.
Regards,
Ralph
<style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign> </style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign> </style><style><Border> <Color>LightGrey</Color>
<Style>Solid</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign> </style><style></TextRun> </TextRuns>
<Style> <TextAlign>Center</TextAlign> </style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun>
</TextRuns> <Style> <TextAlign>Center</TextAlign> </style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign> </style><style><Border> <Color>LightGrey</Color>
<Style>Solid</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign> </style><style></TextRun> </TextRuns>
<Style> <TextAlign>Center</TextAlign> </style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun>
</TextRuns> <Style> <TextAlign>Center</TextAlign> </style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign> </style><style><Border> <Color>LightGrey</Color>
<Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox39</rd:DefaultName> <Style>
<Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs>
<rd:DefaultName>Textbox40</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns>
<Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox41</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun>
</TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox42</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color>
<Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox43</rd:DefaultName> <Style>
<Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs>
<rd:DefaultName>Textbox127</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns>
<Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox44</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun>
</TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox45</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color>
<Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox46</rd:DefaultName> <Style>
<Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs>
<rd:DefaultName>Textbox47</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns>
<Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox48</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun>
</TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>ACTDESCR</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color>
<Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>DocType</rd:DefaultName> <Style>
<Border> <Color>LightGrey</Color> <Style>Solid</style><style><Format>d</Format> </style><style></Paragraph> </Paragraphs>
<rd:DefaultName>docdate</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><Format>#,0.00;(#,0.00);'-'</Format>
</style><style></Paragraph> </Paragraphs> <rd:DefaultName>DocAmount</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><Format>#,0.00;(#,0.00);'-'</Format>
</style><style></Paragraph> </Paragraphs> <rd:DefaultName>Balance1</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun>
</TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox128</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color>
<Style>Solid</style><style><Format>#,0.00;(#,0.00);'-'</Format> </style><style><TextAlign>=Iif(Fields!Current.Value = 0, "Center", "Default")</TextAlign>
</style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style><Format>#,0.00;(#,0.00);'-'</Format> </style><style><TextAlign>=Iif(Fields!ID31_60_Days.Value
= 0, "Center", "Default")</TextAlign> </style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style><Format>#,0.00;(#,0.00);'-'</Format>
</style><style><TextAlign>=Iif(Fields!ID61_90_Days.Value = 0, "Center", "Default")</TextAlign> </style><style><Border> <Color>LightGrey</Color>
<Style>Solid</style><style><Format>#,0.00;(#,0.00);'-'</Format> </style><style><TextAlign>=Iif(Fields!ID91_120_Days.Value = 0, "Center", "Default")</TextAlign>
</style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style><Format>#,0.00;(#,0.00);'-'</Format> </style><style><TextAlign>=Iif(Fields!Over_121_Days.Value
= 0, "Center", "Default")</TextAlign> </style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontStyle>Italic</FontStyle>
</style><style></Paragraph> </Paragraphs> <rd:DefaultName>ACTNUMST</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontStyle>Italic</FontStyle>
</style><style></Paragraph> </Paragraphs> <rd:DefaultName>ACTDESCR1</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontStyle>Italic</FontStyle>
<Format>#,0.00;(#,0.00);'-'</Format> </style><style></Paragraph> </Paragraphs> <rd:DefaultName>DistAmnt</rd:DefaultName> <Style> <Border>
<Color>LightGrey</Color> <Style>Solid</style><style><FontStyle>Italic</FontStyle> </style><style></Paragraph> </Paragraphs> <rd:DefaultName>Textbox111</rd:DefaultName>
<Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontStyle>Italic</FontStyle> </style><style></Paragraph>
</Paragraphs> <rd:DefaultName>ID31_60_Days</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontStyle>Italic</FontStyle>
</style><style></Paragraph> </Paragraphs> <rd:DefaultName>ID61_90_Days</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontStyle>Italic</FontStyle>
</style><style></Paragraph> </Paragraphs> <rd:DefaultName>ID91_120_Days</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontStyle>Italic</FontStyle>
</style><style></Paragraph> </Paragraphs> <rd:DefaultName>Over_121_Days</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun>
</TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox27</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color>
<Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>Textbox28</rd:DefaultName> <Style>
<Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs>
<rd:DefaultName>Textbox29</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontWeight>Bold</FontWeight>
<Format>#,0.00;(#,0.00);'-'</Format> </style><style></Paragraph> </Paragraphs> <rd:DefaultName>Textbox30</rd:DefaultName> <Style> <Border>
<Color>LightGrey</Color> <Style>Solid</style><style><FontStyle>Italic</FontStyle> <FontWeight>Bold</FontWeight> </style><style></Paragraph>
</Paragraphs> <rd:DefaultName>Textbox133</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontStyle>Italic</FontStyle>
<FontWeight>Bold</FontWeight> <Format>#,0.00;(#,0.00);'-'</Format> </style><style></Paragraph> </Paragraphs> <rd:DefaultName>Textbox31</rd:DefaultName>
<Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontWeight>Bold</FontWeight> <Format>#,0.00;(#,0.00);'-'</Format>
</style><style></Paragraph> </Paragraphs> <rd:DefaultName>Textbox32</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontWeight>Bold</FontWeight>
<Format>#,0.00;(#,0.00);'-'</Format> </style><style></Paragraph> </Paragraphs> <rd:DefaultName>Textbox33</rd:DefaultName> <Style> <Border>
<Color>LightGrey</Color> <Style>Solid</style><style><FontWeight>Bold</FontWeight> <Format>#,0.00;(#,0.00);'-'</Format> </style><style></Paragraph>
</Paragraphs> <rd:DefaultName>Textbox34</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontWeight>Bold</FontWeight>
<Format>#,0.00;(#,0.00);'-'</Format> </style><style></Paragraph> </Paragraphs> <rd:DefaultName>Textbox35</rd:DefaultName> <Style> <Border>
<Color>LightGrey</Color> <Style>Solid</style><style><FontWeight>Bold</FontWeight> <Format>#,0.00;(#,0.00);'-'</Format> </style><style></Paragraph>
</Paragraphs> <rd:DefaultName>Textbox36</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun>
</TextRuns> <Style> <TextAlign>Center</TextAlign> </style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style><Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign>
</style><style></TextRun> </TextRuns> <Style> <TextAlign>Center</TextAlign> </style><style><Border> <Color>LightGrey</Color>
<Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>VENDORID1</rd:DefaultName> <Style>
<Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs>
<rd:DefaultName>Textbox50</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style></TextRun> </TextRuns>
<Style /> </Paragraph> </Paragraphs> <rd:DefaultName>VCHRNMBR2</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><FontWeight>Bold</FontWeight>
</style><style></Paragraph> </Paragraphs> <rd:DefaultName>Textbox52</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</style><style><Border>
<Style>None</style>
Hi rwahlert,
According to your description, you want to sum the records of documents based on vendor. Right?
In this scenario, you mentioned the sum result is not correct because of the additional record of expense accounts. Based on your information, these records are within a document, so it supposed to have a column related to document.
In Reporting Services, we can use a table to display all the records. Set the records group on Document, and add the vendor as the parent group. Please refer to the following link:
Understanding Groups (Report Builder and SSRS). Then use sum function and specify the document group as scope. See:
Sum Function (Report Builder and SSRS)
If you have any question, please feel free to ask.
Best Regards,
Simon Hou
Similar Messages
-
APP-PAY-07201 Cannot perform a delete when child record exists in future
I am trying to put end date to a payment method of any employee in HR/Payroll 11.5.10.2
but receiving the following error message:
APP-PAY-07201 Cannot perform a delete when child record exists in future
Can u advise what steps I should follow to resolve this issue.
Regards /AliThis note is related to termination of employee while our employee is on payroll and just want to change is payment method. But in the presence of existing payment method we cannot attched another becuase we are receiving an error:
APP-PAY-07041: Priority must be unique within an orgainzational payment method -
C#: Sending email from a specific account when multiple accounts exist in Outlook?
Somehow I accidentally deleted this message trying to edit it... sorry.
Microsoft.Office.Interop.Outlook.Application outApp = null;
outApp = Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
MailItem mailItem = (MailItem)outApp.CreateItem(OlItemType.olMailItem);
mailItem.Subject = "Director Script Confirmation Request";
mailItem.To = person;
mailItem.Body = message;
//mailItem.Display(false);
mailItem.Send();
How do I send email from a specific account when multiple accounts exist in Outlook?
Below is the code that I have. I think I'm supposed to use the AddressEntry or AddressEntries to designate where emails are sent from. However, at the moment, I haven't found an example.
SVHello SV,
The MailItem class provides the
SendUsingAccount property which allows to set an Account object
that represents the account under which the MailItem is
to be sent. Here is what MSDN states:
The SendUsingAccount property can be used to specify the account
that should be used to send the MailItem when the Send method
is called.
Sub SendUsingAccount()
Dim oAccount As Outlook.account
For Each oAccount In Application.Session.Accounts
If oAccount.AccountType = olPop3 Then
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using POP3 Account"
oMail.Recipients.Add ("[email protected]")
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
End If
Next
End Sub -
SCD issue when multiple records in the source dataset have same natural key
When I load a dataset into a slowly changing dimension, sometimes the dataset contains multiple records for the same natural key. The rows are different by the column last_update_date (among other possible differences).
The behavior I want is this: if during an ODI job run, the source dataset contains multiple records for one natural key, all records will load into the dimension, but only the record with the greatest last_update_date gets marked as the current record in the dimension. Right now, ODI is marking all of the incoming rows for the natural key as current. Any ideas? Thanks!Last_update_date is on the source but is not being sent to the target. Thus, it doesn't have an SCD behavior. I think my solution will be to pre-process the incoming records so I don't attempt to load multiple rows per natural key. I was just hoping someone here knew of an easier solution.
If it helps, except for the SK, NK, Current Flag, and Effective Date fields, all SCD behaviors are "add row on change". -
Get only one record for an id for a date if multiple record exists
Hi,
I need help with below mentioned scenario.
DB Version: 11.2.0.3.0.
Requirement:
Fetch account records that were created after last run of program
Get latest record for an account on a given date if there are multiple records for same account.
If there is a gap of more than 1 day from last run of program, then get latest record for an account for each date if there are multiple records for same account.
Create table t_test
Id number not null,
cust_id number not null,
cust_Acct_id number not null,
ins_date date not null
insert into t_test values
(1, 12345, 678905, to_date('05/31/2012 12:05:10 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(2, 12345, 678905, to_date('05/31/2012 05:25:46 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(3, 12345, 678905, to_date('05/31/2012 11:48:00 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(4, 12345, 678905, to_date('06/01/2012 12:05:10 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(5, 12345, 678905, to_date('06/01/2012 05:25:46 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(6, 12345, 678905, to_date('06/01/2012 11:48:00 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(7, 12345, 678905, to_date('06/02/2012 12:05:10 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(8, 12345, 678905, to_date('06/02/2012 05:25:46 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(9, 12345, 678905, to_date('06/02/2012 11:48:00 PM','MM/DD/YYYY HH:MI:SS PM'));
create table t_log
id number not null,
prgrm_id number not null,
last_run_date date not null
insert into t_log values
(1,1009,to_date('5/30/2012 07:05:12 AM','MM/DD/YYYY HH:MI:SS PM'));Result required:
id cust_id cust_acct_id ins_date
3 12345 678905 '05/31/2012 11:48:00 PM'
6 12345 678905 '06/01/2012 11:48:00 PM'
9 12345 678905 '06/02/2012 11:48:00 PM'
I tried below sql but it will return only id 9 record.
select
id,
cust_id,
cust_acct_id,
ins_date
from
select
id,
cust_id,
cust_acct_id,
ins_date,
row_number() over (partition by cust_acct_id order by ins_date desc) rn
from
t_test t
where
t.ins_date > (
select
last_run_date
from
t_log l
where
l.prgrm_id = 1009
where rn = 1;Thanks in advance.Try:
SQL> select
2 id,
3 cust_id,
4 cust_acct_id,
5 ins_date
6 from
7 (
8 select
9 t.id,
10 t.cust_id,
11 t.cust_acct_id,
12 t.ins_date,
13 row_number() over (partition by cust_acct_id, trunc(ins_date) order by ins_date desc) r
n
14 from
15 t_test t
16 , t_log l
17 where
18 t.ins_date >= l.last_run_date
19 and l.prgrm_id = 1009
20 )
21 where rn = 1;
ID CUST_ID CUST_ACCT_ID INS_DATE
3 12345 678905 31-05-2012 23:48:00
6 12345 678905 01-06-2012 23:48:00
9 12345 678905 02-06-2012 23:48:00But I now see that Bob already nailed it, while I was testing it ;) -
VS Workflow - Erroring out when multiple records are created by same user
Hi,
I am using SP 2013. I have a visual webpart and custom sequential workflow. The webpart saves the data to a custom list and the workflow is associated to the custom list on Item creation only. In the workflow, I am breaking the role inheritance and setting
permission to specific set of users, and then the normal approval workflow happens. The whole workflow condition works fine, but if the user is raising multiple requests one after another, the workflow seems to break either in the Break inheritance or granting
permission. If the user raises only one or two requests then everything works fine.
Below are the errors which I am getting in the workflow:
Error 1:
Error: Save Conflict. Your changes conflict with those made concurrently
by another user. If you want your changes to be applied, click Back in your Web
browser, refresh the page, and resubmit your changes.
I have already checked this :
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/60ab04fd-9650-427d-a48f-784bc22fae05/workflow-and-save-conflict-your-changes-conflict-with-those-made-concurrently-by-another-user?forum=sharepointdevelopmentprevious_
http://adrianhenke.wordpress.com/2010/08/20/sharepoint-error-save-conflict-your-changes-conflict-with-those-made-concurrently-by-another-user/
I have also implemented the "Reload" thing posted in the above URL. This error only happens when multiple new requests are getting raised by same user. This error does not happen if I terminate the workflow and re-start the workflow.
How to fix this?
ThanksHi,
Based on my understanding, you have a Visual Web Part for adding new item into a list. A workflow will be triggered when item creation in this list. Everything works
fine except when an user adds multiple items in a short period.
If this is the case, plus with the error message, a possible cause is that the SharePoint Server and the workflow engine are not functioning effectively enough to
handle the multiple request in a short time, therefore a scenario is that when there is new item being added into the database, the workflow modifies the “RoleAssignments” property of this item at the same time, this may cause a “Save Conflict” error.
As you said, “If the user raises only one or two requests then everything works fine”, a workaround is that you can disable the adding item function in Visual Web
Part forcibly in a specific period after a new item is being added by current user, it can leave some time for handling the item creation and item modification.
Or if there is a need to submit multiple items concurrently, we can organize the requests into one request, then handle this item with other custom logic in your workflow.
Thanks
Patrick Liang
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
contact [email protected]
Patrick Liang
TechNet Community Support -
Formula claculation in query is not summing correctly when details are remo
have a report that totals 2 columns together and is at the work center level. when I remove the details the totals are wrong but when I show them it comes over correctly. Here is the scenario
work center column a column b sum a+b
XXX 2 2 4
the details however bring in 3 and 5 & 8 for columns respectively. Why would the work center level be wrong. do I need to do anything special in my formula?Hi,
Do you mean the<i> calculate result as propety</i> set to standard Deviation for those KF ? If so , we can not expect as how it would be if we select <i>summation</i> for <i> calculate result as propety</i> .
With rgds,
Anil Kumar Sharma .P -
How to get max sequence number when some record exists in data base table
Hi,
I need to create sequence such a way that it should starts from max value already exists in table.
Example:
I have table like below:
ID NAME
1 A
2 B
3 C
4 D
Now when creating sequence it should start from 5 but I should't hard code STARTS WITH 5 in the create sequence. Is there any way to do this without hard code the max value in the sequence. It should automatically take the max + 1 value for next data when I insert.
CREATE SEQUENCE TEST_SEQ.NEXTVAL
START WITH [Max + 1 val from the table]
MAXVALUE 9999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20
NOORDER;
Thanks.....
Edited by: 998976 on Apr 18, 2013 4:37 AM
Edited by: 998976 on Apr 18, 2013 4:38 AMHi,
The numbers in a CREATE SEQUENCE statement are all literals; no other kinds of numeric expressions are allowed.
You need dynamic SQL to do anything like what you want. For example:
COLUMN seq_start_col NEW_VALUE seq_start
SELECT 1 + MAX (val) AS seq_start_col
FROM table_x;
CCREATE SEQUENCE TEST_SEQ.NEXTVAL
START WITH &seq_start
MAXVALUE 9999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20
NOORDER; -
Fetch the row with latest data,when multiple rows exist for same user
Hi ,
Thanks for reading the post.I have table with the follwoing data.
user requestdate createdate
jake 02/21/2006 15:33:41 02/25/2006 15:33:41
jake 04/20/2006 15:33:41 04/21/2006 15:33:41
jake 04/23/2006 15:33:41 04/24/2006 15:33:41
jill 02/21/2006 15:33:41 02/25/2006 15:33:41
jill 04/20/2006 15:33:41 04/21/2006 15:33:41
The data type of user,reqdate,createdate is varchar2.I want to write a query that
gives me all the users and his latest information.After running the query I am expecting the result
user requestdate createdate
jake 04/23/2006 15:33:41 04/24/2006 15:33:41
jill 04/20/2006 15:33:41 04/21/2006 15:33:41
I am not able to write the correct query.Need help , Thanks
PanduI am sorry Again,Here are the actual tables and the data in them.
SQL> desc test;
Name Null? Type
ID NOT NULL VARCHAR2(22)
OBJECTNAME VARCHAR2(30)
SQL> select id,objectname from test order by objectname;
ID OBJECTNAME
49 Nani
43 Nani
46 jack
41 jack
45 jack
47 jill
42 jill
7 rows selected.
SQL> desc testattr;
Name Null? Type
ID NOT NULL VARCHAR2(22)
ATTRNAME VARCHAR2(22)
ATTRVALUE VARCHAR2(22)
SQL> select * from testattr;
ID ATTRNAME ATTRVALUE
41 rdate 02/21/2006 15:33:41
41 cdate 02/25/2006 15:33:41
45 rdate 04/20/2006 15:33:41
45 cdate 04/21/2006 15:33:41
46 rdate 04/23/2006 15:33:41
46 cdate 04/24/2006 15:33:41
42 rdate 02/21/2006 15:33:41
42 cate 02/25/2006 15:33:41
47 rdate 04/20/2006 15:33:41
47 cdate 04/21/2006 15:33:41
43 rdate 04/04/2006 14:33:41
43 cdate 04/05/2006 16:33:41
49 rdate 05/03/2006 09:32:55
49 cdate 05/05/2006 07:12:55
14 rows selected.All the attributes have data type varchar2.I want to write a query that gives the following result.
objectname (attrvalue)requestdate (attrval)createdate
jack 04/23/2006 15:33:41 04/24/2006 15:33:41
jill 04/20/2006 15:33:41 04/21/2006 15:33:41
Nani 05/03/2006 09:32:55 05/05/2006 07:12:55.Thanks,Need help.
Pandu -
When doing a post to a rest service is it possible to send multiple records in json
Hi I'm trying to develop my first web service and I'm not sure I'm in the correct place. I'm using Oracle application express 4.2.2. on oracle 11g. I followed this example Creating and Using RESTful Web Service in Application Express 4.2 and used java as the client to connect to the web service. I change my employee record to have forename,surname, address1. This is working fine for me. However I need to be able to post complex multiple records to the web service in one call to the web service.
e.g. in the example it sends
{"forename","john":"surname","smith":"address1":"first address line"}
What I would like to send is something like this.
"employees" : [{"forename":"john","surname":"smith","address1":"first address line"},{"forename":"Dave","surname":"Jones","address1":"first address line"}]
Is this possible.
Thanks
Anthonyhi:
you can edit the URI template like below
promotionlist/{accnt_price_id},{addr_row_id}
then you can post multi parameters to Web Service. -
Can't delete master record when matching when matching detail record exist
Hi
on the rel. property:
Delete Record Behaviour = cascading
Prevent masterless Operation =yes
Automatic Query = yesCan't delete Record Master & Detail...
On delete getting error msg.
Can't delete master record when matching when matching detail record exist
am i missing something...!
Regards,
Abdetu...First of all, remember the ripple affect of cascading deletes and updates.
Oracle database allows creating master/detail relationship between tables using foreign keys and allows cascading deletes by defining the FOREIGN KEY constraint with ON DELETE CASCADE clause.
Oracle Forms on the other hand, handle cascade delete thing internally when you set the relation properties.
Now if you have 3 tables with MASTER->DETAIL1->DETAIL2 relationship and you have a form defined with MASTER->DETAIL1 relationship only, it won't let you delete (and save) master or detail record since the third table (DETAIL2) is referencing the rows from DETAIL1 which you are trying to delete.
If DETAIL2 were present on the form, it would have deleted with relation property CASCADING. If you really want that when you delete a master record, all its details should be deleted too, then consider defining FOREIGN KEY constraints with ON DELETE CASCADE and on the form set relation property CASCADING.
And if all master/detail tables are on your form and still it is not allowing you to delete master with cascading, there must be some code preventing it. Check triggers like ON-DELETE, KEY-COMMIT etc what they are doing. -
ORA-01654 error message when inserting multiple records
Hello all,
I have a Test table with attributes TEST_ID, TEST_NAME, TEST_DATE, STATUS, and want to insert multiple records into this table based on user input form. If user select a value from the drop down list, and the number of records to insert into the Test table, the application should insert that many into the Test table with the same TEST_DATE, STATUS, but TEST_NAME should be the drop down list value + i (1....the number of inserted records). I manually created the form, and wrote a sql for the process.
For example if the user select MUSIC, 3 then data should look like this
TEST_ID TEST_NAME TEST_DATE STATUS
1 MUSIC1 04/06/2010 Y
2 MUSIC2 04/06/2010 Y
3 MUSIC3 04/06/2010 Y
I got the error ORA-01654: unable to extend index TEST_TOOL_ID.TEST_PK by 128 in table space FLOW_13120862905990037739.
The process query
DECLARE IDTEST NUMBER := 1;
BEGIN
WHILE (IDTEST < :P1_COUNT + 1) LOOP
INSERT INTO TEST ( TEST_NAME, TEST_DATE, STATUS )
VALUES ((:P1_TEST_NAME || ' ' ||IDTEST), SYSDATE, 'Y');
END LOOP;
END;
Here is the link to this application
http://apex.oracle.com/pls/apex/f?p=4000:1:3173416575551580::NO:RP:FB_FLOW_ID,F4000_P1_FLOW:32828,32828
Any help would be appreciated.
Thanks,
KarolineThis is the output i get when i change the getMessage with printStackTrace.
String getMessage() replaced with printStackTrace:
G:\studies\Chapter11\MakeDB.java:33: 'void' type not allowed here
System.out.println("Could not drop primary key on UserStocks table: "
^
G:\studies\Chapter11\MakeDB.java:43: 'void' type not allowed here
System.out.println("Could not drop UserStocks table: "
^
G:\studies\Chapter11\MakeDB.java:54: 'void' type not allowed here
System.out.println("Could not drop Users table: "
^
G:\studies\Chapter11\MakeDB.java:64: 'void' type not allowed here
System.out.println("Could not drop Stocks table: "
^
G:\studies\Chapter11\MakeDB.java:83: 'void' type not allowed here
System.out.println("Exception creating Stocks table: "
^
G:\studies\Chapter11\MakeDB.java:102: 'void' type not allowed here
System.out.println("Exception creating Users table: "
^
G:\studies\Chapter11\MakeDB.java:119: 'void' type not allowed here
System.out.println("Exception creating UserStocks table: "
^
G:\studies\Chapter11\MakeDB.java:133: 'void' type not allowed here
System.out.println("Exception creating UserStocks index: "
^
G:\studies\Chapter11\MakeDB.java:159: 'void' type not allowed here
System.out.println("Exception inserting user: "
^
9 errors
Tool completed with exit code 1 -
Code to sum up multiple record key figure values from one ODS to another OD
We've got two ODSs: ODS1 and ODS2 and ODS1 feeds data to ODS2 through update rule. In ODS1, multiple records could contain one same doc records and we would like to sum up a key figure value for these multip records with the same doc number in the update rule and populate a key figure (a sum-up value or total value) in ODS2 for this doc number. We wonder how the code would look like.
Welcome the valuable input!
ThanksHello Kevin,
In this case there is no need of a code. As in ODS2, contract number is a key and PO is not a part of key, you can have update type for the key figure as "Addition". Value for that particular key figure will be added for all the recordes with same contract number irrespective of PO number.
Hope it helps.
Regards,
Praveen -
Suppressing alert message when records exist
I have a block B - ret_print where the user can see the records entered from block A - ret_view. I want to add a message to a button in block A when there are no records to see in block B. I tried the code below with WHEN-BUTTON-PRESSED trigger in block A but get the alert even when there is a record to view in block B. How can I write this so that the alert does not show when records exist to view? Thanks!
if (:ret_print.card_no is null) then
alert_for_val('stop_alert', 'There Are
No Records To View.');
raise form_trigger_failure;
else
go_block('ret_print');
execute_query;
end if;In the original post ret_print is block B.
My interpretation of the problem is that the form needs to know how many records will be retrieved by a query in block B before it actually does the query. One way to do this would be to do a SQL select and then do execute_query if records exist. Or you could turn the problem on its head as I did in my earlier post - use execute_query to see if records exist and override the default message if there are none found. -
Save required when adding record to avoid multiple record entries@same time
Hello, just wondering if anyone would be so kind as to help me out. I have a small problem that when a user is adding records to my form I want them to add one, then if they go on to add another at the same time (before commiting the first one) that they will be shown a prompt Which states something along the lines of "Before you add another record you must first save the first record, do you wish to do so" , yes will then commit the first record and allow the user to enter the second record, whilst cancel will not allow a second record to be entered.
If anyone would helpout i would be very grateful.Hi
Here is my suggestion, the idea is to use a global variable to memorize the fact that a record has been created :
KEY-CREREC
begin
if :GLOBAL.<BLOCK-NAME>RECORDCREATED = 'FALSE' then
create_record;
:GLOBAL.<BLOCK-NAME>RECORDCREATED := 'TRUE';
else
message('Commit or delete before inserting a new record');
message('Commit or delete before inserting a new record');
end if;
end;
=====================================================================
KEY-DELREC
begin
if :system.record_status in ('NEW','INSERT') then
:GLOBAL.<BLOCK-NAME>RECORDCREATED := 'FALSE';
end if;
delete_record;
end;
====================================================================
KEY-COMMIT
begin
commit_form;
:GLOBAL.<BLOCK-NAME>RECORDCREATED := 'FALSE';
end;
====================================================================
POST-SELECT
:GLOBAL.<BLOCK-NAME>RECORDCREATED := 'FALSE';
====================================================================
It's a bit more complicated if you allow the user to go beyond the last record for creating a new record, as KEY-CREREC and KEY-DELREC are not triggered.
In this case, my suggestion is the following :
KEY-CREREC
begin
if :GLOBAL.<BLOCK-NAME>RECORDCREATED = 'FALSE' then
if :system.last_record = 'TRUE'then
next_record;
else
create_record;
:GLOBAL.<BLOCK-NAME>RECORDCREATED := 'TRUE';
end if;
else
message('Commit or delete before inserting a new record');
message('Commit or delete before inserting a new record');
end if;
end;
===============================================================
WHEN-NEW-RECORD-INSTANCE
begin
if :system.mode = 'NORMAL' then
if :system.record_status = 'NEW' and :system.last_record = 'TRUE' then
if :GLOBAL.<BLOCK-NAME>RECORDCREATED = 'TRUE' then
message('Commit or delete before inserting a new record');
message('Commit or delete before inserting a new record');
delete_record;
end if;
end if;
end if;
end;
================================================================
KEY-DELREC
begin
if :system.record_status in ('NEW','INSERT') then
:GLOBAL.<BLOCK-NAME>RECORDCREATED := 'FALSE';
end if;
delete_record;
end;
=================================================================
KEY-COMMIT
begin
commit_form;
:GLOBAL.<BLOCK-NAME>RECORDCREATED := 'FALSE';
end;
===============================================================
WHEN-VALIDATE-RECORD
begin
if :system.record_status = 'INSERT' and :system.last_record = 'TRUE' then
:GLOBAL.<BLOCK-NAME>RECORDCREATED := 'TRUE';
end if;
end;
==================================================================
POST-SELECT
:GLOBAL.<BLOCK-NAME>RECORDCREATED := 'FALSE';
================================================================
Maybe you are looking for
-
TS4095 iPhoto quit unexpectedly and erased imported photos
After recently importing photos from my memory card into iPhoto I opted to erase pictures from memory stick because of limited space. When I clicked erase iPhoto quit unexpectedly and now my photos are not in my library or on the memory stick. Are th
-
Was in the History to get to a site I visited earlier this morning, but it is claiming that I visited a handful of sites from a training that I took last week. Since it was a site I have been to, I no longer suspect anything suspicious. Why would Fir
-
Re: Apple address book application PRINT PROBLEM
When printing a hard copy of my address book, I encounter these problems... 1, in any print format I use, whether compact or indexed, whether I choose landscape or portrait, some info for the last contact in a column will "wrap" up to the next colum
-
please update your Adobe reader app. Optimize for windows phone 8,1 and fix crashing after resuming.add fast app resume
-
Adding note to Office 365 contact
Hi there! I'm using the Office 365 REST API to interact with contacts. I know that Exchange is behind Office 365, so maybe you can help me with this question... First, I get the contact ID by querying: https://outlook.office365.com/ews/odata/Me/Conta