Different row count for select versus insert in XML query
Hi,
I encounter a situation where a SELECT * returns a different rows count than an INSERT INTO... (SELECT *) by xmltable join. This makes no sense at all!!!
In breif, I tried to convert xml data into traditional relational tables. I wrote an xml query to select data from xmltable... I checked row count. When I used "create table as select" that was the same query above, I got correct row count. However when I used "insert into select" that was the same query above, I got the wrong info in the table I just inserted.
Does any one have any idea what caused this issue? Thanks for your help.
DUPLICATE post
count of rows in a schema tables
Similar Messages
-
Get row count for different tables to the same line
How can I get the row count for different tables in one line:
SELECT count(A), count(B), count(C) from table tb_a A , tb_b B, tb_c C;
Thanks!>
Hi,
How can I get the row count for different tables in one line:
SELECT count(A), count(B), count(C) from table tb_a A , tb_b B, tb_c C;Something like this? One of the many uses for CTE's - Common Table Expressions - AKA
subquery refactoring. Worth getting to know - very handy!
with acount as
select count(*) as counta from dual -- put your table name here
bcount as
select count(*) as countb from dual -- put your table name here
ccount as
select count(*) as countc from dual -- put your table name here
select a.counta, b.countb, c.countc from acount a, bcount b, ccount c;HTH,
Paul...
Edited by: Paulie on 25-Jul-2012 17:44 -
Problem w/: Error while getting estimated row count for view
JDev 10.1.3 - Steps
1. created a ADF VO w/ one bind variable vNAME.
2. Created a basic jspx page, use the data control pal. to drop in VO w/ executeparam option. Use the data control pal to drop in VO w/ ADF Read-Only Table w/ select and sort option. Selected all VO columns in table.
3. Following Error msg occurs when running jspx page -
oracle.jbo.DMLException: Error while getting estimated row count for view object CategoryView, statement SELECT count(1) FROM (SELECT
CATEGORY.CATID CATID,
CATEGORY.NAME NAME,
CATEGORY.PICTURE PICTURE,
CATEGORY.ACTIVE ACTIVE
FROM
CATEGORY
WHERE
(CATEGORY.NAME LIKE UPPER(:vName)||'%')) .
Tested SQL Statement in SQL Worksheet works ok (with a Value replacing ':vName').
Can anyone advise - seems to be a straight forward process that is returning this error msg. I have tried variations of the SQL stmt with no luck. The jspx page errors when the ADF Read-Only Table is added.I seem 2 have the same error, in a slightly different situation.
I have a view which subclasses a Entity with a history column 'CreatedOn'. When performing a quick search/filter on this column I get the same error. The ADF app is build on a DB2 database, so no named parameters here. Instead invalid SQL is created when executing the estimated row count. The WHERE clause contains 'CreatedOn = null', should be 'CreatedOn is null'. Furthermore the input of my quick search is not filled in this clause.
Any help would be appreciated -
There was an error while updating row count for "SH".."SH".CHANNELS
Hi All,
Am new to OBIEE.Pls help in this regard.
Am building the physical layer as per Repository guide.When am importing the data in to this,am getting the below error.
*"There was an error while updating row count for "SH".."SH".CHANNELS" :"*
channles is the table name and having 5 rows.
but am able to see the data in the sql prompt. like SELECT * FROM SH.CHANNELS then 5 rows data would be displaying..
pls help in this regard and where is the excat problem?
Thanks,what is the error?
Make sure that your connection pool settings are okay..
Make sure that, you are using correct driver in case of if you are using ODBC dsn..
Also make sure that, your oracle server is running... TNS and Oracle server services -
How to get row count(*) for each table that matches a pattern
I have the following query that returns all tables that match a pattern (tablename_ and then 4 digits). I also want to return the row counts for these tables.
Currently a single column is returned: tablename. I want to add the column RowCount.
DECLARE @SQLCommand nvarchar(4000)
DECLARE @TableName varchar(128)
SET @TableName = 'ods_TTstat_master' --<<<<<< change this to a table name
SET @SQLCommand = 'SELECT [name] as zhistTables FROM dbo.sysobjects WHERE name like ''%' + @TableName + '%'' and objectproperty(id,N''IsUserTable'')=1 ORDER BY name DESC'
EXEC sp_executesql @SQLCommandThe like operator requires a string operand.
http://msdn.microsoft.com/en-us/library/ms179859.aspx
Example:
DECLARE @Like varchar(50) = '%frame%';
SELECT * FROM Production.Product WHERE Name like @Like;
-- (79 row(s) affected)
For variable use, apply dynamic SQL:
http://www.sqlusa.com/bestpractices/datetimeconversion/
Rows count all tables:
http://www.sqlusa.com/bestpractices2005/alltablesrowcount/
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
Count (*) for select stmt take more time than execute a that sql stmt
HI
count (*) for select stmt take more time than execute a that sql stmt
executing particular select stmt take 2.47 mins but select stmt is using the /*+parallel*/ (sql optimer) in that sql command for faster execute .
but if i tried to find out total number of rows in that query it takes more time ..
almost 2.30 hrs still running to find count(col)
please help me to get count of row faster.
thanks in advance...797525 wrote:
HI
count (*) for select stmt take more time than execute a that sql stmt
executing particular select stmt take 2.47 mins but select stmt is using the /*+parallel*/ (sql optimer) in that sql command for faster execute .
but if i tried to find out total number of rows in that query it takes more time ..
almost 2.30 hrs still running to find count(col)
please help me to get count of row faster.
thanks in advance...That may be because your client is displaying only the first few records when you are running the "SELECT *". But when you run "COUNT(*)", the whole records has to be counted.
As already mentined please read teh FAQ to post tuning questions. -
Rows count for repetitive groups in tablix.
Hi All,
To make the story cut short, i will going to explain my scenario:
i have a tablis contro and i garoup it by a field say "Field1" which contains A and B values,
in my case we divide groups in two parts if it has rows more then 200.
so, my report output and my required is below :
Current Output -------------------------- Required layout
here 200, 20, 30 are number of rows per group.
now my requirement is if a group is repetitive
i need the all rows count for that value like in above case :
Header text of Group A should be like : A(220) i.e 200 +20
please help me on this...
it is very urgent for me
shashankhi Simon,
thanks for reply, sorry, i skipped to mentioned that i have to provide multilevel grouping also, like
Group By: Field 1 -> Field 2 -> field3
so, to achieve my requirement by Sql as solution has no problem if i do not have multilevel grouping, but i have to provide that and in that case the query will be like,
“select distinct [column1],[Column2],[Column3],count(*) as rn from [table] group by [column1],[Column2],[Column3]”
which is problematic in my case.
so for doing this i need a solution apart from sql but by using SSRS Report end.
Thanks again.
Shashank -
Getting different message count for some mail boxes in a particular account
Hello,
I am using java mail api in my project.
I am using two methods
Case 1 :
folder.getMessageCount()
case 2:
getMessageCount(String folderName){
int iCount = 0;
Folder objFolder = store.getDefaultFolder();
if (folderName != null && folderName.equalsIgnoreCase("") == false) {
objFolder = objFolder.getFolder(folderName);
iCount = objFolder.getMessageCount();
return iCount;
I am getting different output from both the above cases.
I have tested both cases on many accounts and they give me same message count. but for one gmail account only they give me different message count for two folders, Inbox as well as Gmail/All.
Can anyone tell me the reason for this difference.Yes, in case 1, i first open the folder and then i call folder.getMessageCount().
I am using IMAP in both the cases
as i used Store store = session.getStore("imaps");
Yes, there is no new mail delivered to the folder when this methods are analyzed.
i am getting different count as
imap.getMessageCount() >> First way
imap.getMessageCount(Bi testing) >> Another way:-
imap.getMessageCount(Bi testing)--> Count = 4
imap.getMessageCount()--> Count = 4
imap.getMessageCount(INBOX)--> Count = 125
imap.getMessageCount()--> Count = 117
imap.getMessageCount(Personal)--> Count = 11
imap.getMessageCount()--> Count = 11
imap.getMessageCount(Receipts)--> Count = 6
imap.getMessageCount()--> Count = 6
imap.getMessageCount(Travel)--> Count = 36
imap.getMessageCount()--> Count = 36
imap.getMessageCount(Work)--> Count = 2
imap.getMessageCount()--> Count = 2
*imap.getMessageCount([Gmail]/All Mail)--> Count = 180*
imap.getMessageCount()--> Count = 161
imap.getMessageCount([Gmail]/Drafts)--> Count = 0
imap.getMessageCount()--> Count = 0
imap.getMessageCount([Gmail]/Sent Mail)--> Count = 40
imap.getMessageCount()--> Count = 40
imap.getMessageCount([Gmail]/Spam)--> Count = 0
imap.getMessageCount()--> Count = 0
imap.getMessageCount([Gmail]/Starred)--> Count = 0
imap.getMessageCount()--> Count = 0
imap.getMessageCount([Gmail]/Trash)--> Count = 15
imap.getMessageCount()--> Count = 15
In this two folders Inbox as well as [Gmail]/All Mail showing different counts when used on both methods. -
Trying to get row counts for all tables at a time
Hi,
i am trying to get row counts in database at a time with below query but i am getting error:
its giving me ora-19202 error..please advise me
select
table_name,
to_number(
extractvalue(
xmltype(dbms_xmlgen.getxml('select count(*) c from '||table_name))
,'/ROWSET/ROW/C')
count
from all_tables;ALL_TABLES returns tables/views current user has access to. These tables/views are owned not just by current user. However your code
dbms_xmlgen.getxml('select count(*) c from '||table_name)does not specify who the owner is. You need to change it to:
dbms_xmlgen.getxml('select count(*) c from '||owner || '.' || table_name)However, it still will not work. Why? As I said, ALL_TABLES returns tables/views current user has access to. Any type of access, not just SELECT. So if current user is, for example, granted nothing but UPDATE on some table the above select will fail. You would have to filter ALL_TABLES through ALL_SYS_PRIVS, ALL_ROLE_PRIVS, ALL_TAB_PRIVS and PUBLIC to get list of tables current user can select from. For example, code below does it for tables/views owned by current user and tables/views current user is explicitly granted SELECT:
select
t.owner,
t.table_name,
to_number(
extractvalue(
xmltype(dbms_xmlgen.getxml('select count(*) c from '||t.owner || '.' || t.table_name))
,'/ROWSET/ROW/C')
count
from all_tables t,user_tab_privs p
where t.owner = p.owner
and t.table_name = p.table_name
and privilege = 'SELECT'
union all
select
user,
t.table_name,
to_number(
extractvalue(
xmltype(dbms_xmlgen.getxml('select count(*) c from '||t.table_name))
,'/ROWSET/ROW/C')
count
from user_tables t
OWNER TABLE_NAME COUNT
SCOTT DEPT 4
U1 QAQA 0
U1 TBL 0
U1 EMP 1
SQL> SY. -
Row count for tables from 2 different databases
Hi,
i wrote a query to get counts from all the tables in one schema to another schema. this generates the select count (*) from tables and gives me the counts, but i want to get the counts such as
table1 -- 100 -- DB1
table1 - 110
table2 - 230 - DB2
table2 - 230 etc...
here is my query that works but display of the output is the way i wanted. can someone help me getting the output as above described.
select 'select ''PTO'', count(*) as '||(table_name)||'_count'||' from '||table_name||';'from dba_tables
where owner = 'TEST'
union all
select 'select ''PFO'', count(*) as '||(table_name)||'_count'||' from '||table_name||';'from [email protected]
where owner = 'TEST';
thanks...DUPLICATE post
count of rows in a schema tables -
Different row counts between SQL management studio and Visual Studio
Hi
I'm pulling data from a NAV database using a stored procedure containing a Pivot (due to bad table design), the problem is my SQL management studio is returning 53 rows of records yet Visual studio is only returning 5.
I initially copied the query from management studio into VS to create my dataset, however after returning very few records I used a stored procedure instead.
Unfortunately the same result occurred, 5 records instead of 53,
Is there something different between the two systems, perhaps VS doesn't like something in the Pivot?
Can anyone help?
Thanks
Charlie
CREATE
PROCEDURE [dbo].[PosReleaseTestPrepared]
--@Date AS DATETIME
AS
BEGIN
-- -- SET NOCOUNT ON added to prevent extra result sets from
-- -- interfering with SELECT statements.
-- SET NOCOUNT ON;
-- -- Insert statements for procedure here
DECLARE @cols
NVARCHAR(MAX),
@stmt NVARCHAR(MAX)
SELECT @cols
=
ISNULL(@cols
+
+
+ ES.Code
+
FROM
(SELECT
Code
FROM dbo.[Branston
Live$Enquiry Step]
WHERE [Enquiry Code]
=
'PREPARED')
AS ES
SELECT @stmt
=
SELECT *
FROM
(SELECT PR.[Entry No_], PR.[Mobile User Code], PR.[Failure Step Code],PR.[Item No_], PR.[Customer No_] ,[Enquiry Step Code], Value
FROM dbo.[Branston Live$Positive Release] PR
LEFT OUTER JOIN dbo.[Branston Live$Positive Release Step] PRS
ON PR.[Entry No_] = PRS.[Positive Release Entry No_]
WHERE PR.[Enquiry Code] = ''PREPARED'') PR
PIVOT
MAX(VALUE)
FOR [Enquiry Step Code] in ('
+ @cols
+
) AS P'
EXEC
sp_executesql@stmt
END
GOHi Satheesh, Latheesh
I'm using a shared data source in VS, the server and database are definitely pointed to the right location. As is the Stored procedure/SQL query. The table names "PositiveRelease" are bespoke to us and therefore are easy to recognise.
Below is one of the 5 records from the VS report:
Mobile User Code
Customer No
Item No
Failure Step Code
Depot Date
PP_GY
102980
S10586
DEPOT_DATE
17/02/14
Below is the record from the SQL management studio, you can see it is pulling through matching records.
Mobile User Code
Customer No_
Item No_
Failure Step Code
DEPOT_DATE
PP_GY
102980
S10586
DEPOT_DATE
17/02/2014 -
Adding 2 more rows to a select without inserting rows to base table
hello all,
i have a below simple select statement which is querying a table.
select * from STUDY_SCHED_INTERVAL_TEMP
where STUDY_KEY = 1063;
but here is the situations. As you can see its returning 7 rows. But i need to add
2 more rows..with everything else default value or what exist... except adding 2 more rows.
i cannot insert into base table. I want my end results to increment by 2 days in
measurement_date_Taken to 01-apr-09....so basically measurement_date_taken should
end at study_end_Date...
IS THAT EVEN POSSIBLE WITHOUT INSERTING ROWS INTO THE TABLE AND JUST PLAYIHY AROUND WITH
THE SELECT STATEMENT??
sorry if this is confusing...i am on 10.2.0.3
Edited by: S2K on Aug 13, 2009 2:19 PMWell, I'm not sure if this query looks as good as my lawn, but seems to work anyway ;)
I've used the 'simplified version', but the principle should work for your table to, S2K.
As Frank already pointed out (and I stumbled upon it while clunging): you just select your already existing rows and union them with the 'missing records', you calculate the number of days you're 'missing' based on the study_end_date:
MHO%xe> alter session set nls_date_language='AMERICAN';
Sessie is gewijzigd.
Verstreken: 00:00:00.01
MHO%xe> with t as ( -- generating your data here, simplified by me due to cat and lawn
2 select 1063 study_key
3 , to_date('01-MAR-09', 'dd-mon-rr') phase_start_date
4 , to_date('02-MAR-09', 'dd-mon-rr') measurement_date_taken
5 , to_date('01-APR-09', 'dd-mon-rr') study_end_date
6 from dual union all
7 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('04-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
8 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('09-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
9 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('14-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
10 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('19-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
11 select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('23-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
12 select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('30-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual
13 ) -- actual query:
14 select study_key
15 , phase_start_date
16 , measurement_date_taken
17 , study_end_date
18 from t
19 union all
20 select study_key
21 , phase_start_date
22 , measurement_date_taken + level -- or rownum
23 , study_end_date
24 from ( select study_key
25 , phase_start_date
26 , measurement_date_taken
27 , study_end_date
28 , add_up
29 from (
30 select study_key
31 , phase_start_date
32 , measurement_date_taken
33 , study_end_date
34 , study_end_date - max(measurement_date_taken) over (partition by study_key
35 order by measurement_date_taken ) add_up
36 , lead(measurement_date_taken) over (partition by study_key
37 order by measurement_date_taken ) last_rec
38 from t
39 )
40 where last_rec is null
41 )
42 where rownum <= add_up
43 connect by level <= add_up;
STUDY_KEY PHASE_START_DATE MEASUREMENT_DATE_TA STUDY_END_DATE
1063 01-03-2009 00:00:00 02-03-2009 00:00:00 01-04-2009 00:00:00
1063 03-03-2009 00:00:00 04-03-2009 00:00:00 01-04-2009 00:00:00
1063 03-03-2009 00:00:00 09-03-2009 00:00:00 01-04-2009 00:00:00
1063 03-03-2009 00:00:00 14-03-2009 00:00:00 01-04-2009 00:00:00
1063 03-03-2009 00:00:00 19-03-2009 00:00:00 01-04-2009 00:00:00
1063 22-03-2009 00:00:00 23-03-2009 00:00:00 01-04-2009 00:00:00
1063 22-03-2009 00:00:00 30-03-2009 00:00:00 01-04-2009 00:00:00
1063 22-03-2009 00:00:00 31-03-2009 00:00:00 01-04-2009 00:00:00
1063 22-03-2009 00:00:00 01-04-2009 00:00:00 01-04-2009 00:00:00
9 rijen zijn geselecteerd.If there's a simpler way (in SQL), I hope others will join and share their example/ideas/thoughts.
I have a feeling that this is using more resources than needed.
But I've got to cut the daisies first now, they interfere my 'lawn-green-ess' ;) -
How can we split limit row counts for DB2?
We want to mass data from DB2. but, we guess 200,000,000 count.
so we try to split by 5,000 count and almost 5 MB.
How can we use sql query for DB2? How can we make JDBC Sender?
but, We don't use update query. because Customer did not allow ours requirement.
How can we do?Well, there are ways, how to achieve success, but in all of them must customer do some changes in their database.
a, create "interface table", run select into (load relevant data to it) and then run JDBC adapter select on this table using update statement to mark the processed lines
b, there is for sure a table, which is "main" - every record is replicated and every one is repliacted only once.. Add new column to this table and use it as a "marker" for already processed records..
...for example...
There may be of course more possibilites...
If you don't want to process all records at once, there must be some flag to distinguish already processed records from not processed ones..
Peter -
Unable to set count for Select Query for BizTalk SQL receive port
Hi All,
Iam using BizTalk server 2009 classic SLQ adapter (using XML clause)for my integration to pull records from DB in to my application.
As per the DB values iam unable to set the record count as this started giving me error below (first it worked for 820 records with select Query.and then 400 and going down with respect to multiple runs).Kindly help .
Thanks in advance.Hi Abhishek,
iam still getting the same error for 1000 records.
after turning off PreserveBOM aswell in send pipeline.
There was a failure executing the receive pipeline: "Microsoft.BizTalk.DefaultPipelines.XMLReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Source: "Pipeline " Receive Port:
"SQLPort" URI: "SQL://XXXXX/OneC_DB/" Reason: An error occurred when parsing the incoming document: "'
', hexadecimal value 0x0B, is an invalid character. Line 188, position 3944.". -
How to increase the row count for display in OBIEE Answers-Dashboard page?
Hi All,
I have problem in exporting my reports. I need to export my report to either PDF or EXCEL format. My report contains more than 1200 rows. But when i am exporting the report to PDF it contains only 500 rows, for rest of the rows i have to scroll down and again i have to export to get the contents from 501 to 1000.
Is it possible by changing any property, can i export the entire 1200+ rows in a single EXCEL or PDF? Pls anybody shed light on this issue.
Thanks in Advance
Thenmozhi.Hi,
D:\Oracle\Middleware\instances\instance1\config\OracleBIPresentationServicesComponent\coreapplication_obips1\instanceconfig.xml
before take it u r back up and then update the below code ..
<Views>
<Pivot>
<MaxCells>6500000</MaxCells>
<MaxVisibleColumns>100</MaxVisibleColumns>
<MaxVisiblePages>1000</MaxVisiblePages>
<MaxVisibleRows>65000</MaxVisibleRows>
<MaxVisibleSections>25</MaxVisibleSections>
<DefaultRowsDisplayed>500</DefaultRowsDisplayed>
<!--This Configuration setting is managed by Oracle Business Intelligence Enterprise Manager--><DefaultRowsDisplayedInDelivery>75</DefaultRowsDisplayedInDelivery>
<!--This Configuration setting is managed by Oracle Business Intelligence Enterprise Manager--><DefaultRowsDisplayedInDownload>65000</DefaultRowsDisplayedInDownload>
<!--This Configuration setting is managed by Oracle Business Intelligence Enterprise Manager--><DisableAutoPreview>false</DisableAutoPreview>
</Pivot>
<Table>
<MaxCells>6500000</MaxCells>
<MaxVisiblePages>1000</MaxVisiblePages>
<MaxVisibleRows>65000</MaxVisibleRows>
<MaxVisibleSections>25</MaxVisibleSections>
<DefaultRowsDisplayed>500</DefaultRowsDisplayed>
<!--This Configuration setting is managed by Oracle Business Intelligence Enterprise Manager--><DefaultRowsDisplayedInDelivery>75</DefaultRowsDisplayedInDelivery>
<!--This Configuration setting is managed by Oracle Business Intelligence Enterprise Manager--><DefaultRowsDisplayedInDownload>65000</DefaultRowsDisplayedInDownload>
</Table>
</Views>
finally re start all services then try it again... here its working fine...
Thanks
Deva
Maybe you are looking for
-
Input Filed Length Changes in SAP Table How to maintain in WDJ
hi , i have scenario where we are having the scenario like dat .. container id with 10 chars previousl y in sap system currently from sap they have changed the length to 20 char in sap tablle. from web dynpro java we have set length 20 char . scenari
-
The instragram zxp extention is invalid - how to solve?
The instragram zxp extention is invalid: just installed the last extension manager CS6, downloaded the instragram add on but get an error message on installation of the add on with "The installer file is invalid....."
-
Two step process of creating G/l
Hi, Please advise what is two step process of creating a g/l. i know creating it through fs00. but there is another way of creating ti thru company code and chart of accounts. CAn anybody help me?
-
Customizing Oracle Sales Reports
I am trying to customize a report in the Oracle Sales module. For instance, there is a Customer Organization Summary page that lists customers. Our employees would like a column added to that page that has a link to the Organization Notes page. How c
-
Condition type ztc1 in TAXINJ PRICING PROCEDURE
HI, Condition tye ZTC1 TCS in TAXINJ was not come on invoice why because ZCTC1 requirement 905 is missing in scrap sale organsiation 905 requirement says that user parameter should be maintain in own data at the user system as VKO= OT00 sale document