Why "select count(*) from sometable" will get 2 rows in ResultSet?
When i query this sql string.. the resultset returns 2 rows.
and when i use such code as following :
while (rs.next())
temp = rs.getString(1);
will cause an error as: the course is outOfRang...
what's the matter with this statement?
When i query this sql string.. the resultset returns 2
rows.
and when i use such code as following :
while (rs.next())
temp = rs.getString(1);
will cause an error as: the course is outOfRang...
what's the matter with this statement?
Do you have a printStackTrace in your code to determine the exact line where you get the error?
Similar Messages
-
Select Count(*) from Sample_table - how to get the count using JDBC?
Hi All,
It would be glad if anyone could help me with this. The problem is that I have to get the 'count' of records selected from a arbitrary table say, 'sample_table'. Is that possible to form the SQL in JDBC as
Select Count(*) from Sample_table
and get the value of the count? If yes, how?
Thanks in advance
Prabzstmt = con.createStatement();
ResultSet recordcnt_rs = stmt.executeQuery("Select Count (*) as record_ctr From Sample_table");
recordcnt_rs.next();
record_ctr = recordcnt_rs.getInt("record_ctr");
hope this helps. -
Select count from large fact tables with bitmap indexes on them
Hi..
I have several large fact tables with bitmap indexes on them, and when I do a select count from these tables, I get a different result than when I do a select count, column one from the table, group by column one. I don't have any null values in these columns. Is there a patch or a one-off that can rectify this.
ThxYou may have corruption in the index if the queries ...
Select /*+ full(t) */ count(*) from my_table t
... and ...
Select /*+ index_combine(t my_index) */ count(*) from my_table t;
... give different results.
Look at metalink for patches, and in the meantime drop-and-recreate the indexes or make them unusable then rebuild them. -
Select count(*) from table in oracle 11g with direct path read takes time
select count(*) from table takes long time, even more than couple of hours..
direct path read is the wait event which is almost is at 99%..
can u someone provide some info on this.. on solution.. thankxknowledgespring wrote:
table has millions of records... 130 millions..
select count(*) from BIG_SIZE_TABLE; --- executed in sql plus command prompt.
Rows Execution Plan
0 SELECT STATEMENT MODE: ALL_ROWS
0 SORT (AGGREGATE)
0 TABLE ACCESS MODE: ANALYZED (FULL) OF 'BIG_SIZE_TABLE' (TABLE)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 1 0.00 0.00
enq: KO - fast object checkpoint 1 0.01 0.01
Disk file operations I/O 18 0.00 0.00
direct path read 58921 0.34 418.54direct path read time waited is : 58921 total time waited: 418.54
That 418 seconds - not the hours you reported earlier. Is it possible that your connection to the database broke ?
On a typical system, by the way, you can usually turn one direct read for tablescan into 1MB, so your scan seems to have covered about 59 GB, which seems to be in the right sort of ballpark for 130M rows.
we have another query and when we test the query execution using v$sql, is_bind_sensitive =N, how to make is_bind_sensitive=Y all the time.. There is a hint /*+ bind_aware */ - I'd have to check whether or not it's documented at present. It might help.
I would be interested in hearing why you think the hint should be bind sensitive when the optimizer doesn't.
Regards
Jonathan Lewis -
Hi,
I have an odd situation where "select count(*) from my_view where some_clause" returns 0, but the exact same query fetching the data (ie "select * from my_view where some_clause") works fine and fetches, correctly, 4000+ records.
I have tried dropping and recreating the view, and collecting DB stats again, but the problem persists.
I had a look at the explain plans and they are very different, but both the SQL statements work fine on a copy of the database taken with impdp.
Does anyone have any suggestions on what might be going on here ?
Any help would be appreciated, I've run out of ideas !
Dave
Edited by: user10281551 on 18-Sep-2008 00:43
Edited by: user10281551 on 18-Sep-2008 00:44Maybe it's the bug that a function based index is present and gets incorrectly used in the select count(*) statement?
If that's not the case, then please show us more details, like the statement and both execution plans.
Regards,
Rob. -
How do I execute "Select count(*) from table " in OCI
Hi,
I am new to OCI and so this question may seem stupid. I would like to know how to execute the query "select count(*) from <table>" using OCI V8 functionality? Also after how do I get the result into a integer datatype? I have gone through most of the demo programs but is is of little help to me.
Thanks in advance...
Regards,
Shubhayan.Hi,
Here is sample code to give you some idea how to do it. If you want some more info let me know.
Pankaj
ub4 count;
// Prepare the statement.
char szQry = "SELECT count() FROM T1";
if(OCI_ERROR == OCIStmtPrepare(pStmthp, pErrhp, (unsigned char*)szQry, strlen(szQry), OCI_NTV_SYNTAX , OCI_DEFAULT) )
cout << "Error in OCIStmtPrepare" << endl;
exit(1);
// Bind the output parameter.
OCIDefine *pDefnpp;
if(OCI_ERROR == OCIDefineByPos ( pStmthp, &pDefnpp, pErrhp, 1,
&count, sizeof(ub4), SQLT_INT,
(dvoid *) 0, (ub2 *) 0, (ub2 *) 0,
OCI_DEFAULT) )
cout << "Error in OCIDefineByPos" << endl;
exit(1);
if(OCI_ERROR == OCIStmtExecute(pSvchp, pStmthp, pErrhp, 1, 0, NULL, NULL, OCI_DEFAULT) )
cout << "Error in OCIStmtExecute" << endl;
exit(1); -
Why select data from Function directly (SE37) got data , but when use funct
why select data from Function directly (SE37) got data , but when use function in program donot found data
i use function
CS_BOM_EXPL_MAT_V2
when i run function directly at SE37 .
i found data.
but when i use same function in program .
system not found.
please see my attachment.
help me please.
[http://www.quickfilepost.com/download.do?get=c974356a498b3a4d369aa0c50622e50b]
http://www.quickfilepost.com/download.do?get=c974356a498b3a4d369aa0c50622e50bI know why U get empty data.
In Program U should follow the rules:
U'd better data a variant typed the function parameters's type.
for example:
in your program the parameter: stlal = '1'
U'd better like follow:
Data l_stlal type STKO-STLAL
l_stlal = '01'. *Attention: '1' <> '01'.
stlal = l_stlal.
in this way U may have less mistake
and the parameter MTNRV
U should use material convernt : "CONVERSION_EXIT_MATN1_INPUT" to change material into internal types before U put into function's parameter.
why se37 has no problem? because In se37, the data you filled was be processed before use -
Wrong results from "Select count(*) from tbl"
I am the user of an Oracle DB and I am getting what
look like wrong counts using "Select count(*)" statments.
It first occurred when I tried to get monthly record counts with
Select count(*), month
from tbl
group by month
(Note this is the query I used with the exception
of a change in the table name. The month field is numeric)
All the monthly counts but one looked like it was 2x what it should be.
Oddly enough if I tried
Select count(*), month
from tbl
where month = 200302
group by month
OR
Select count(*), month
from tbl
where month in (200301 200302)
group by month
I got what looked correct.
I even got the 2X problem when I asked for a count on
the entire table using
Select count(*)
from tbl
One of our DBAs suggested the problem has somehting to do with
the indexes and not running analyze on the table recently.
I'll note also that the table is partitioned.
I think it's Oracle version 8.1.7.4.0 running on a Sun box.
Has anyone seen this before or does anyone have any
suggestions on the cause of the problem?
I have been told it has to do with indexes
and I know there are many indexes on this table.
The table is also partitioned.
Thanks,
- johnplz copy and paste here your tests
i am running 8.1.7.4.0 too and all is fine here...
(i heard about a count(*) problem but on a lite version of an old 8.0.x...)
Fred -
"select count(*) from dba_jobs_running" takes 5 minutes to return
Hi,
I login as sys or system from sql*plus to run query "select count(*) from dba_jobs_running". This query takes about 5 minutes to run.
Querying other DBA_* views returns instantly, only this dba_jobs_running view is troubling.
I have 11 records in dba_jobs, and 18 records in v$lock as usual.
No error or warning in logfile, no trace file.
What's possibly wrong with the server?
Thanks,
HarryHi,
The following are the exact statements I used to create the trace file:
alter session set timed_statistics=true;
alter session set max_dump_file_size=unlimited;
alter session set events '10046 trace name context forever, level 12';
select count(*) from dba_jobs_running;
exit;
The content of the trace file is attached at the end.
If it is CPU bound, I have no activity on the db host. I am solely using it to analyze this problem.
load averages: 0.02, 0.02, 0.07 22:16:38
48 processes: 47 sleeping, 1 on cpu
CPU states: 98.4% idle, 1.6% user, 0.0% kernel, 0.0% iowait, 0.0% swap
Memory: 1792M real, 983M free, 517M swap in use, 2937M swap free
PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
655 oracle 1 59 0 0K 0K sleep 1:14 0.32% oracle
865 oracle 1 59 0 2072K 1184K cpu 0:00 0.14% top
667 oracle 1 59 0 0K 0K sleep 0:13 0.08% oracle
663 oracle 1 59 0 0K 0K sleep 0:27 0.07% oracle
665 oracle 1 59 0 0K 0K sleep 0:15 0.02% oracle
671 oracle 1 59 0 0K 0K sleep 0:00 0.02% oracle
645 oracle 18 59 0 0K 0K sleep 0:23 0.01% oracle
657 oracle 1 59 0 0K 0K sleep 0:14 0.00% oracle
649 oracle 1 59 0 0K 0K sleep 0:02 0.00% oracle
659 oracle 1 59 0 0K 0K sleep 0:01 0.00% oracle
251 root 20 59 0 3256K 2512K sleep 0:00 0.00% nscd
70 root 5 59 0 2864K 2096K sleep 0:00 0.00% picld
224 root 3 59 0 3912K 2008K sleep 0:00 0.00% automountd
271 root 1 59 0 4408K 1896K sleep 0:00 0.00% sendmail
588 oracle 1 59 0 2600K 1864K sleep 0:00 0.00% bash
Any help is greatly appreciated.
<-- TRACE FILE CONTENT -->
*** 2006-11-21 21:34:54.413
*** SESSION ID:(21.832) 2006-11-21 21:34:54.412
APPNAME mod='[email protected] (TNS V1-V3)' mh=0 act='' ah=0
=====================
PARSING IN CURSOR #1 len=69 dep=0 uid=0 oct=42 lid=0 tim=107123626140 hv=2004533713 ad='97219d80'
alter session set events '10046 trace name context forever, level 12'
END OF STMT
EXEC #1:c=0,e=346,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=107123625473
WAIT #1: nam='SQL*Net message to client' ela= 11 p1=1650815232 p2=1 p3=0
WAIT #1: nam='SQL*Net message from client' ela= 6476024 p1=1650815232 p2=1 p3=0
=====================
PARSING IN CURSOR #1 len=37 dep=0 uid=0 oct=3 lid=0 tim=107130104260 hv=2246554324 ad='97c21958'
select count(*) from dba_jobs_running
END OF STMT
PARSE #1:c=0,e=548,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=107130104237
BINDS #1:
EXEC #1:c=0,e=1412,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=107130106034
WAIT #1: nam='SQL*Net message to client' ela= 12 p1=1650815232 p2=1 p3=0
*** 2006-11-21 21:40:53.931
FETCH #1:c=350760000,e=344612113,p=0,cr=2,cu=16652,mis=0,r=1,dep=0,og=4,tim=107474718456
WAIT #1: nam='SQL*Net message from client' ela= 1936 p1=1650815232 p2=1 p3=0
FETCH #1:c=0,e=6,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=107474721309
WAIT #1: nam='SQL*Net message to client' ela= 8 p1=1650815232 p2=1 p3=0
*** 2006-11-21 21:56:30.972
WAIT #1: nam='SQL*Net message from client' ela= 915075702 p1=1650815232 p2=1 p3=0
XCTEND rlbk=0, rd_only=1
STAT #1 id=1 cnt=1 pid=0 pos=1 obj=0 op='SORT AGGREGATE (cr=2 r=0 w=0 time=100535896 us)'
STAT #1 id=2 cnt=0 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=2 r=0 w=0 time=100535876 us)'
STAT #1 id=3 cnt=5550 pid=2 pos=1 obj=0 op='MERGE JOIN CARTESIAN (cr=2 r=0 w=0 time=128639 us)'
STAT #1 id=4 cnt=10 pid=3 pos=1 obj=0 op='NESTED LOOPS OUTER (cr=2 r=0 w=0 time=5839 us)'
STAT #1 id=5 cnt=10 pid=4 pos=1 obj=69 op='FIXED TABLE FULL X$KSQRS (cr=0 r=0 w=0 time=4790 us)'
STAT #1 id=6 cnt=10 pid=4 pos=2 obj=202 op='INDEX UNIQUE SCAN OBJ#(202) (cr=2 r=0 w=0 time=561 us)'
STAT #1 id=7 cnt=5550 pid=3 pos=2 obj=0 op='BUFFER SORT (cr=0 r=0 w=0 time=90039 us)'
STAT #1 id=8 cnt=555 pid=7 pos=1 obj=16 op='FIXED TABLE FULL X$KSUSE (cr=0 r=0 w=0 time=1277 us)'
STAT #1 id=9 cnt=0 pid=2 pos=2 obj=0 op='VIEW (cr=0 r=0 w=0 time=344148954 us)'
STAT #1 id=10 cnt=105477 pid=9 pos=1 obj=0 op='UNION-ALL (cr=0 r=0 w=0 time=343814331 us)'
STAT #1 id=11 cnt=105476 pid=10 pos=1 obj=0 op='VIEW (cr=0 r=0 w=0 time=203487737 us)'
STAT #1 id=12 cnt=105476 pid=11 pos=1 obj=0 op='UNION-ALL (cr=0 r=0 w=0 time=202961626 us)'
STAT #1 id=13 cnt=0 pid=12 pos=1 obj=272 op='FIXED TABLE FULL X$KDNSSF (cr=0 r=0 w=0 time=13633786 us)'
STAT #1 id=14 cnt=105476 pid=12 pos=2 obj=72 op='FIXED TABLE FULL X$KSQEQ (cr=0 r=0 w=0 time=188317145 us)'
STAT #1 id=15 cnt=0 pid=10 pos=2 obj=253 op='FIXED TABLE FULL X$KTADM (cr=0 r=0 w=0 time=76301426 us)'
STAT #1 id=16 cnt=1 pid=10 pos=3 obj=254 op='FIXED TABLE FULL X$KTCXB (cr=0 r=0 w=0 time=62693462 us)'
STAT #1 id=16 cnt=1 pid=10 pos=3 obj=254 op='FIXED TABLE FULL X$KTCXB (cr=0 r=0 w=0 time=62693462 us)'
<---- END of TRACE FILE --> -
'select count(*) from x' returns 5460 rows and 'Select * from x' returns 0 rows
As you can see in the next lines something is wrong in my Oracle (8.0.6 on Win NT 4.0 sp 6a) :
Oracle8 Enterprise Edition Release 8.0.6.0.0 - Production
With the Partitioning option
PL/SQL Release 8.0.6.0.0 - Production
SQLWKS> SELECT * FROM V_TERRA_TE;
PERIOD_DATE PERIOD_TIME TERRARCV TERRASND TERCV TESND
0 rows selected.
SQLWKS> SELECT COUNT(*) FROM V_TERRA_TE;
COUNT(*)
5460
1 row selected.
V_TERRA_TE is a complex join of 5 Tables :
CREATE OR REPLACE VIEW "ACTUATE".V_TERRA_TE AS Select to_date(to_char(p1.period_date,'YYYYMMDD'),'YYYYMMDD') "PERIOD_DATE",
to_date(to_char(p1.period_time,'HH24:MI'),'HH24:MI') "PERIOD_TIME",
to_number(p1.caudalrcv + ((p3.caudalrcv + p4.caudalrcv)*(confterrate.conexadslterra/confterrate.conexadsltotal))) "TERRARCV",
to_number(p1.caudalsnd + ((p3.caudalsnd + p4.caudalsnd)*(confterrate.conexadslterra/confterrate.conexadsltotal))) "TERRASND",
to_number((p2.caudalrcv * confterrate.pctinfonegocio) + ((p3.caudalrcv + p4.caudalrcv)*(confterrate.conexadslte/confterrate.conexadsltotal)))"TERCV",
to_number((p2.caudalsnd * confterrate.pctinfonegocio) + ((p3.caudalsnd + p4.caudalsnd)*(confterrate.conexadslte/confterrate.conexadsltotal)))"TESND"
from p1,p2,p3,p4,confterrate
where (p1.period_date=p2.period_date)and
(p1.period_date=p3.period_date)and
(p1.period_date=p4.period_date)and
(p1.period_time=p3.period_time)and
(p1.period_time=p4.period_time)and
(p1.period_time=p2.period_time)and
to_char(p1.period_date,'MMYYYY')=to_char(confterrate.period_datetime,'MMYYYY');
I think that some not reported error happens in the select * with some temporary space or similar but only the message '0 rows selected' is displayed (instead the real error)
Could somebody help me ?
Thanks in advance
FranciscoForcing the Join/sort to be made on Disk (not on memory) the problem not happens. This demostrate that ORACLE has a VERY IMPORTANT BUG : It returns 0 rows wich is false.
To force it to work on disk i use this parameters :
alter session set sort_area_size=0
alter session set hash_join_enabled=false
Note : probably is not the best combination or use of parameters, but using it the query works as espected. -
How Can I Select Folder From itunes will import my photos?
When I begin to sync my ipod Classic with itunes 8.0, I see the screen with tabs on it that allow me to set my upload preferences. When the syncing is occurring, I'm unable to make any changes. When the syncing is completed, this screen disappears and I can't seem to bring it up again.
I want to use this screen to change the folder from which the photos that will show on my ipod will come from.
Will somebody tell me how to get to the screen that will allow me to change the folder that my photos to be stored on my ipod come from?
Thanks.*When the syncing is completed, this screen disappears and I can't seem to bring it up again.*
Have you tried clicking directly on the iPod icon in the iTunes source list to bring up the preference tabs in the main pane?
You can also use a keyboard command to prevent your iPod auto-syncing with iTunes which might help. While connecting the iPod to the computer on Windows hold down the Shift + Ctrl keys together. This will stop the iPod from auto-syncing with iTunes and the iPod will appear in the source list. Wait until you are sure the iPod has mounted, and that it will not auto sync and then you can let the keys go. This may take between 20 to 30 seconds depending on your computer. -
SELECT from XML to get multiple rows
We are trying to set up web services to facilitate access to a central asset database. I’m able to make the request, & I store the response in the following table:
CREATE TABLE assets
(asset_name VARCHAR2(40),
asset_xml XMLType,
add_dt DATE);
Different asset types can have the same name so when I get a response there may be several assets returned with the same name but different types as seen in this formatted XML:
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<AssetDetailsResponse>
<Asset>
<ID>44535</ID>
<AssetName>asset1</AssetName>
<TypeName>Server</TypeName>
<Status>Active</Status>
<SerialNumber>jk823</SerialNumber>
<Business>Finance</Business>
<Vendor>hewlett packard</Vendor>
<Location>
<CountryName>United States</CountryName>
<StateProvName>Ohio</StateProvName>
<CityTownName>Cincinnati</CityTownName>
<Street>2875 Vine Street</Street>
<PostalCode>45229</PostalCode>
</Location>
</Asset>
<Asset>
<ID>453051</ID>
<AssetName>asset1</AssetName>
<TypeName>Tape Backup</TypeName>
<Status>Inactive</Status>
<SerialNumber>s97032</SerialNumber>
<Business>Sales</Business>
<Vendor>Any vendor</Vendor>
<Location>
<CountryName>United States</CountryName>
<StateProvName>Ohio</StateProvName>
<Street>7683 Main Street</Street>
<CityTownName>Cincinnati</CityTownName>
<PostalCode>45492</PostalCode>
</Location>
</Asset>
</AssetDetailsResponse>
</soapenv:Body>
</soapenv:Envelope>
The following query works but the assets are strung together rather than on separate rows:
SQL> SELECT extract(asset_xml, '//AssetName/text()') from gewscadb;
EXTRACT(ASSET_XML,'//ASSETNAME/TEXT()')
asset1asset1
I have tried the following queries to return separate rows but they return “no rows selected”:
SELECT a.asset_id, a.asset_name
FROM assets,
XMLTABLE('/Asset' PASSING assets.asset_xml
COLUMNS asset_id VARCHAR2(20) PATH '/Asset/ID',
asset_name VARCHAR2(30) PATH '/Asset/AssetName') a;
SELECT a.asset_id, a.asset_name
FROM assets,
XMLTABLE('/AssetDetailsResponse'
PASSING assets.asset_xml
COLUMNS asset_id VARCHAR2(20) PATH '/AssetDetailsResponse/Asset/ID',
asset_name VARCHAR2(30) PATH '/AssetDetailsResponse/Asset/AssetName') a;
I suspect there is a problem with my path names in these queries. Can someone please provide some guidance on how I can get a separate row for each asset?Hi,
You must use a double slash to extract assets nodes :
WITH assets AS (
SELECT xmltype('<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<AssetDetailsResponse>
<Asset>
<ID>44535</ID>
<AssetName>asset1</AssetName>
<TypeName>Server</TypeName>
<Status>Active</Status>
<SerialNumber>jk823</SerialNumber>
<Business>Finance</Business>
<Vendor>hewlett packard</Vendor>
<Location>
<CountryName>United States</CountryName>
<StateProvName>Ohio</StateProvName>
<CityTownName>Cincinnati</CityTownName>
<Street>2875 Vine Street</Street>
<PostalCode>45229</PostalCode>
</Location>
</Asset>
<Asset>
<ID>453051</ID>
<AssetName>asset1</AssetName>
<TypeName>Tape Backup</TypeName>
<Status>Inactive</Status>
<SerialNumber>s97032</SerialNumber>
<Business>Sales</Business>
<Vendor>Any vendor</Vendor>
<Location>
<CountryName>United States</CountryName>
<StateProvName>Ohio</StateProvName>
<Street>7683 Main Street</Street>
<CityTownName>Cincinnati</CityTownName>
<PostalCode>45492</PostalCode>
</Location>
</Asset>
</AssetDetailsResponse>
</soapenv:Body>
</soapenv:Envelope>') asset_xml
FROM dual
SELECT a.asset_id, a.asset_name
FROM assets,
XMLTABLE(
'//Asset' -- << Here
PASSING assets.asset_xml
COLUMNS asset_id VARCHAR2(20) PATH '/Asset/ID',
asset_name VARCHAR2(30) PATH '/Asset/AssetName'
) a; -
How to select data from AZure table storage without row key and partition key
Hi
I need to select a data from azure table storage without rowkey and partition key. how in azure storage emulator click query it display all data from that table.
thanks
rajeshHi rajesh,
It seems that you didn't click query data using storage emulator. But I recommend you could use the azure server explore in your VS to view your data and query data. Please see this document (http://msdn.microsoft.com/en-us/library/azure/ff683677.aspx).
And base on my experience, you may need input the command on Azure storage emulator, such as this page(http://msdn.microsoft.com/en-us/library/azure/gg433005.aspx).
Regards,
Will
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Select Count(*) and actual row are differ: 136 rows vs 65k x 7 rows
Dear All,
Good morning. Need your advices. We had a view which is running and producing output to excel files. But recently after one of ours database migration, it were producing differ result: Select Count(*) and actual row are differ: 136 rows vs 65k x 7 rows. Error happen when we export out the row to csv file is produced 65000 rows x 7 worksheep. But when perform select count(*) from RTNEWWIP, result return: 136 rows.
Is there any way to trace below sql to find where go wrong?
The Veiw as below:
CREATE OR REPLACE VIEW RTNEWWIP
(FAB_ID, PO, PRD_NO, SHP_PRD_NO, LOT,
WIP_QTY, ROUTEDESC, IN_TIME, STAY_DAY, BACK_DAY,
WO_FCST_DATE, SHIP_FCST_DATE, SHIP_CONF_DATE, WS_DATE, ROUTERATIO,
PROCESS, LOTSTATUS, LOTTYPE, RETICLEVERSION, PROCESSVERSION,
ROUTESEQUENCE, PRIORITY, PROCESSGEN, PROCESSFAMILY)
AS
select
--ord.order_no,
'SILTERRA' FAB_ID,
wip.PO_NUMBER PO,
wip.FW_DEVICE PRD_NO,
wip.USER_ITEM_DESCRIPTION SHP_PRD_NO,
wip.LOT_ID LOT,
wip.CURR_QTY WIP_QTY,
wip.STEP_DESC ROUTEDESC,
to_char(wip.RECORD_START_DATE,'DD-MON-YYYY HH24:MI:SS') IN_TIME,
to_char((sysdate - wip.RECORD_START_DATE),'9999D99') STAY_DAY,
to_char((wip.SCHEDULED_COMPLETE_DATE - sysdate),'9999D99') BACK_DAY,
-- (sysdate - wip.RECORD_START_DATE) STAY_DAY,
-- (wip.SCHEDULED_COMPLETE_DATE - sysdate) BACK_DAY,
to_char(wip.SCHEDULED_COMPLETE_DATE,'DD-MON-YYYY') WO_FCST_DATE,
to_char((wip.SCHEDULED_COMPLETE_DATE + 1),'DD-MON-YYYY') SHIP_FCST_DATE,
--nvl(oel.attribute15, to_char(sysdate+3650,'DD-MON-YYYY')) SHIP_CONF_DATE,
to_char(nvl(to_date(oel.attribute15,'DD-MON-YYYY'), sysdate+3650),'DD-MON-YYYY') SHIP_CONF_DATE,
to_char(wip.LOT_START_DATE,'DD-MON-YYYY') WS_DATE,
--wip.MASK_NO || '/' || wip.MASK_TOTAL ROUTERATIO,
'''' ||wip.MASK_NO || '/' || wip.MASK_TOTAL ROUTERATIO,
wip.PLAN_NAME_ACTIVE PROCESS,
wip.LOT_STATUS LOTSTATUS,
wip.LOT_TYPE LOTTYPE,
0 RETICLEVERSION,
wip.PLAN_VERSION_ACTIVE PROCESSVERSION,
0 ROUTESEQUENCE,
wip.PRIORITY PRIORITY,
' ' PROCESSGEN,
' ' PROCESSFAMILY
from wip_report wip, lot_fact lf, order_fact orf, order_dim ord,
apps.oe_order_headers_all@prod_myfabetl oeh,
apps.oe_order_lines_all@prod_myfabetl oel
where wip.CUSTNAME like 'Realtek%'
--AND WIP.FW_DEVICE like '%R25C'
and wip.ACTIVE_FACT_KEY = lf.RECORD_KEY
and lf.ORDER_FACT_KEY = orf.RECORD_KEY
and orf.ORDER_KEY = ord.RECORD_KEY
and ord.ORDER_NO = to_char(oeh.order_number)
and oeh.header_id = oel.header_id
and orf.LINE_ITEM_NUMBER = to_char(oel.line_number)
and orf.ITEM_SCHEDULE = to_char(oel.shipment_number)
and wip.LOT_TYPE in ('ENX','PRA','PRD','PRT','CSK','MPW')
union all
select --od.order_no,'
'SILTERRA' FAB_ID,
od.CUST_PO PO,
imd.FW_DEVICE_ID PRD_NO,
nvl(orf.USER_ITEM_DESCRIPTION, nvl(imd.CUST_DEVICE_ID, imd.FW_DEVICE_ID)) SHP_PRD_NO,
sfl.LOTID LOT,
sfl.currentcompqty WIP_QTY,
'CREATED' ROUTEDESC,
to_char(to_date(substr(recordstartdate,1, 14), 'yyyymmddhh24miss'), 'DD-MON-YYYY HH24:MI:SS') IN_TIME,
--sysdate - to_date(substr(recordstartdate,1, 14), 'yyyymmddhh24miss') STAY_DAY,
--to_date(sfl.scheduledcompletedate,'yyyymmdd') - sysdate BACK_DAY,
to_char(sysdate - to_date(substr(recordstartdate,1, 14), 'yyyymmddhh24miss'),'9999D99') STAY_DAY,
to_char(to_date(sfl.scheduledcompletedate,'yyyymmdd') - sysdate,'9999D99')BACK_DAY,
to_char(to_date(sfl.scheduledcompletedate,'yyyymmdd'),'DD-MON-YYYY') WO_FCST_DATE,
to_char(to_date(sfl.scheduledcompletedate,'yyyymmdd') + 1, 'DD-MON-YYYY') SHIP_FCST_DATE,
--nvl(oel.attribute15, to_char(sysdate+3650,'DD-MON-YYYY')) SHIP_CONF_DATE,
to_char(nvl(to_date(oel.attribute15,'DD-MON-YYYY'), sysdate+3650),'DD-MON-YYYY') SHIP_CONF_DATE,
to_char(to_date(sfl.startdate,'yyyymmdd'), 'DD-MON-YYYY') WS_DATE,
' ' ROUTERATIO,
sfl.tempprocessplan PROCESS,
sfl.currentstatus LOTSTATUS,
sfl.currenttype LOTTYPE,
0 RETICLEVERSION,
0 PROCESSVERSION,
0 ROUTESEQUENCE,
' ' PRIORITY,
' ' PROCESSGEN,
' ' PROCESSFAMILY
from SIL_FW_LOTCREATED_VIEW sfl, order_dim od, order_fact orf, item_master_dim imd,
apps.oe_order_headers_all@prod_myfabetl oeh,
apps.oe_order_lines_all@prod_myfabetl oel
where substr(sfl.salesorderno,1,instr(sfl.salesorderno,'-',1,1)-1)= to_char(od.ORDER_NO)
and od.RECORD_KEY = orf.ORDER_KEY
and od.RECORD_CURRENT_FLAG = 1
and orf.RECORD_CURRENT_FLAG =1
and to_char(orf.LINE_ITEM_NUMBER) = substr(sfl.salesorderno,instr(sfl.salesorderno, '-',1,1) +1, (instr(sfl.salesorderno, '.',1,1) -1) - instr(sfl.salesorderno, '-',1,1))
and to_char(orf.ITEM_SCHEDULE) = substr(sfl.salesorderno,instr(sfl.salesorderno, '.',1,1) +1, length(salesorderno) - instr(sfl.salesorderno, '.',1,1))
and orf.ITEM_MASTER_KEY = imd.RECORD_KEY
and sfl.customername = 'Realtek'
and od.ORDER_NO = to_char(oeh.order_number)
and oeh.header_id = oel.header_id
and orf.LINE_ITEM_NUMBER = to_char(oel.line_number)
and orf.ITEM_SCHEDULE = to_char(oel.shipment_number);
select count(*) from rtnewwip;
COUNT(*)
136
1 row selectedquery might be referring to different environment/schema as you are using database link to access some tables.
getting result/count from view means executing query which forms that view. try to run that query separately and see the output.
it may help you to debug -
Select count(*) failure
I'm trying to determine if select count(*) on an existing table could ever fail without there being worse problems that have involved the db and sys admins.
Instinct says no, it can't fail without databases/systems being unavailable.
But I've learned NOT to trust instinct when it comes to IT.
Can anyone relate any situations where they've seen select count(*) fail?Hi,
user639265 wrote:
I'm trying to determine if select count(*) on an existing table could ever fail without there being worse problems that have involved the db and sys admins.
Instinct says no, it can't fail without databases/systems being unavailable.In this case, your instinct is right.
If the table really exists, and you have the necessary privileges, then "SELECT COUNT (*) FROM table_x;" will return exactly one row.
The only time it would raise an error would be some serious problem (like database or network failure).
If there is row-level security or fine-grained auditing on the table, then all bets are off: the function that is run in those cases could raise any kind of error.
Maybe you are looking for
-
Here's a layout puzzle looking for a good solution
Does anyone have ideas what the best way to do this might be? I am writing a long book text (several hundred pages) which should be in a single continuous column. I want to have occasional brief notes placed outside the text and alongside, in the mar
-
Creating Database Views at Runtime
I want to create database views (on the fly) every time an ODI Package is executed. The views will be used as sources during step 2 of the Package. How can I create interface that will create these views that can be the first step in my Package? Woul
-
I use SSRS 2008 R2 in SharePoint 2010 integrated mode. Today a customer did not receive any emails from SSRS subscriptions. In the log I can see Errors dbcleanup!WindowsService_0!3164!04/04/2014-01:03:37:: e ERROR: Sql Error in CleanExpiredSessions:
-
WIN - UNIX: color palette
Hi, How can you port as color palette definition file from win -> unix and get your custom colors displayed Form help guide takes you only to the point of creating a custom color palette and using it on windows - not actually deploying it ! I've trie
-
At sea trying to move photos from laptop to desktop
I have two copies of LR 1.41. The desktop runs Vista Home Premium SP1 and the laptop runs XP SP3. Please, someone give me a straighforward way to move these files so that the edits show up in the desktop. I have tried exporting, exporting as a catalo