Help with reworking this query
Hi Gurus.
I use the following script on an ad-hoc basis to check free space in tablespaces and it works fine.
However I would like to trim this script so that it outputs to a small file which can then be emailed. I would like the file to only contain the % free column of the original output.
I have tried but failed miserably in an effort to change this query. Can anyone assist?
set lines 200 pages 2000
col tablespace_name heading 'Tablespace' format a30 truncate
col total_maxspace_mb heading 'MB|Max Size' format 9G999G999
col total_allocspace_mb heading 'MB|Allocated' format 9G999G999
col used_space_mb heading 'MB|Used' format 9G999G999D99
col free_space_mb heading 'MB|Free Till Max' like used_space_mb
col free_space_ext_mb heading 'MB|Free Till Ext' like used_space_mb
col pct_used heading '%|Used' format 999D99
col pct_free heading '%|Free' like pct_used
break on report
compute sum label 'Total Size:' of total_maxspace_mb total_allocspace_mb used_space_mb - free_space_mb (used_space_mb/total_maxspace_mb)*100 on report
select /*+ALL_ROWS */
alloc.tablespace_name,
alloc.total_maxspace_mb,
alloc.total_allocspace_mb,
(alloc.total_allocspace_mb - free.free_space_mb) used_space_mb,
free.free_space_mb+(alloc.total_maxspace_mb-alloc.total_allocspace_mb) free_space_mb,
free.free_space_mb free_space_ext_mb,
((alloc.total_allocspace_mb - free.free_space_mb)/alloc.total_maxspace_mb)*100 pct_used,
((free.free_space_mb+(alloc.total_maxspace_mb-alloc.total_allocspace_mb))/alloc.total_maxspace_mb)*100 pct_free
FROM (SELECT tablespace_name,
ROUND(SUM(CASE WHEN maxbytes = 0 THEN bytes ELSE maxbytes END)/1048576) total_maxspace_mb,
ROUND(SUM(bytes)/1048576) total_allocspace_mb
FROM dba_data_files
WHERE file_id NOT IN (SELECT FILE# FROM v$recover_file)
GROUP BY tablespace_name) alloc,
(SELECT tablespace_name,
SUM(bytes)/1048576 free_space_mb
FROM dba_free_space
WHERE file_id NOT IN (SELECT FILE# FROM v$recover_file)
GROUP BY tablespace_name) free
WHERE alloc.tablespace_name = free.tablespace_name (+)
ORDER BY pct_used DESC
SELECT tablespace_name
FROM dba_data_files
WHERE file_id NOT IN (SELECT FILE# FROM v$recover_file)
GROUP BY tablespace_name alloc,
(SELECT tablespace_name,
SUM(bytes)/1048576 free_space_mb
FROM dba_free_space
WHERE file_id NOT IN (SELECT FILE# FROM v$recover_file)
GROUP BY tablespace_name) free
WHERE alloc.tablespace_name = free.tablespace_name (+)
ORDER BY pct_used DESC;
The output from this is:
MB MB MB MB MB % %
Tablespace Max Size Allocated Used Free Till Max Free Till Ext Used Free
APPS_TS_TX_IDX 18,197 17,730
APPS_TS_TX_DATA 25,600 24,832 24,746.38 853.63 85.63 96.67 3.33
APPS_TS_ARCHIVE 2,048 2,048 1,963.00 85.00 85.00 95.85 4.15
APPS_TS_MEDIA 10,240 8,693 8,662.88 1,577.13 30.13 84.60 15.40
I would like to ideally have only the % Free column (at the far right) returned.
Oracle 10.2.0.4
Linux RH 4.
Thanks in advance.
DA
I have a simple query for tablespace growth check. try this if it suits for you,
select t1.n1 "Tablespace Name",
t2.total "Total size",
(t2.total-t1.free) "Used Size" ,
t1.free "Free space",
trunc((t1.free/t2.total)*100) "%free " ,
trunc((1-t1.free/t2.total)*100) "% used"
from
(select tablespace_name n1,trunc(sum(bytes)/1024/1024) free
from dba_free_space where tablespace_name not in ('CWMLITE','DRSYS','ODM','XDB','EXAMPLE','TOOLS')
group by tablespace_name ) t1 ,
(select trunc(sum(bytes)/1024/1024) total,tablespace_name n2
from dba_Data_files where tablespace_name not in ('CWMLITE','DRSYS','ODM','XDB','EXAMPLE','TOOLS')
group by tablespace_name) t2
where t1.n1=t2.n2;
Similar Messages
-
i am using
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
With the Partitioning option
JServer Release 8.1.7.4.0 - Production
Please help to simplify this query. I also want to make this as a procedure.
select
RH.resort as RH_RESORT,
RH.rate_code as RH_RATE_CODE,
RD.rate_detail_id as RD_RATE_DETAIL_ID,
RD.rate1 as RD_RATE1,
RD.rate2 as RD_RATE2,
RD.rate3 as RD_RATE3,
RD.rate4 as RD_RATE4,
RD.rate5 as RD_RATE5,
RRC.room_category as RM_CAT,
initcap(RRMCAT.long_description) as RM_DESC,
RH.DAY1,
RH.DAY2,
RH.DAY3,
RH.DAY4,
RH.DAY5,
RH.DAY6,
RH.DAY7,
RH.WEEKEND1,
RH.WEEKEND2,
RH.WEEKEND3,
RH.WEEKEND4,
RH.WEEKEND5,
RH.WEEKEND6,
RH.WEEKEND7
from pms_rate_header RH,
pms_rate_detail RD,
pms_rate_room_cat RRC,
resort_room_category RRMCAT
where RH.inactive_date is NULL
and RH.RESORT='FABGOI'
and RH.RATE_CODE ='CRRRACK'
and ('15-Jan-2007' >= RH.BEGIN_DATE
and '16-Jan-2007' <= RH.END_DATE)
and RD.rate_header_id=RH.rate_header_id
and RD.inactive_date is NULL
and ('15-Jan-2007' >= RD.BEGIN_DATE
and '16-Jan-2007' <= RD.END_DATE)
and RRC.rate_detail_id=RD.rate_detail_id
and RRC.resort=RH.resort
and RRMCAT.resort=RH.resort
and RRMCAT.room_category=RRC.room_category
and RRC.inactive_date is NULL
and RRMCAT.inactive_date IS NULL
regards
lee1212where RH.inactive_date is NULL
and RH.RESORT='FABGOI'
and RH.RATE_CODE ='CRRRACK'
and ('15-Jan-2007' >= RH.BEGIN_DATE
and '16-Jan-2007' <= RH.END_DATE)
and RD.rate_header_id=RH.rate_header_id
and RD.inactive_date is NULL
and ('15-Jan-2007' >= RD.BEGIN_DATE
and '16-Jan-2007' <= RD.END_DATE)
and RRC.rate_detail_id=RD.rate_detail_id
and RRC.resort=RH.resort
and RRMCAT.resort=RH.resort
and RRMCAT.room_category=RRC.room_category
and RRC.inactive_date is NULL
and RRMCAT.inactive_date IS NULL
in the above part i am finding repeated joins and lot of 'and's
i want to know any line can be eliminated or the the query can be rewritten in a simple way without affecting it's accuracy?
regards
Lee1212 -
Need some help with the Select query.
Need some help with the Select query.
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
select single vkorg abgru from ZADS into it_rej.
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
This is causing performance issue. They are asking me to include the where condition for this select query.
What should be my select query here?
Please suggest....
Any suggestion will be apprecaiated!
Regards,
DeveloperHello Everybody!
Thank you for all your response!
I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table
select vkorg abgru from ZADS into it_rej.
Earlier :
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
Now :
DATA : BEGIN OF IT_REJ occurs 0,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
I guess this will fix the issue correct?
PLease suggest!
Regards,
Developer. -
Could you please help me make this query less complicated
could you please help me make this query less complicated
select t1.R_OBJECT_ID
from dm_relation_sp a, ddt_resolution_sp t1
where a.parent_id = '0900000283560456' -----------ID
and a.child_id = t1.R_OBJECT_ID
union all
select t3.R_OBJECT_ID
from ddt_resolution_sp t3
where t3.R_OBJECT_ID in (select t2.child_id
from dm_relation_sp t2
where t2.parent_id in (select a.child_id
from asud_fsk.dm_relation_sp a, asud_fsk.ddt_resolution_sp t1
where a.parent_id = '0900000283560456' -----------ID
and a.child_id = t1.R_OBJECT_ID))
union all
select t4.R_OBJECT_ID
from ddt_resolution_sp t4
where t4.R_OBJECT_ID in(
select t3.child_id from dm_relation_sp t3
where t3.parent_id in (
select t2.child_id
from asud_fsk.dm_relation_sp t2
where t2.parent_id in (select a.child_id
from asud_fsk.dm_relation_sp a, asud_fsk.ddt_resolution_sp t1
where a.parent_id = '0900000283560456' -----------ID
and a.child_id = t1.R_OBJECT_ID))
and t3.relation_name = 'RESOLUTION_RELATION')
union all
select t5.R_OBJECT_ID
from ddt_resolution_sp t5
where t5.R_OBJECT_ID in
(select t4.child_id
from dm_relation_sp t4
where t4.parent_id in(
select t3.child_id from dm_relation_sp t3
where t3.parent_id in (
select t2.child_id
from asud_fsk.dm_relation_sp t2
where t2.parent_id in (select a.child_id
from asud_fsk.dm_relation_sp a, asud_fsk.ddt_resolution_sp t1
where a.parent_id = '0900000283560456' -----------ID
and a.child_id = t1.R_OBJECT_ID))
and t3.relation_name = 'RESOLUTION_RELATION')
and t4.relation_name = 'RESOLUTION_RELATION')
Edited by: user13025450 on 29.04.2010 16:23Hi,
Welcome to the forum! You'll find that there are many qualified people (such as Tubby) willing to help you. Will you do what you can to help them? In order to simplify the query you posted,someone will first have to understand what it does, what the tables that it uses are like, and what tools you have to work with (that is, what version of Oracle, and any other software you are using). To actually test their ideas, people will need versions of your tables.
Many people, if they spent enough time, might be able to figure out roughly what you are doing, make some tables themselves and test a solution. You can help with all of that. I assume you already know what the appliction is, and what this particular query is supposed to do: you don't have to figure out any of that, you just have to say it. You know what all your tables are, what the datatypes of all the columns are, and what kinds of data are in the tables: you don't have to guess at any of that.
Describe what you're doing. Think about it: how do we know that
SELECT NULL
FROM dual;doesn't do what you want?
Post CREATE TABLE and INSERT statements for a little sample data.
Post the results that this query is supposed to produce from those results. (Is it producing the right output now? Then it should be easy to post the correct results.)
Describe, as well as you can, how the present query is doing it.
Format your existing code, so it's easy to see what the different branches of the UNION are, and what the main clauses are in each one.
When posting formatted text (code or results) type these 6 characters
\(all small letters, inside curly brackets) before and after each formatted section, to keep this site from compressing the spaces.
Say what versions of Oracle (e.g. 10.2.0.3.0) and any other relevant software you are using.
I know it's a lot of work, but it really helps. You can do it as well (probably better) than anyone else, and if you're unwilling to do it, why should anyone else be willing? -
Hi,
I'm using below query in procedure.It's taking more more time can some one help to tune this query or advice to rewrite the query.
Databse :10.1
SELECT 'Reading Comprehension' TEST_NAME,T.TEST_END_DATE TEST_SESSION_DATE,
C.POOL_VERSION_ID, I.CREATED_ON POOL_CREATED_DT,
C.ITEM_ID, C.ITEM_RESPONSE_ID, S.STUDENT_ID_PK, C.RESPONSE_KEY, C.IS_CORRECT RESPONSE_IS_CORRECT,
T.SCORE SCALE_SCORE, C.RESPONSE_DURATION, P.ITEM_KEY,
T.TEST_SESSION_DETAIL_ID, SYSDATE CREATED_ON
-- BULK COLLECT INTO TV_PSYCHO_DET
FROM
CAT_ITEM_PARAMETER P, CAT_ITEM_USER_RESPONSE C, TEST_SESSION_DETAIL T,
TEST_SESSION S, ITEM_POOL_VERSION I, TEST_DETAIL D
,INSTITUTION E
WHERE TRUNC(T.TEST_END_DATE) BETWEEN TO_DATE('01-11-09','dd-mm-yy') AND TO_DATE('30-11-09','dd-mm-yy')
AND D.TEST_NAME = 'Reading Comprehension'
AND T.TEST_SESSION_STATUS_ID = 3
AND I.POOL_AVAILABILITY='Y'
AND P.PRETEST=0 AND C.RESTART_FLAG=0
AND T.TEST_DETAIL_ID = D.TEST_DETAIL_ID
AND S.TEST_SESSION_ID = T.TEST_SESSION_ID
AND C.TEST_SESSION_DETAIL_ID = T.TEST_SESSION_DETAIL_ID
AND S.INSTITUTION_ID=E.INSTITUTION_ID
AND SUBSTR(E.INSTITUTION_ID_DISPLAY,8,3) <> '000'
AND I.ITEM_ID = C.ITEM_ID
AND P.ITEM_ID = I.ITEM_ID;expln plan
Plan hash value: 3712814491
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart|
Pstop |
| 0 | SELECT STATEMENT | | 50857 | 7151K| 93382 (1)| 00:18:41 | |
|
|* 1 | FILTER | | | | | | |
|
|* 2 | HASH JOIN | | 50857 | 7151K| 93382 (1)| 00:18:41 | |
|
| 3 | PARTITION HASH ALL | | 2312 | 23120 | 25 (0)| 00:00:01 | 1 |
5 |
|* 4 | TABLE ACCESS FULL | CAT_ITEM_PARAMETER | 2312 | 23120 | 25 (0)| 00:00:01 | 1 |
5 |
|* 5 | HASH JOIN | | 94938 | 12M| 93356 (1)| 00:18:41 | |
|
|* 6 | TABLE ACCESS FULL | ITEM_POOL_VERSION | 9036 | 132K| 30 (0)| 00:00:01 | |
|
|* 7 | TABLE ACCESS BY GLOBAL INDEX ROWID | CAT_ITEM_USER_RESPONSE | 9 | 279 | 18 (0)| 00:00:01 | ROWID |
ROWID |
| 8 | NESTED LOOPS | | 45349 | 5270K| 93325 (1)| 00:18:40 | |
|
|* 9 | HASH JOIN | | 4923 | 423K| 11377 (1)| 00:02:17 | |
|
|* 10 | INDEX FAST FULL SCAN | INSTI_ID_NAME_COUN_DISP_IDX | 8165 | 111K| 18 (0)| 00:00:01 | |
|
|* 11 | HASH JOIN | | 4923 | 355K| 11359 (1)| 00:02:17 | |
|
|* 12 | TABLE ACCESS BY GLOBAL INDEX ROWID| TEST_SESSION_DETAIL | 4107 | 148K| 6804 (1)| 00:01:22 | ROWID |
ROWID |
| 13 | NESTED LOOPS | | 4923 | 278K| 6806 (1)| 00:01:22 | |
|
|* 14 | INDEX RANGE SCAN | TEST_DETAIL_AK_1 | 1 | 21 | 2 (0)| 00:00:01 | |
|
|* 15 | INDEX RANGE SCAN | TEST_SESSION_DETAIL_FK2_I | 39737 | | 102 (0)| 00:00:02 | |
|
| 16 | PARTITION HASH ALL | | 1672K| 25M| 4546 (1)| 00:00:55 | 1 |
5 |
| 17 | TABLE ACCESS FULL | TEST_SESSION | 1672K| 25M| 4546 (1)| 00:00:55 | 1 |
5 |
|* 18 | INDEX RANGE SCAN | CAT_ITEM_USER_RESP_IDX1 | 18 | | 3 (0)| 00:00:01 | |
|
Predicate Information (identified by operation id):
1 - filter(TO_DATE('01-11-09','dd-mm-yy')<=TO_DATE('30-11-09','dd-mm-yy'))
2 - access("P"."ITEM_ID"="I"."ITEM_ID")
4 - filter("P"."PRETEST"=0)
5 - access("I"."ITEM_ID"="C"."ITEM_ID")
6 - filter("I"."POOL_AVAILABILITY"='Y')
7 - filter(TO_NUMBER("C"."RESTART_FLAG")=0)
9 - access("S"."INSTITUTION_ID"="E"."INSTITUTION_ID")
10 - filter(SUBSTR("E"."INSTITUTION_ID_DISPLAY",8,3)<>'000')
11 - access("S"."TEST_SESSION_ID"="T"."TEST_SESSION_ID")
12 - filter(TRUNC(INTERNAL_FUNCTION("T"."TEST_END_DATE"))>=TO_DATE('01-11-09','dd-mm-yy') AND "T"."TEST_SESSION_STATUS_ID"=3
AND TRUNC(INTERNAL_FUNCTION("T"."TEST_END_DATE"))<=TO_DATE('30-11-09','dd-mm-yy'))
14 - access("D"."TEST_NAME"='Reading Comprehension')
15 - access("T"."TEST_DETAIL_ID"="D"."TEST_DETAIL_ID")
18 - access("C"."TEST_SESSION_DETAIL_ID"="T"."TEST_SESSION_DETAIL_ID")
43 rows selected.Edited by: user575115 on Dec 18, 2009 12:31 AMWhen you see something like ...
7 - filter(TO_NUMBER("C"."RESTART_FLAG")=0) It means that Oracle had to do a conversion for you since you aren't using the proper data type in your query.
That would mean IF there is an index on that column, it won't be useable... -
Help with an SQL Query on the Logger
We are running UCCE 8.5(3) and need help with an SQL query. When I run the below I would also like to see skill group information(name preferably)? Any help would be greatly appreciated!
select * from dbo.t_Termination_Call_Detail where DateTime between '10-11-2012 00:00:00:00' and
'10-11-2012 23:59:59:59'David, thanks for replying. Unfortunitly I don't know enough about SQL to put that into a query and have it return data. Would you be able to give an example on what the query would look like?
-
Please help to modifiy this query for better performance
Please help to rewrite this query for better performance. This is taking long time to execute.
Table t_t_bil_bil_cycle_change contains 1200000 rows and table t_acctnumberTab countains 200000 rows.
I have created index on ACCOUNT_ID
Query is shown below
update rbabu.t_t_bil_bil_cycle_change a
set account_number =
( select distinct b.account_number
from rbabu.t_acctnumberTab b
where a.account_id = b.account_id
Table structure is shown below
SQL> DESC t_acctnumberTab;
Name Type Nullable Default Comments
ACCOUNT_ID NUMBER(10)
ACCOUNT_NUMBER VARCHAR2(24)
SQL> DESC t_t_bil_bil_cycle_change;
Name Type Nullable Default Comments
ACCOUNT_ID NUMBER(10)
ACCOUNT_NUMBER VARCHAR2(24) YIshan's solution is good. I would avoid updating rows which already have the right value - it's a waste of time.
You should have a UNIQUE or PRIMARY KEY constraint on t_acctnumberTab.account_id
merge rbabu.t_t_bil_bil_cycle_change a
using
( select distinct account_number, account_id
from rbabu.t_acctnumberTab
) t
on ( a.account_id = b.account_id
and decode(a.account_number, b.account_number, 0, 1) = 1
when matched then
update set a.account_number = b.account_number -
Hi,
I have a query in my proj where the same table is looked up twice in the same query.
Can anybody suggest in improving the performance of this query?
select * from table1 a1 where (a1.column1, a1.column2, a1.column3, a1.column4, a1.column5, a1.column6, a1.column7, a1.column8, a1.column9,
a1.column10) in ( select a2.column1, a2.column2, a2.column3, a2.column4, a2.column5, a2.column6, a2.column7, a2.column8, a2.column9,
a2.column10 from table1 a2 where column20 = '<condn>')
The table1 used here is same in outer query as well as the sub query. this is a example of what we use here, and the table1 contains 30 million rows. Though, creating index with 10 columns can be a option, we already have a unique index with 11 columns(which includes 10 from this query) and will that be helpful in anyway? or the same existing index can be forced?
Thanks a lot for ur timeDepending on the selectivity of column20 I am not sure Index is the best way to go. It might perform better with two full scans and a hash-join.
Anyway, I do prefer the syntax:
select /*+ leading(a2) */ a1.*
from table1 a1, table1 a2
where a2.column20 = '<condn>'
and a1.column1 = a2.column1
and a1.column2 = a2.column2
and a1.column3 = a2.column3
and a1.column4 = a2.column4
and a1.column5 = a2.column5
and a1.column6 = a2.column6
and a1.column7 = a2.column7
and a1.column8 = a2.column8
and a1.column9 = a2.column9
and a1.column10 = a2.column10;I've added a leading hint to tell oracle that the start table is a2. Might be useless.
Ensure your stats are up to date. You might need histograms here if your column20 is skewed.
Hope this helps,
François
Edited by: Francois Berger on Oct 24, 2008 1:47 AM -
Help with Inner Join query in SQL
Hope someone can help with this, as this is quite an involved project for me, and I'm just about there with it.
My table structure is :
table_packages
packageID
package
packageDetails
etc
table_destinations
destinationID
destination
destinationDetails
etc
table_packagedestinations
packageID
destinationID
..so nothing that complicated.
So the idea is that I can have a package details page which shows the details of the package, along any destinations linked to that package via the packagedestinations table.
So this is the last part really - to get the page to display the destinations, but I'm missing something along the way....
This is the PHP from the header, including my INNER JOIN query....
PHP Code:
<?php
$ParampackageID_WADApackages = "-1";
if (isset($_GET['packageID'])) {
$ParampackageID_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
$ParamSessionpackageID_WADApackages = "-1";
if (isset($_SESSION['WADA_Insert_packages'])) {
$ParamSessionpackageID_WADApackages = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_packages'] : addslashes($_SESSION['WADA_Insert_packages']);
$ParampackageID2_WADApackages = "-1";
if (isset($_GET['packageID'])) {
$ParampackageID2_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
mysql_select_db($database_connPackages, $connPackages);
$query_WADApackages = sprintf("SELECT packageID, package, costperpax, duration, baselocation, category, dateadded, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, rollingtours, teambuilding, description, offer FROM packages WHERE packageID = %s OR ( -1= %s AND packageID= %s)", GetSQLValueString($ParampackageID_WADApackages, "int"),GetSQLValueString($ParampackageID2_WADApackages, "int"),GetSQLValueString($ParamSessionpackageID_WADApackages, "int"));
$WADApackages = mysql_query($query_WADApackages, $connPackages) or die(mysql_error());
$row_WADApackages = mysql_fetch_assoc($WADApackages);
$totalRows_WADApackages = mysql_num_rows($WADApackages);
$colname_educationalDestinations = "1";
if (isset($_GET['PackageID'])) {
$colname_educationalDestinations = (get_magic_quotes_gpc()) ? packageID : addslashes(packageID);
mysql_select_db($database_connPackages, $connPackages);
$query_educationalDestinations = sprintf("SELECT * FROM destinations INNER JOIN (packages INNER JOIN packagedestinations ON packages.packageID = packagedestinations.packageID) ON destinations.destinationID = packagedestinations.destinationID WHERE packages.packageID = %s ORDER BY destination ASC", GetSQLValueString($colname_educationalDestinations, "int"));
$educationalDestinations = mysql_query($query_educationalDestinations, $connPackages) or die(mysql_error());
$row_educationalDestinations = mysql_fetch_assoc($educationalDestinations);
$totalRows_educationalDestinations = mysql_num_rows($educationalDestinations);
?>
And where I'm trying to display the destinations themselves, I have :
<table>
<tr>
<td>Destinations :</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_educationalDestinations['destination']; ?></td>
</tr>
<?php } while ($row_educationalDestinations = mysql_fetch_assoc($educationalDestinations)); ?>
</table>
If anyone could have a quick look and help me out that would be much appreciated - not sure if its my SQL at the top, or the PHP in the page, but either way it would be good to get it working.
Thanks.First off, you need to get the database tables so that there is a relationship between them.
In fact, if there is a one to one relationship, then it may be better to store all of your information in one table such as
table_packages
packageID
package
packageDetails
destination
destinationDetails
etc
If there is a one to many relationship, then the following would be true
packages
packageID
package
packageDetails
etc
destinations
destinationID
packageID
destination
destinationDetails
etc
The above assumes that there are many destinations to one package with the relationship coloured orange.
Once you have the above correct you can apply your query as follows
SELECT *
FROM packages
INNER JOIN destinations
ON packages.packageID = destinations.packageID
WHERE packages.packageID = %s
ORDER BY destination ASC
The above query will show all packages with relevant destinations -
Please help with an embedded query (INSERT RETURNING BULK COLLECT INTO)
I am trying to write a query inside the C# code where I would insert values into a table in bulk using bind variables. But I also I would like to receive a bulk collection of generated sequence number IDs for the REQUEST_ID. I am trying to use RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs clause where :REQUEST_IDs is another bind variable
Here is a full query that use in the C# code
string sql = "INSERT INTO REQUESTS_TBL(REQUEST_ID, CID, PROVIDER_ID, PROVIDER_NAME, REQUEST_TYPE_ID, REQUEST_METHOD_ID, " +
"SERVICE_START_DT, SERVICE_END_DT, SERVICE_LOCATION_CITY, SERVICE_LOCATION_STATE, " +
"BENEFICIARY_FIRST_NAME, BENEFICIARY_LAST_NAME, BENEFICIARY_DOB, HICNUM, CCN, " +
"CLAIM_RECEIPT_DT, ADMISSION_DT, BILL_TYPE, LANGUAGE_ID, CONTRACTOR_ID, PRIORITY_ID, " +
"UNIVERSE_DT, REQUEST_DT, BENEFICIARY_M_INITIAL, ATTENDING_PROVIDER_NUMBER, " +
"BILLING_NPI, BENE_ZIP_CODE, DRG, FINAL_ALLOWED_AMT, STUDY_ID, REFERRING_NPI) " +
"VALUES " +
"(SQ_CDCDATA.NEXTVAL, :CIDs, :PROVIDER_IDs, :PROVIDER_NAMEs, :REQUEST_TYPE_IDs, :REQUEST_METHOD_IDs, " +
":SERVICE_START_DTs, :SERVICE_END_DTs, :SERVICE_LOCATION_CITYs, :SERVICE_LOCATION_STATEs, " +
":BENEFICIARY_FIRST_NAMEs, :BENEFICIARY_LAST_NAMEs, :BENEFICIARY_DOBs, :HICNUMs, :CCNs, " +
":CLAIM_RECEIPT_DTs, :ADMISSION_DTs, :BILL_TYPEs, :LANGUAGE_IDs, :CONTRACTOR_IDs, :PRIORITY_IDs, " +
":UNIVERSE_DTs, :REQUEST_DTs, :BENEFICIARY_M_INITIALs, :ATTENDING_PROVIDER_NUMBERs, " +
":BILLING_NPIs, :BENE_ZIP_CODEs, :DRGs, :FINAL_ALLOWED_AMTs, :STUDY_IDs, :REFERRING_NPIs) " +
" RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs";
int[] REQUEST_IDs = new int[range];
cmd.Parameters.Add(":REQUEST_IDs", OracleDbType.Int32, REQUEST_IDs, System.Data.ParameterDirection.Output);
However, when I run this query, it gives me a strange error ORA-00925: missing INTO keyword. I am not sure what that error means since I am not missing any INTOs
Please help me resolve this error or I would appreciate a different solution
Thank youIt seems you are not doing a bulk insert but rather an array bind.
(Which you will also find that it is problematic to do an INSERT with a bulk collect returning clause (while this works just fine for update/deletes) :
http://www.oracle-developer.net/display.php?id=413)
But you are using array bind, so you simply just need to use a
... Returning REQUEST_ID INTO :REQUEST_IDand that'll return you a Rquest_ID[]
see below for a working example (I used a procedure but the result is the same)
//Create Table Zzztab(Deptno Number, Deptname Varchar2(50) , Loc Varchar2(50) , State Varchar2(2) , Idno Number(10)) ;
//create sequence zzzseq ;
//CREATE OR REPLACE PROCEDURE ZZZ( P_DEPTNO IN ZZZTAB.DEPTNO%TYPE,
// P_DEPTNAME IN ZZZTAB.DEPTNAME%TYPE,
// P_LOC IN ZZZTAB.LOC%TYPE,
// P_State In Zzztab.State%Type ,
// p_idno out zzztab.idno%type
// IS
//Begin
// Insert Into Zzztab (Deptno, Deptname, Loc, State , Idno)
// Values (P_Deptno, P_Deptname, P_Loc, P_State, Zzzseq.Nextval)
// returning idno into p_idno;
//END ZZZ;
//Drop Procedure Zzz ;
//Drop Sequence Zzzseq ;
//drop Table Zzztab;
class ArrayBind
static void Main(string[] args)
// Connect
string connectStr = GetConnectionString();
// Setup the Tables for sample
Setup(connectStr);
// Initialize array of data
int[] myArrayDeptNo = new int[3]{1, 2, 3};
String[] myArrayDeptName = {"Dev", "QA", "Facility"};
String[] myArrayDeptLoc = {"New York", "Chicago", "Texas"};
String[] state = {"NY","IL","TX"} ;
OracleConnection connection = new OracleConnection(connectStr);
OracleCommand command = new OracleCommand (
"zzz", connection);
command.CommandType = CommandType.StoredProcedure;
// Set the Array Size to 3. This applied to all the parameter in
// associated with this command
command.ArrayBindCount = 3;
command.BindByName = true;
// deptno parameter
OracleParameter deptNoParam = new OracleParameter("p_deptno",OracleDbType.Int32);
deptNoParam.Direction = ParameterDirection.Input;
deptNoParam.Value = myArrayDeptNo;
command.Parameters.Add(deptNoParam);
// deptname parameter
OracleParameter deptNameParam = new OracleParameter("p_deptname", OracleDbType.Varchar2);
deptNameParam.Direction = ParameterDirection.Input;
deptNameParam.Value = myArrayDeptName;
command.Parameters.Add(deptNameParam);
// loc parameter
OracleParameter deptLocParam = new OracleParameter("p_loc", OracleDbType.Varchar2);
deptLocParam.Direction = ParameterDirection.Input;
deptLocParam.Value = myArrayDeptLoc;
command.Parameters.Add(deptLocParam);
//P_STATE -- -ARRAY
OracleParameter stateParam = new OracleParameter("P_STATE", OracleDbType.Varchar2);
stateParam.Direction = ParameterDirection.Input;
stateParam.Value = state;
command.Parameters.Add(stateParam);
//idParam-- ARRAY
OracleParameter idParam = new OracleParameter("p_idno", OracleDbType.Int64 );
idParam.Direction = ParameterDirection.Output ;
idParam.OracleDbTypeEx = OracleDbType.Int64;
command.Parameters.Add(idParam);
try
connection.Open();
command.ExecuteNonQuery ();
Console.WriteLine("{0} Rows Inserted", command.ArrayBindCount);
//now cycle through the output param array
foreach (Int64 i in (Int64[])idParam.Value)
Console.WriteLine(i);
catch (Exception e)
Console.WriteLine("Execution Failed:" + e.Message);
finally
// connection, command used server side resource, dispose them
// asap to conserve resource
connection.Close();
command.Dispose();
connection.Dispose();
Console.WriteLine("Press Enter to finish");
Console.ReadKey();
} -
Need help with LikeFilter for querying the keyset instead of value
Hi,
I'm looking for help with the LikeFilter.
I need to query the cache to get all entries with key starting with a particular string.
I could see samples using LikeFilter for querying the values in the cache but not the keyset.
Can someone help?
E.g:
Cache Entries:
abc123 - value1
abc234 - value2
bcd123 - value3
I want to get all entries with key starting with 'abc'.
thanks,
rama.NJ, thanks for the quick reply.
I tried something similar (as below) but this code gives me 'java.lang.NoClassDefFoundError: com/tangosol/util/ValueExtractor'.
KeyExtractor extractor = new KeyExtractor("getKey");
Filter filter = new LikeFilter(extractor, id+":%",'-',false);
-rama.
Edited by: 911950 on Feb 2, 2012 1:18 PM -
Hi,
I've got a server audit log in PowerPivot (114,000 rows) which I provide some basic reporting from (PowerPivot is not my specialist subject so go easy). What I now need to perform a Distinct filter, but can't get the logic right. Basically the log
as two bits of information, 1) is the source of the job and 2) if it was a success or failure. What I need to do is to find all of the Source items that have never completed sucessfully. Any ideas on what formula is best to use, or
do I need to split in to multiple sheets and create a table relationship?
Source,Status
======,======
Source1,Fail
Source1,Fail
Source1,Success
Source2,Fail
Source3,Fail
Source3,Success
So in the above example, I would only expect the filter to show me Source2
Thanks
AlexHi Alex,
using Power Query instead, it would work like this:
Once you've pushed your table to PQ, add a column "helper" with value=1.
Then pivot on "Status", taking "helper"-column into "values column"
(hope translation is understandable, as I'm using localized Version & translation via "Quick info" isn't working in the PQ menu)
Then filter on column "Success" = blank.
Imke -
I have the following table
EX_ID
EX_NAME
EX_SURNAME
EX_FLAG
1
TOM
JONES
Y
1
JIM
SLIM
N
1
BO
SELECTA
Y
2
AIRES
BEARS
N
2
JIM
DAVIES
Y
3
PAUL
BALL
N
3
YOU
KNOW
N
I need to create a query that only displays one of the ex_id’s, it doesn’t matter which one. When the query has been run it will look like below:
EX_ID
EX_NAME
EX_SURNAME
EX_FLAG
1
TOM
JONES
Y
2
AIRES
BEARS
N
3
YOU
KNOW
N
Can anyone help with this query?SELECT * FROM
SELECT *,ROW_NUMBER () OVER (PARTITION BY ex_id ORDER BY (SELECT 0))
FROM tbl
) AS Der WHERE rn=1
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Hi all i have this query:
SELECT VTA.CO_VENDEDOR
,VTA.NB_VENDEDOR
,VTA.CO_CLASE_CLIENTE
,VTA.DE_CLASE_CLIENTE
,VTA.CO_CLIENTE
,VTA.NB_CLIENTE
,VTA.MN_VENDIDO
,NVL(DEV.MN_DEVUELTO,0) MN_DEVUELTO
,VTA.MN_VENDIDO - NVL(DEV.MN_DEVUELTO,0) MN_NETO_VENDIDO
,NVL(COB.MN_COBRADO,0) MN_COBRADO
,NVL(COB.MN_DESCUENTO,0) MN_DESCUENTO
,NVL(COB.MN_COBRADO,0) + NVL(COB.MN_DESCUENTO,0) MN_COBRADO_MAS_DESCUENTO
FROM (SELECT FCL.CTV_CO_CLASE_ORGANIZACION CO_CLASE_CLIENTE
,FCL.CTV_DE_CLASE_ORGANIZACION DE_CLASE_CLIENTE
,FCL.CO_ORGANIZACION CO_CLIENTE
,FCL.ORG_NB_CLIENTE NB_CLIENTE
,FCL.PER_CO_IDENTIFICACION_VENDEDOR CO_VENDEDOR
,FCL.PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
FCL.PER_NB_PRIMER_APELLIDO_VEND NB_VENDEDOR
,SUM((CA_PRODUCTO * (PR_PRODUCTO - NVL(PR_DESCUENTO_PRODUCTO,0))) * (1 - NVL(PC_DESCUENTO,0))) MN_VENDIDO
FROM S04_FACTURA_CLIENTE_TOTAL_R FCL
,S04_FACTURA_CLIENTE_PRD_TOT FPR
,(SELECT FCP.FAC_ID_FACTURA
,SUM(DDC.MN_DEBITO_CREDITO) /
SUM(FCP.CA_PRODUCTO * (FCP.PR_PRODUCTO - NVL(FCP.PR_DESCUENTO_PRODUCTO,0))) PC_DESCUENTO
FROM S04_DOCUMENTO_DEBITO_CREDITO_R DDC
,S04_FACTURA_CLIENTE_PRD_TOT FCP
WHERE DDC.ID_DOCUMENTO_REFERENCIA = FCP.FAC_ID_FACTURA
AND DDC.TDC_IN_DEBITO_CREDITO = 'C'
GROUP BY FCP.FAC_ID_FACTURA) DCT
WHERE FCL.ID_REGISTRO = FPR.FAC_ID_FACTURA
AND DCT.FAC_ID_FACTURA (+) = FPR.FAC_ID_FACTURA
AND FCL.FE_EMISION BETWEEN to_date('01112009','ddmmyyyy') AND to_date('29112009','ddmmyyyy')
AND FCL.ORG_ID_CLIENTE = NVL(NULL,FCL.ORG_ID_CLIENTE)
AND FCL.PER_ID_VENDEDOR = NVL(7647771,FCL.PER_ID_VENDEDOR)
AND FCL.CTV_CO_ESTADO_DOCUMENTO = 'EM'
AND FCL.UBG_ID_UBICACION_CLIENTE in (SELECT ID_REGISTRO
FROM S00_UBICACION_GEOGRAFICA
START WITH ID_REGISTRO = nvl(NULL, FCL.UBG_ID_UBICACION_CLIENTE)
CONNECT BY PRIOR ID_REGISTRO = UBG_ID_UBICACION_PADRE)
GROUP BY FCL.CTV_CO_CLASE_ORGANIZACION
,FCL.CTV_DE_CLASE_ORGANIZACION
,FCL.CO_ORGANIZACION
,FCL.ORG_NB_CLIENTE
,PER_CO_IDENTIFICACION_VENDEDOR
,PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
PER_NB_PRIMER_APELLIDO_VEND) VTA
,(SELECT NDC .CTV_CO_CLASE_ORGANIZACION CO_CLASE_CLIENTE
,NDC.CTV_DE_CLASE_ORGANIZACION DE_CLASE_CLIENTE
,NDC.CO_CLIENTE
,NDC.ORG_NB_CLIENTE NB_CLIENTE
,FCL.PER_CO_IDENTIFICACION_VENDEDOR CO_VENDEDOR
,FCL.PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
FCL.PER_NB_PRIMER_APELLIDO_VEND NB_VENDEDOR
,SUM(CA_PRODUCTO * (PR_PRODUCTO - NVL(PR_DESCUENTO_PRODUCTO,0))) MN_DEVUELTO
FROM S06_NOTA_DEBITO_CREDITO_TOT_R NDC
,S06_DETALLE_NOTA_DEB_CRED_TOT DND
,S04_FACTURA_CLIENTE_TOTAL_R FCL
WHERE NDC.ID_REGISTRO = DND.NDC_ID_NOTA_DEBITO_CREDITO
AND NDC.CTV_CO_TIPO_DOCUMENTO = SK00_BUSCAR.F_VCT('CO_TIPO_DOCUMENTO_NOTA_CREDITO_FISCAL')
AND NDC.CTV_CO_ESTADO_DOCUMENTO = SK00_BUSCAR.F_VCT('CO_ESTADO_DOCUMENTO_EMITIDO')
AND NDC.FE_EMISION BETWEEN to_date('01112009','ddmmyyyy') AND to_date('29112009','ddmmyyyy')
AND (NDC.CTV_CO_MOTIVO_NOTA = SK00_BUSCAR.F_VCT('CO_MOTIVO_NOE_DEVOLUCION')
OR NDC.CTV_CO_MOTIVO_NOTA = SK00_BUSCAR.F_VCT('CO_MOTIVO_AJUSTE_PRECIO_NCD'))
AND NDC.ORG_ID_CLIENTE = NVL(NULL,NDC.ORG_ID_CLIENTE)
AND FCL.ID_REGISTRO = NDC.FAC_ID_FACTURA
AND FCL.CTV_CO_ESTADO_DOCUMENTO = 'EM'
AND FCL.UBG_ID_UBICACION_CLIENTE in (SELECT ID_REGISTRO
FROM S00_UBICACION_GEOGRAFICA
START WITH ID_REGISTRO = nvl(NULL, FCL.UBG_ID_UBICACION_CLIENTE)
CONNECT BY PRIOR ID_REGISTRO = UBG_ID_UBICACION_PADRE)
GROUP BY NDC.CTV_CO_CLASE_ORGANIZACION
,NDC.CTV_DE_CLASE_ORGANIZACION
,NDC.CO_CLIENTE
,NDC.ORG_NB_CLIENTE
,FCL.PER_CO_IDENTIFICACION_VENDEDOR
,FCL.PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
FCL.PER_NB_PRIMER_APELLIDO_VEND) DEV
,(SELECT RCD .CTV_CO_CLASE_ORGANIZACION CO_CLASE_CLIENTE
,RCD.CTV_DE_CLASE_ORGANIZACION DE_CLASE_CLIENTE
,RCD.CO_ORGANIZACION CO_CLIENTE
,RCD.ORG_NB_DISTRIBUIDOR NB_CLIENTE
,FCL.PER_CO_IDENTIFICACION_VENDEDOR CO_VENDEDOR
,FCL.PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
FCL.PER_NB_PRIMER_APELLIDO_VEND NB_VENDEDOR
,SUM(RCD.MN_DESCUENTO) MN_DESCUENTO
,SUM(DECODE(SIGN(RCO.MN_COBRADO_ANTES - IVA.MN_IVA)
,-1
,RCD.MN_ABONO - ABS(RCO.MN_COBRADO_ANTES - IVA.MN_IVA)
,RCD.MN_ABONO)) MN_COBRADO
FROM S06_RECIBO_COBRO_DOC_TOTAL_R RCD
,S04_FACTURA_CLIENTE_TOTAL_R FCL
,(SELECT ID_DOCUMENTO_REFERENCIA FAC_ID_FACTURA
,NVL(SUM(MN_DEBITO_CREDITO),0) MN_IVA
FROM S04_DOCUMENTO_DEBITO_CREDITO_R
WHERE TDC_CO_TIPO_DEBITO_CREDITO = SK00_BUSCAR.F_VCT('CO_TIPO_DEBITO_IVA')
GROUP BY ID_DOCUMENTO_REFERENCIA) IVA
,(SELECT ID_REFERENCIA FAC_ID_FACTURA
,NVL(SUM(MN_ABONO),0) MN_COBRADO_ANTES
FROM S06_RECIBO_COBRO_DOC_TOTAL_R
WHERE FE_EMISION < to_date('01112009','ddmmyyyy')
GROUP BY ID_REFERENCIA) RCO
WHERE RCD.CTV_CO_ESTADO_DOCUMENTO = SK00_BUSCAR.F_VCT('CO_ESTADO_DOCUMENTO_EMITIDO')
AND RCD.FE_EMISION BETWEEN to_date('01112009','ddmmyyyy') AND to_date('29112009','ddmmyyyy')
AND RCD.ORG_ID_ORGANIZACION = NVL(NULL,RCD.ORG_ID_ORGANIZACION)
AND FCL.CTV_CO_ESTADO_DOCUMENTO = 'EM'
AND FCL.ID_REGISTRO = RCD.ID_REFERENCIA
AND FCL.UBG_ID_UBICACION_CLIENTE in (SELECT ID_REGISTRO
FROM S00_UBICACION_GEOGRAFICA
START WITH ID_REGISTRO = nvl(NULL, FCL.UBG_ID_UBICACION_CLIENTE)
CONNECT BY PRIOR ID_REGISTRO = UBG_ID_UBICACION_PADRE)
AND IVA.FAC_ID_FACTURA (+) = FCL.ID_REGISTRO
AND RCO.FAC_ID_FACTURA (+) = FCL.ID_REGISTRO
GROUP BY RCD.CTV_CO_CLASE_ORGANIZACION
,RCD.CTV_DE_CLASE_ORGANIZACION
,RCD.CO_ORGANIZACION
,RCD.ORG_NB_DISTRIBUIDOR
,FCL.PER_CO_IDENTIFICACION_VENDEDOR
,FCL.PER_NB_PRIMER_NOMBRE_VENDEDOR||' '||
FCL.PER_NB_PRIMER_APELLIDO_VEND) COB
WHERE VTA.CO_CLIENTE = DEV.CO_CLIENTE (+)
AND VTA.CO_VENDEDOR = DEV.CO_VENDEDOR (+)
AND VTA.CO_CLIENTE = COB.CO_CLIENTE (+)
AND VTA.CO_VENDEDOR = COB.CO_VENDEDOR (+)
ORDER BY VTA.NB_VENDEDOR
,VTA.CO_CLIENTE
Is there a way i can influence the join method on this query ...?
It's an XE DB.
Regards, Luis ...!THIS IS THE PLAN:
SQL> /
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=79006 Card=1 Bytes
=253)
1 0 SORT (ORDER BY) (Cost=79006 Card=1 Bytes=253)
2 1 HASH JOIN (OUTER) (Cost=79005 Card=1 Bytes=253)
3 2 HASH JOIN (OUTER) (Cost=78538 Card=1 Bytes=211)
4 3 VIEW (Cost=78478 Card=1 Bytes=182)
5 4 HASH (GROUP BY) (Cost=78478 Card=1 Bytes=232)
6 5 FILTER
7 6 HASH JOIN (OUTER) (Cost=78469 Card=1 Bytes=232
8 7 TABLE ACCESS (BY INDEX ROWID) OF 'T04_FACTUR
A_PRODUCTO' (TABLE) (Cost=2 Card=1 Bytes=46)
9 8 NESTED LOOPS (Cost=25 Card=1 Bytes=213)
10 9 VIEW OF 'V04_FACTURA_CLIENTE_TOTAL_R' (V
IEW) (Cost=23 Card=1 Bytes=167)
11 10 NESTED LOOPS (Cost=23 Card=1 Bytes=284
12 11 NESTED LOOPS (OUTER) (Cost=23 Card=1
Bytes=278)
13 12 HASH JOIN (SEMI) (Cost=23 Card=1 B
ytes=272)
14 13 NESTED LOOPS (Cost=17 Card=1 Byt
es=259)
15 14 NESTED LOOPS (Cost=16 Card=1 B
ytes=218)
16 15 NESTED LOOPS (OUTER) (Cost=1
6 Card=1 Bytes=212)
17 16 NESTED LOOPS (Cost=15 Card
=1 Bytes=179)
18 17 NESTED LOOPS (Cost=15 Ca
rd=1 Bytes=173)
19 18 NESTED LOOPS (OUTER) (
Cost=14 Card=1 Bytes=162)
20 19 NESTED LOOPS (OUTER)
(Cost=14 Card=1 Bytes=156)
21 20 NESTED LOOPS (OUTE
R) (Cost=14 Card=1 Bytes=150)
22 21 NESTED LOOPS (OU
TER) (Cost=14 Card=1 Bytes=144)
23 22 NESTED LOOPS (
Cost=14 Card=1 Bytes=105)
24 23 SORT (UNIQUE
) (Cost=2 Card=1 Bytes=13)
25 24 TABLE ACCE
SS (FULL) OF 'T00_GRUPO_DATO_USUARIO_ACTIVO' (TABLE (TEMP))
(Cost=2 Card=1 Bytes=13)
26 23 TABLE ACCESS
(BY INDEX ROWID) OF 'T04_FACTURA' (TABLE) (Cost=11 Card=1 B
ytes=92)
27 26 INDEX (RAN
GE SCAN) OF 'I04_FAC_FE_EMISION' (INDEX) (Cost=10 Card=2)
28 22 TABLE ACCESS (
BY INDEX ROWID) OF 'T03_EMPRESA_SUCURSAL' (TABLE) (Cost=0 Ca
rd=1 Bytes=39)
29 28 INDEX (RANGE
SCAN) OF 'I03_EMS_EMP' (INDEX) (Cost=0 Card=1)
30 21 INDEX (UNIQUE SC
AN) OF 'PK_PRY' (INDEX (UNIQUE)) (Cost=0 Card=1 Bytes=6)
31 20 INDEX (UNIQUE SCAN
) OF 'PK_CAJ' (INDEX (UNIQUE)) (Cost=0 Card=1 Bytes=6)
32 19 INDEX (UNIQUE SCAN)
OF 'PK_PEC' (INDEX (UNIQUE)) (Cost=0 Card=1 Bytes=6)
33 18 TABLE ACCESS (BY INDEX
ROWID) OF 'T00_CONTENIDO_TABLA_VIRTUAL' (TABLE) (Cost=1 Car
d=1 Bytes=11)
34 33 INDEX (UNIQUE SCAN)
OF 'PK_CTV' (INDEX (UNIQUE)) (Cost=0 Card=1)
SORRY EXPLAIN OUTPUT TRUNCATED DUE TO SPACE RESTRICION .....
Any help would be greatly appreciated.
I believe there must be a way to influence on the tha costly HASH JOIN operation
SQL> SPOOL OFF -
I have two tables, one is sierra_price, which just has a part_number and a sierra_list
I have another table called products which is already populated with the parts from sierra_price, just no prices. It also has other products in it that are not included in sierra_price
What I need to do is update products with the base_price where products.sku is the same as sierra_price.part_number
I'm using db 10.2
I'm having trouble with this query...
UPDATE products
SET base_price = (select sierra_list from sierra_price where products.sku = sierra_price.part_number)
WHERE products.mfg_account_id = 4
I get the error:
ORA-01427: single-row subquery returns more than one row
Edited by: user10785816 on Jan 16, 2009 9:18 AMI got it to run with the query:
Update
(Select base_price bp, sierra_list sp from products p, sierra_price s where p.sku = s.part_number and p.mfg_account_id = 4)
SET bp = sp
I also had to set the primary key in sierra_price to the part_number to get it to work.
I'm quite new to SQL, but cheers for trying to help me!
Maybe you are looking for
-
How do I get my music to sync with iTunes?
I couldn't find this answer, Basically, I added 2xSSD's in my Windows PC and reinstalled iTunes. I had certain songs on my ipod touch (about 900) and I have about 3000 in my iTunes that are all checked now after the reinstall of iTunes. I never creat
-
Deleting an order line item with B1WS?
Hi, I am building an application which uses B1WS as it's interface to DISERVER. There is a situation I am confused about and am hoping the folks here can shed light on. I have an order object, and I would like to delete a line item from it. How can
-
How to read a time stamp from the db without ".0" at the end
Hi All, I have code that is saving the results of a query in a result set. When ever i read a time stamp from the db (mysql 4) it always adds ".0" to the end of it. I tried using the getTimeStamp, getDate, getString methods for result sets and was no
-
Order prints while in view mode?
Is there a way to order prints while in the view mode while the picture is nice and big, rather than having to select all pictures from an event when they are much smaller?
-
Mac Preview made view able on PC?
Is there an easy way to make the non viewable information typed into a form viewable and saveable on my PC using adobe reader XI and windows 7? thanks Liam