Count(*) column in Mapping
Hi All,
We would like to create mapping with the following sql statment.
SELECT DESC AS DESCRIPTION,
COUNT ( ) AS RECORDS*
FROM VIEW A
GROUP BY DESC;
Any suggestions how can we pull COUNT(*) as Records column in mapping level.
Regards,
Ava
You can use Aggregator operator and type in output column expression COUNT(*) or you can use Expression operator and use COUNT analytic function.
Similar Messages
-
Hi,
After using sql loader to import informations in the table fa_mass_additions and after the functionnal uses a treatment to imputate this assets, it asks me to do an update on the table fa_additions to change the value of attribute1 but i get an error
Error report:
ORA-01779: cannot modify a column which maps to a non key-preserved table
ORA-06512: at line 11
01779. 00000 - "cannot modify a column which maps to a non key-preserved table"
*Cause: An attempt was made to insert or update columns of a join view which
map to a non-key-preserved table.
*Action: Modify the underlying base tables directly.
please how can i do this update?Hi,
The "fa_additions" is a view, not a table.
You should update the base table "fa_additions_b".
Regards,
Bashar -
Repeated column in mapping error - Hibernate mapping
Hi, I am relatively new to using Hibernate. I have two tables which I have tried to map unsuccesfully.
Table 1:
Primary Key(Instrument) -> Generated using function.
Table 2:
Primary Key(Instrument) -> Referenced from primary key of table 1
Table 3:
Primary Key(Instrument) -> Referenced from primary key of table 2
Additional Column(Parent_Instrument) -> Referenced from the primary key of table 2
So, two columns in Table 3 have to be mapped to the primary key of table 2.
I have tried mapping them but am getting the following error:
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.db.csb.model.securitycreation.entities.tradegate.WiBonds column: INSTRUMENT (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:652)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:674)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:696)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:450)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:807)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:740)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
... 32 moreThe following is my code:
TABLE 2
@Entity
@Table(name="BOND_SPEC")
@Id
@GenericGenerator
@GeneratedValue
@Column(name="INSTRUMENT", nullable=false,insertable=false,updatable=false)
public long getInstrument() {
return instrument;
public void setInstrument(long instrument) {
this.instrument = instrument;
@OneToMany
@JoinColumn(name = "INSTRUMENT", nullable=false, insertable=false)
public Set<WiBonds> getWiBonds(){
return Wi_Bonds;
public void setWiBonds(Set<WiBonds> Wi_Bonds){
this.Wi_Bonds = Wi_Bonds;
TABLE 3
@Entity
@Table(name="WI_BONDS")
@Id
@GenericGenerator(name = "fk_bondspec", strategy = "foreign", parameters = { @Parameter(name = "property", value = "BondSpec") })
@GeneratedValue(generator = "fk_bondspec")
@Column(name="INSTRUMENT", nullable=false,insertable=false,updatable=false)
public long getInstrument() {
return instrument;
public void setInstrument(long instrument) {
this.instrument = instrument;
@ManyToOne(targetEntity = BondSpec.class)
@JoinColumn(name = "INSTRUMENT", nullable = false, insertable=false, updatable=false)
public BondSpec getBondSpec() {
public void setbondSpec(BondSpec bondspec) {
@OneToOne(targetEntity = BondSpec.class)
@JoinColumn(name = "PARENT_INSTRUMENT", nullable = false, insertable = false, updatable = false, unique=true)
public long getParent_instrument() {
public void setParent_instrument(long parent_instrument) {
}What am I doing wrong?theraptor wrote:
I probably didn't explain it correctly. I am trying to populate these tables with data about financial instruments.
Table 2 and 3 share a primary key (INSTRUMENT). The primary key is generated in table 2, and the same value has to be later inserted into table 3. Sorry, I'm not following this at all. I don't think two tables should "share" a primary key. Both should have their own. Perhaps Table 3 would have a foreign key relationship with Table 2. OR the two tables should be one. But this notion of sharing doesn't sound right to me, and apparently Hibernate agrees. I think you have a bad design.
Table 2 has a one to many relation with table 3. Then they can't share a primary key. It's 1:m, which you can easily model with Hibernate.
(By many I mean it could be 0 as well, since hibernate does not provide a (one to 'maybe' one 'maybe zero) relation.Fine. Then it's a 1:m relationship. You've been thinking about it incorrect.
Table 3 has an additional column PARENT_INSTRUMENT which is a foreign key to the the primary key of table 2.No. Wrong.
Yes Instrument is financial in nature. However, I am not trying to model what you have spoken about above.Yes, I get it. Listen to Hibernate - your original idea is quite incorrect. Table 2 is 1:m with Table 3. Model it that way, and forget about this incorrect notion of "sharing a primary key". Give Table 3 its own auto generated key.
% -
I have about 500 songs in my library that have played one time. Although a "last date played" date is noted, there is no number in the play count column. This only happens some times. Any reason for this, and can it be corrected? thx
Thanks, but the play count is not incrementing only on the very first play. All subsequent plays are fine. Meaning the play counts for these particular tracks are always one play short. I double-checked some of the tracks in question and I have not shortened, or stopped them early.
-
ORA-01779: cannot modify a column which maps to a non key-preserved table
define cusname='GEORGE';
INSERT INTO (select s.prd_id, s.cus_id, s.qty_sold, s.price from sales s, customers c where s.cus_id=c.cus_id)
VALUES (102,(select cus_id from customers where upper(c_name) like '%GEORGE%'),14,(select price from product where prd_id = 102)*14)
I am getting the following error when I am trying to run the above query.
SQL Error: ORA-01779: cannot modify a column which maps to a non key-preserved table
01779. 00000 - "cannot modify a column which maps to a non key-preserved table"
*Cause: An attempt was made to insert or update columns of a join view which map to a non-key-preserved table.
*Action: Modify the underlying base tables directly.
CUSTOMERS TABLE
Name
Null
Type
CUS_ID
NOT NULL
NUMBER
C_NAME
VARCHAR2(50)
C_LIMIT
NUMBER
CITY
VARCHAR2(20)
PRODUCT TABLE
Name
Null
Type
PRD_ID
NOT NULL
NUMBER
PRICE
NUMBER
COST
NUMBER
SALES TABLE
Name
Null
Type
PRD_ID
NOT NULL
NUMBER
CUS_ID
NOT NULL
NUMBER
QTY_SOLD
NUMBER
PRICE
NUMBERHi,
As the error message sugggested, INSERT directly into the sales table. You can get the values from a sub-query that joins whatever tables are needed, including sales itself. MERGE might be simpler and more efficient than INSERT.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
If you're asking about a DML statement, such as INSERT, the sample data will be the contents of the table(s) before the DML, and the results will be state of the changed table(s) when everything is finished.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
How to maintain a counter column?
Hi All,
I am a novice with Oracle. Currently I have a problem which requires me to maintain a counter in an oracle column.
Following is my schema:
assetTable
1. ID
2. Name
3. Count
recordTable
1. ID
2. AssetID
For each insert in the recordTable, I want to update the 'Count' column in assetTable by 1 for the appropriate 'AssetID' which is the foreign key to the assetTable. There would be multiple clients trying to do insert into the recordTable, however the counter must be incremented for each insert reliably. Initially I thought I would be able to achieve this by writing a simple trigger. But I think that a trigger which does a simple read and update would not work as their are multiple clients writing simultaneously.
Please suggest a solution.
Thanks in advance.create or replace view v_asset as
select a.id, a.name, count(r.id)
from assetTable a, recordTable r
where r.assetID = a.id
{code}<br /><br /><br /><br />Google database+normalization for why any other approach is <a href="http://catb.org/jargon/html/B/Bad-and-Wrong.html" title="Bad And Wrong">Bad And Wrong</a>
Edited by: Dave Hemming on Oct 31, 2008 11:46 AM -
How to set Tile count column or count row?
How to set Tile count column or count row? If not can do, How
to adjust count row or count column?
Thx for all idea.The Tile container's number of columns and rows is calculated
based on each child's width and height (or based on tileWidth and
tileHeight which you can set). If you need more control over the
layout, use Grid. -
How can I build a count column with a where clause based on a query defined in the report builder query screen? From what I can tell the built in count column does not allow the addition or definition of a where clause.
ThanksHi Ruth,
Not exactly sure if this will answer your question, but here goes. It sounds like you want to count values based on certain conditions? If the where clause is already in your query, you can use the count function that's available in SQL and allow the database to perform the count for you. Otherwise you can use a formula column in combination with a placeholder column or a summary column to get the conditional count. In the formula column you can use plsql to determine if you want to increment your count or not. Depending on how you do it, you can either just return '1' or '0' from your formula column and create a summary column based on your formula column. Or you can increment a placeholder column from your formula column. If you decide to go with placeholders, I'd suggest reading the online help examples for placeholders as there are a few rules you'll have to go by.
Hope that helps,
Toby -
Query of Query count(column) returns blank not zero
This appears to be a bug in 7,0,1,116466 and 8,0,1,195765
Query of Query count(column) or count(*) returns blank not
zero when there are no matches. Properly returns a number when
there are query matches.
e.g. select count(i_id) from PersonnelQuery where i_id <
100
Where does one report these?scottcook,
This was a known bug in ColdFusion 6.x which has apparently
not been fixed.
Bug in CF6 (See the Comments section of the page linked
below)
http://livedocs.adobe.com/coldfusion/6.1/htmldocs/using_29.htm
Workaround
http://www.bennadel.com/blog/244-ColdFusion-Query-Of-Queries-Odd-COUNT-Behavior.htm
To report this as a bug
http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform -
Counter column in the Receiver file
Hi All,
My requirement -->
Souce is IDOC and target is a file.
In the Receiver file there is one column counter which will indicate the counter for each line...
So the Receiver file should be like this
FHEAD,0001
THEAD,00002,00001,20081103
TDETL,0003,0001,A,777,23456789
TDETL,0004,0002,M,881,45333333
TTAIL,0005
THEAD,0006,00002,20081103
TDETL,0007,0001,A,777,23456789
TDETL,0008,0002,M,881,45333333
TDETL,0009,0003,M,381,4533677
TTAIL,0010
FTAIL,0011
The problem is when i map with the source and use counter for the second column, i am getting the counters different, this is due to the condition on the node level, because if 10 idocs come the file may need only 5 based on condition. but since source occurence is 10 the counter cannot give correct values in the file as required,
Please suggest the best way to handle this..
Regards,
Sridhar ReddyHi,
>>this is due to the condition on the node level, because if 10 idocs come the file may need only 5 based on condition. but since source occurence is 10 the counter cannot give correct values in the file as required,
As far as i understand the question, you need the 5 Idocs based on condition and then you want to give the counter 1 to 5. Right ?
If this is the case just use one more additional parameter for counting the occurence when some Idoc come just increment it.
Like if you are using X variable for counting Idocs earlier n i think you are using that variable only for assigning count for filtered Idocs. or may be you are checking some condition and thats why that output for count is coming wrong. Use another variable and then increment that variable and assign that variable value to desired place.
Regards
Aashish Sinha -
Report with multiple COUNT columns with counts from same table
I am new to discoverer so I am a bit lost.
I am working to create a report to show usage data from the eBusiness Knowledge Base. I have the query written in SQL using subqueries that is in the format:
Solution Number | Soultion Title | Solution Views | Positive Feedback | Negative Feedback
12345 ___________ Title ________ 345 ____________ 98 _______________ 34
The 'Views', 'Positive' and 'Negative' entries are stored in the same table so i am doing a count where setid=setid and usedtype=VS, then counting where usedtype=PF and usedtype=NF
In discoverer I can get the solution number, title and ONE of the totals but I can't seem to figure out how to get a COUNT for three different things from the same table in columns on the same row.
When I go to edit sheet -> select items once I select the COUNT option for the UsedType column in the table CS_KB_SET_USED_HISTS I can't select it again. I also have found now way to add a column based on an entered query.
If anyone could help it would be much appreciated.
Thanks
Edited by: Toolman21 on Dec 2, 2010 2:17 PM
added ______ to correct spacing.Hi,
You can separate the column by using a case or decode.
for example create 2 calculations:
case
when usedtype='PF'
then <you original column> --- the one contain them both
else 0
end
case
when usedtype='NF'
then <you original column> --- the one contain them both
else 0
end
after that you can create the count aggregation over those.
Tamir -
Interactive report: How to display "count" column on total data set?
Hi,
I'm a relative newbie to APEX and would appreciate some help with the following:
I have an interactive report that will usually contain around 8000 rows.
I need to report the total number of distinct values in one of the columns - but I need to get around the limitation of APEX where it only counts the number of rows displayed on the screen.
I thought to create a separate region and use a separate SQL query to show the full total regardless of the number of rows displayed - however, I've now got the problem of not being able to access the interactive report "query", so, for example, if someone running the report adds a filter, I need the total to report with this new filter applied.
Does anyone know if I can:
a) get around the the limitation of only counting the number of rows displayed?
or, if not,
b) how to access the interactive report "query" that is being run?
or
c) any other way of doing this!?
I do hope this makes sense. Thanks in advance for any help....
HelenHi all,
Thanks for your responses. They really are much appreciated.
I had hoped to spend some time on this over the weekend - but haven't got round to it. I'll work on it again tomorrow and will certainly look at the thread you mentioned Tony.
Sorry I'm not being very clear about what I want. Why are these things always so hard to explain in words :o)
I'll have another go....
I have an interactive report that would report around, say, 8000 rows. Obviously I don't want to display all 8000 on the screen so I'll probably display them in chunks of 15 rows. If I use the aggregation function on the report, I can add a count of the distinct account numbers to the bottom of the display, but it will only count the ones displayed on the screen. I need the count to be of all the rows - so 8000 instead of 15 - but still displaying only 15 rows. When a user then applies a filter to the report, I need the count to change in accordance with the filter - so if the number of rows returned as a result of the filter is now 4000 instead of 8000, I need the count to now say 4000 instead of 8000 even though still only 15 rows are actually displayed on the screen.
I'll try and pre-empt the questions...
1) There will always be duplicate account numbers in there so the count will never be the actual number of rows - but I'm simplifying above to help explain the problem better
2) Why would they want 8000 rows? Don't ask. I'm sure it's something to do with exporting the lot into an excel spreadsheet but they'll never admit it :o)
I hope this makes more sense......
Thanks again!!
Helen
P.S. Almost forgot again... I'm using Apex 4.1 on the Oracle hosted environment which I assume is 11g. -
How to: Count columns in a table?
Quite simple question actually. How do I count the number of columns in a table using SQL?
For AdventureWorks2012 tables & views:
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COUNT(COLUMN_NAME ) ColCount
FROM INFORMATION_SCHEMA.COLUMNS
GROUP BY TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME
ORDER BY TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME;
TABLE_SCHEMA TABLE_NAME ColCount
dbo AWBuildVersion 4
dbo DatabaseLog 8
dbo ErrorLog 9
HumanResources Department 4
HumanResources Employee 16
HumanResources EmployeeDepartmentHistory 6
HumanResources EmployeePayHistory 5
HumanResources JobCandidate 4
HumanResources Shift 5
HumanResources vEmployee 18
HumanResources vEmployeeDepartment 10
HumanResources vEmployeeDepartmentHistory 11
HumanResources vJobCandidate 16
HumanResources vJobCandidateEducation 13
HumanResources vJobCandidateEmployment 11
Person Address 9
Person AddressType 4
Person BusinessEntity 3
Person BusinessEntityAddress 5
Person BusinessEntityContact 5
Person ContactType 3
Person CountryRegion 3
Person EmailAddress 5
Person Password 5
Person Person 13
Person PersonPhone 4
Person PhoneNumberType 3
Person StateProvince 8
Person vAdditionalContactInfo 17
Person vStateProvinceCountryRegion 7
Production BillOfMaterials 9
Production Culture 3
Production Document 14
Production Illustration 3
Production Location 5
Production Product 25
Production ProductCategory 4
Production ProductCostHistory 5
Production ProductDescription 4
Production ProductDocument 3
Production ProductInventory 7
Production ProductListPriceHistory 5
Production ProductModel 6
Production ProductModelIllustration 3
Production ProductModelProductDescriptionCulture 4
Production ProductPhoto 6
Production ProductProductPhoto 4
Production ProductReview 8
Production ProductSubcategory 5
Production ScrapReason 3
Production TransactionHistory 9
Production TransactionHistoryArchive 9
Production UnitMeasure 3
Production vProductAndDescription 5
Production vProductModelCatalogDescription 25
Production vProductModelInstructions 11
Production WorkOrder 10
Production WorkOrderRouting 12
Purchasing ProductVendor 11
Purchasing PurchaseOrderDetail 11
Purchasing PurchaseOrderHeader 13
Purchasing ShipMethod 6
Purchasing Vendor 8
Purchasing vVendorWithAddresses 9
Purchasing vVendorWithContacts 12
Sales CountryRegionCurrency 3
Sales CreditCard 6
Sales Currency 3
Sales CurrencyRate 7
Sales Customer 7
Sales PersonCreditCard 3
Sales SalesOrderDetail 11
Sales SalesOrderHeader 26
Sales SalesOrderHeaderSalesReason 3
Sales SalesPerson 9
Sales SalesPersonQuotaHistory 5
Sales SalesReason 4
Sales SalesTaxRate 7
Sales SalesTerritory 10
Sales SalesTerritoryHistory 6
Sales ShoppingCartItem 6
Sales SpecialOffer 11
Kalman Toth Database & OLAP Architect
sqlusa.com
Paperback / Kindle: Pass SQL Exam 70-461 & Job Interview: Programming SQL Server 2012 -
Increment counter in XSLT mapping
Hi Experts,
I am creating xslt mapping by using mapforce tool. I am trying to get increment counter variable in xslt mapping. can you please tell me what would be the code for getting sequence number.
Thanks for your help.
Thanks,
Hariyes, there is a global variable concept in XI which u can use for your Sequence Number concept.
If you are on SP14 and above, just take a lookat this blog and the GLOBAL Variables Section
XI: New features in SP14
check this thread
Re: Need Help in XSLT Mapping
Re: Sequence Number in XI Mapping -
Hi all,
I work with forms 6i and database oracle 8. I want to know if it's possible to count the number of column in a sql query. For exemple, i have : "select id, name, dtbirth from table". In this query, I have 3 column. But I don't know how can I get it! Someone can help me! please!
best regards.You are in the wrong forum, try the database forum.
Steven Davelaar,
JHeadstart Team.
Maybe you are looking for
-
We have been using j2ee.jar previously in our project but its been recommended to pick it from Weblogic but there are too many jars similar to it, plz guide which one to ake in our project.
-
Importing audio voice file changes the pitch in Logic Express
I noticed something weird with my Logic Express 7. When I import an audio voice file. The pitch seems to be lower in Logic when I play the file than compared to the original file. Does anyone know what could be causing the pitch change? I though I wa
-
How to use memory analyser in CE 7.1 portal
Hi, I want to use Memory Analyser in my landscape, i have installaed CE7.1 on oracle DB( remote DB) on my VM.I have downloaded the memory analyzer from the eclipse site and i have the memory analyser.exe file with me. How can i use this one to use in
-
HT4489 Importing .vcf vCard to iCloud problems
I am trying to copy my contacts list onto iCloud from Hotmail. I exported it from Hotmail as .csv, converted it to vCard .vcf and tried to upload to iCloud, but got an error message saying I was exceeding size limits. My contacts list is only 750 e
-
Bootcamp Partition option without option key?
I work for a school division where we have dual boot macs in some of our schools. Many of the younger students have difficulty figuring out which key to press (option key) in time to bring up the boot partition option screen. I know it sounds strange