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 you
It 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();
}
Similar Messages
-
Please help with the 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
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
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 youYou cannot use (and do not want to in this case) the BULK COLLECT.
create table for_testing
the_id number not null primary key,
some_data number
declare
l_return_value for_testing.the_id%type;
begin
4
insert into for_testing
the_id,
some_data
values
1,
5
returning the_id into l_return_value;
dbms_output.put_line('the return values is ' || l_return_value);
end;
20 /
the return values is 1
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.02
TUBBY_TUBBZ?Is a simple example. In the future, please use the tags to preserve formatting on your code like i have so it remains readable . -
How to tune a query which contains "Bulk Collect Into" clause
I want to tune the below query:
SELECT customer_master_num,
product_nam
BULK COLLECT INTO t_cont09_rec
FROM TB_CMA009_SUPRA_RE_AGNT_CONT
WHERE re_agent_customer_master_num = p_63cust_master_num
AND customer_master_num = p_63board_master_num
AND cancellation_dt IS NULL
AND NVL (is_training_key_flg, 'N') = 'N';
This contains "Bulk Collect Into" clause.
TYPE cont09cur IS RECORD (
customer_master_num TB_CMA009_SUPRA_RE_AGNT_CONT.customer_master_num%TYPE,
product_nam TB_CMA009_SUPRA_RE_AGNT_CONT.product_nam%TYPE);
t_cont09_rec cont09_rec;
"t_cont09_rec" This is of Record Type
Please help me out how to tune this one.[url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]When your query takes too long ...
Also, don't get too distracted by the PL/SQL bulk collect into construction. If it takes time, then you have more than 99% chance that the time is spent in the SQL.
Regards,
Rob. -
PLEASE help with JavaScript parsing of WSDL return
Can someone help with parsing return WSDL data?
My return WSDL data is a concatenated string of alias names (firstname middlename lastname generation) delininated with an "@":
7433|ALIAS|John|W|Smith| @7432|ALIAS|Johnny| |Smith| @7430|ALIAS|JJ| |Smithers| @7431|ALIAS|JJ| |Smith| @7400|ALIAS|Jon| |Smith| @7416|ALIAS|John|Wilber|Smith|JR
I must have these names appear on my forms in a "lastname, firstname middlename generation" format. Can anyone provide expertise in this area if I provide the table.column reference?
alias.alternate_id = tmp[0];
alias.type = tmp[1];
alias.firstname = tmp[2];
alias.middlename = tmp[3];
alias.lastname = tmp[4];
alias.generation = tmp[5];Can someone help with parsing return WSDL data?
My return WSDL data is a concatenated string of alias names (firstname middlename lastname generation) delininated with an "@":
7433|ALIAS|John|W|Smith| @7432|ALIAS|Johnny| |Smith| @7430|ALIAS|JJ| |Smithers| @7431|ALIAS|JJ| |Smith| @7400|ALIAS|Jon| |Smith| @7416|ALIAS|John|Wilber|Smith|JR
I must have these names appear on my forms in a "lastname, firstname middlename generation" format. Can anyone provide expertise in this area if I provide the table.column reference?
alias.alternate_id = tmp[0];
alias.type = tmp[1];
alias.firstname = tmp[2];
alias.middlename = tmp[3];
alias.lastname = tmp[4];
alias.generation = tmp[5]; -
Please help with optimizing aggregate query
Good Morning.
I hope this will be a simple question, so I won't give a lot of detail about the db unless you ask for clarification.
I have four tables I need to join. CLC can have many CLS, and a CLS can have many CUSTD, and a CUSTD can have many CUSTDR.
I need to add up all the rows in CUSTD for one CLC, and subtract the sum of all the rows in CUSTDR for that CLC.
I first tried this
SELECT SUM(custd.amount_owed) - SUM(cusdr.amount_refunded)but that doesn't work because the amount owed is returned for every amount refunded.
Then I tried using a subquery
SELECT
TO_CHAR(owed.amount - NVL(SUM(custdr.refund_amount),0), 'L999G999G999G999D00')
INTO
g$_value
FROM
claim_settlements cls
,customer_debts custd
,customer_debt_recoveries custdr
SELECT
cls1.clc_id id
,SUM(custd1.owed_amount),0 amount
FROM
claim_settlements cls1
,customer_debts custd1
WHERE
custd1.st_table_short_name = 'CLS'
AND custd1.key_value = cls1.id
AND custd1.status != 'WO'
GROUP BY
cls1.clc_id
)owed
WHERE
custd.st_table_short_name = 'CLS'
AND custd.key_value = cls.id
AND custd.id = custdr.custd_id(+)
AND cls.clc_id = p$_key_value
AND owed.id = cls.clc_id
GROUP BY
owed.amount; I would like to know if this is possible using an analytic sum. This query works, but I read that analytics are better than sub queries, and I am still not sure on all the uses of analytic functions.
Thanks
Message was edited by:
dmill
Updated my question.
Message was edited by:
dmillThanks, Nic
That is the kind of query I was imaging, so I hope we can get it to work.
Here is information about the tables and the data:
DESC customer_debts
Name Null Type
ID NOT NULL NUMBER(28)
CUSTA_ID NOT NULL NUMBER(28)
GLTT_ID NOT NULL NUMBER(28)
ST_TABLE_SHORT_NAME NOT NULL VARCHAR2(10)
KEY_VALUE NOT NULL NUMBER(28)
OWED_AMOUNT NOT NULL NUMBER(11,2)
OWED_BY_CUSTOMER NOT NULL VARCHAR2(1)
STATUS NOT NULL VARCHAR2(2)
NOTES VARCHAR2(4000)
DATE_CREATED NOT NULL DATE
CREATED_BY NOT NULL VARCHAR2(30)
DATE_MODIFIED DATE
MODIFIED_BY VARCHAR2(30)
13 rows selected
DESC customer_debt_recoveries
Name Null Type
ID NOT NULL NUMBER(28)
CUSTD_ID NOT NULL NUMBER(28)
ST_TABLE_FOR_PAID_BY NOT NULL VARCHAR2(10)
KEY_VALUE_FOR_PAID_BY NOT NULL NUMBER(28)
REFUND_AMOUNT NOT NULL NUMBER(11,2)
REFUND_CHECK_NUMBER NUMBER(9)
DATA_SOURCE NOT NULL VARCHAR2(1)
NOTES VARCHAR2(4000)
DATE_CREATED NOT NULL DATE
CREATED_BY NOT NULL VARCHAR2(30)
DATE_MODIFIED DATE
MODIFIED_BY VARCHAR2(30)
12 rows selected
customer_debts custd
ID CSL_ID OWED_AMOUNT
1 4143802 20
2 4143802 10
3 4143802 10
5 4143796 10
6 4143806 10
7 999999999 20
8 999999999 10
9 999999999 10
11 4143802 100
9 rows selected
customer_debt_recoveries custdr
ID CUSTD_ID REFUND_AMOUNT
1 5 10
2 1 27
3 1 5
3 rows selected
claim_charges clc and claim_settlements cls
CLC_ID CLS_ID
537842 4143802
537842 999999999
538057 4143796
538209 4143806
4 rows selectedThe clc is the object that we want the information for. For example, clc 537842 should return the amount of 148, which is the sum of all the debts minus the sum of all the recoveries.
clc 4143796 would return 0
and 4143806 would return 10
When I run your query for clc 537842, which looks like this with joins
select distinct
clc.id clc_id
,sum(custd.owed_amount) over (partition by clc.id, cls.id, custd.id)
sum(custdr.refund_amount) over (partition by clc.id, cls.id, custd.id, custdr.id) amount_owed
from
claim_charges clc
,claim_settlements cls
,customer_debts custd
,customer_debt_recoveries custdr
where
cls.clc_id = clc.id
AND custd.key_value = cls.id
AND custd.st_table_short_name = 'CLS'
AND custd.id = custdr.custd_id (+)
AND custd.status != 'WO'
AND clc.id = 537842I get this result
CLC_ID AMOUNT_OWED
537842
537842 35
537842 13
3 rows selectedThanks again, and let me know if this is not enough info. -
Please help with processing a query
I have a text area were I input 6 numbers (ex. 123456,
25698,12564,8899664, etc) the first problem is I would like for the
numbers
to be displayed in a verical list (12345
12345
12345 etc)
The second problem is I am comparing the numbers in the list
with numbers that are in a Database. I do know that 1 set of the
numbers exists, when I run my query with all the numbers
being submitted I get no records found, however if I run the query
with
only the set of numbers that is in the database i get 1
record found for 12345,
here is my code
<cfquery name="TRI">
Select IDnumbers from Process where IDnumbers like
'%#DepID#%'
cfloop = "TRI" list="#DepID#"
cfoutput #Tri.Recordcount found #DepID#
DepID is the name given to the textarea were the numbers are
posted.
I know the syntax in not correct I'm just trying to get an
idea of what the problem is. and what direction should i be heading
inquote:
Originally posted by:
rere
I have a text area were I input 6 numbers (ex. 123456,
25698,12564,8899664, etc) the first problem is I would like for the
numbers
to be displayed in a verical list (12345
12345
12345 etc)
The second problem is I am comparing the numbers in the list
with numbers that are in a Database. I do know that 1 set of the
numbers exists, when I run my query with all the numbers
being submitted I get no records found, however if I run the query
with
only the set of numbers that is in the database i get 1
record found for 12345,
here is my code
<cfquery name="TRI">
Select IDnumbers from Process where IDnumbers like
'%#DepID#%'
cfloop = "TRI" list="#DepID#"
cfoutput #Tri.Recordcount found #DepID#
DepID is the name given to the textarea were the numbers are
posted.
I know the syntax in not correct I'm just trying to get an
idea of what the problem is. and what direction should i be heading
in
No offense, but you are doing something horribly wrong. Not
sure if it is storing lists of numbers in a single field or storing
numbers in char fields.
Fix your db and life will be much easier. -
Please help with this inventory query
I want 2 display
item_num(segment1), description(mtl_system_items), on_hand_quantity, reservations, availability
pleseeeeeeeeeeeeeeeeeeeee help meeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
i guess we need to join these three tables ??
mtl_system_items
mtl_onhand_quantities_detail
mtl_reservationsAny body thereeeeeeeeeeeeeeeee :(((((((((
-
Will someone from the UK please help with a security query?
Hello
I've been subscribing to a facility which provides cheap telephone calls, since around 2004. Details may be found here: http://www.call18866.co.uk
Last month my credit card was reissued for another three year period which, in turn, meant that previous financial commitments had to be renewed.
When I visit Call18866 to subscribe to my account I can, indeed, gain access to the secure areas, but I can see no 'https' nor a padlock when I use Safari as my browser!
I have also used Firefox, Chrome and SeaMonkey browsers to view the site - and they DO show 'https' and a padlock!
I'm wondering if the fault is with me or with the Call18866 wesite!
I should be most grateful if someone would use their Safari browser to check whether or not they can find a 'padlock' or an 'https' link at Call18866.
Thanks.
David B
PS I have questioned Call18866 about this. They have simply said that their website is secure!SQL> create table testme
2 as
3 select 'A' name, 1 val from dual union all
4 select 'A', 2 from dual union all
5 select 'A', 3 from dual union all
6 select 'B', 1 from dual union all
7 select 'B', 2 from dual union all
8 select 'B', 3 from dual union all
9 select 'C', 1 from dual union all
10 select 'C', 2 from dual
11 /
Tabel is aangemaakt.
SQL> select max(name) name
2 , max(val) keep (dense_rank last order by name) val
3 from testme
4 /
NAME VAL
C 2Regards,
Rob. -
Please help with creating a summary report from data collected in a fillable PDF form.
I'm sure this has been asked before so I apologize in advance - I'm new to this forum and I'm not quite sure of which section I should be in. If I may just describe a certain scenario of something I am trying to create - could you please point me in the right direction?
I'm looking to create a summary report/form to help me better organize my patients after each appointment. So data collected from other fillable forms I've created, will lead to the final page to print that will include selections from fillable text boxes or drop down lists, etc to basically summarize each encounter. It should go something like this:
FORM 1:
-pt chart #
-pg age
-purpose for visit
-date of visit
-diagnosis
-prognosis
-etc
SUMMARY page
On (-date of visit), patient (-pt chart #) arrived with complaint of (-purpose for visit)....
The diagnosis was determined to be (-diagnosis), treatment to be performed is suggested to be (-treatment) with a (-prognosis) prognosis. Treatment was (accepted or not) and completed on... etc. etc... you get the idea
Does anyone know how I can do this?
Thank you all for your time and advice!I have downloaded Castor and got some good tutorials, but.......
There is a problem, when I try to use the Marshaller to get an XML document the following error is reported:
java.lang.NoClassDefFoundError: org/apache/xml/serialize/XMLSerializer
I have scanned the Internet looking for a solution, some recommend including Xecers in the Classpath. I downloaded Xerces 2.7.1 and added it to as instructed but this did not work.
Hope you can help -
Returning (bulk collect) clause with execute immediate
db version 11.1.0.7
trying to do a returning bulk collect but it is not working:
-- my test table
create table t as
with f as (select rownum rn from dual connect by rownum <= 10)
select
rn,
lpad('x',10,'x') pad
from f;
-- works as expected
declare
type aat is table of t%rowtype;
aay aat;
begin
delete from t returning rn,pad bulk collect into aay;
rollback;
end;
-- but the table I really want to do has many columns so I want to dynamically build list of columns for the
-- returning clause. This way if the table changes the stored proc will not have to be modified
-- fails PLS-00429: unsupported feature with RETURNING clause
declare
type aat is table of t%rowtype;
aay aat;
s varchar2(4000);
begin
s := 'delete from t returning rn,pad into :1';
execute immediate s returning bulk collect into aay;
rollback;
end;
-- tried a few other things:
create or replace type t_obj as object (rn number,pad varchar2(10));
-- PLS-00497: cannot mix between single row and multi-row (BULK) in INTO list
declare
nt t_obj;
s varchar2(4000);
begin
s := 'delete from t returning t_obj(rn,pad) into :1';
execute immediate s returning bulk collect into nt;
rollback;
end;
-- works, but would require store proc changes if the table changes
declare
type t is table of number;
type v is table of varchar2(10);
vt v;
nt t;
s varchar2(4000);
begin
s := 'update t set rn = 10 returning rn,pad into :1,:2';
execute immediate s returning bulk collect into nt,vt;
rollback;
end;
/basically I want to dynamically build the list of columns with all_tab_cols and put the list into the returning clause
but seems like I will have to hard code the column lists. This means whenever the table changes I will have to
modify the store proc .. Any way around this?
ThanksAnd with object type you were almost there. You forgot to create table of objects type:
SQL> create or replace type t_obj as object (rn number,pad varchar2(10));
2 /
Type created.
SQL> declare
2 type aat is table of nt;
3 aay aat;
4 s varchar2(4000);
5 begin
6 s := 'delete from t returning
SQL> declare
2 type aat is table of t_obj;
3 aay aat;
4 s varchar2(4000);
5 begin
6 s := 'delete from t returning t_obj(rn,pad) into :1';
7 execute immediate s returning bulk collect into aay;
8 rollback;
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> SY. -
Hi,
I have another query running slow when executed from cognos. It is also not returning any output continues to execute,
with "Union15" as (
select distinct CASE WHEN(substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 1, 4) IS NULL) OR (case substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end IS NULL) THEN NULL ELSE (substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 1, 4)||case substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end ) END "QUARTER", "EES_ENERGY_MASTER"."PAT_KEY" "Cases_Using_Energy", 0 "Total_Cases"
from "MDM_DBA"."EES_ENERGY_MASTER" "EES_ENERGY_MASTER", "MDM_DBA"."EES_CONS_PROV" "EES_CONS_PROV"
where "EES_ENERGY_MASTER"."DISC_MON">=2006101 and "EES_ENERGY_MASTER"."PDCT_CAT"='Energy' and substr("EES_ENERGY_MASTER"."ICD_CODE", 1, 2)='68-gyn' and "EES_ENERGY_MASTER"."MANUFACTURER"='EES' and "EES_CONS_PROV"."CONS_06_09_YN" in ('N', 'Y') and "EES_ENERGY_MASTER"."PROV_ID"="EES_CONS_PROV"."PROV_ID" union
select CASE WHEN(substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4) IS NULL) OR (case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end IS NULL) THEN NULL ELSE (substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4)||case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end ) END "QUARTER", 0 "Cases_Using_Energy", count("MVW_EES_ICD_STATS"."CASES") "Total_Cases"
from "MDM_DBA"."MVW_EES_ICD_STATS" "MVW_EES_ICD_STATS", "MDM_DBA"."EES_CONS_PROV" "EES_CONS_PROV", "MDM_DBA"."EES_HOSP_CHG_PROV" "EES_HOSP_CHG_PROV"
where "MVW_EES_ICD_STATS"."DISC_QTR">=20061 and "MVW_EES_ICD_STATS"."ICD_GROUP"='68-gyn' and "EES_CONS_PROV"."CONS_06_09_YN" in ('N', 'Y') and "EES_HOSP_CHG_PROV"."PDCT_CAT"='Energy' and "EES_HOSP_CHG_PROV"."MANUFACTURER"='EES' and "MVW_EES_ICD_STATS"."PROV_ID"="EES_CONS_PROV"."PROV_ID" and "MVW_EES_ICD_STATS"."PROV_ID"="EES_HOSP_CHG_PROV"."PROV_ID"
group by CASE WHEN(substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4) IS NULL) OR (case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end IS NULL) THEN NULL ELSE (substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4)||case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end ) END)
select "T1"."C0" "levelkey", "T1"."C1" "Cases_Using_Energy", "T0"."C0" "Cases_Using_Energy1", "T1"."C2" "Total_Cases"
from (
select count(distinct "Union15"."Cases_Using_Energy") "C0"
from "Union15") "T0", (
select "Union15"."QUARTER" "C0", count(distinct "Union15"."Cases_Using_Energy") "C1", sum("Union15"."Total_Cases") "C2"
from "Union15"
group by "Union15"."QUARTER") "T1"The explain plan is as follows,
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
| 0 | SELECT STATEMENT | | 1 | 50 | | 22 |
| 2 | TEMP TABLE TRANSFORMATION | | | | | |
| 1 | RECURSIVE EXECUTION | SYS_LE_2_0 | | | | |
| 0 | INSERT STATEMENT | | 3053 | 128K| | 1372 |
| 1 | LOAD AS SELECT | | | | | |
| 2 | SORT UNIQUE | | 3053 | 128K| 376K| 1372 |
| 3 | UNION-ALL | | | | | |
|* 4 | HASH JOIN | | 3052 | 128K| | 185 |
|* 5 | TABLE ACCESS FULL | EES_CONS_PROV | 622 | 3732 | | 2 |
|* 6 | TABLE ACCESS BY INDEX ROWID | EES_ENERGY_MASTER | 3055 | 110K| | 182 |
|* 7 | INDEX RANGE SCAN | IDX_ENERGY_PDCT_CAT | 1978 | | | 2478 |
| 8 | SORT GROUP BY | | 1 | 40 | | 1160 |
|* 9 | TABLE ACCESS BY INDEX ROWID | EES_HOSP_CHG_PROV | 4 | 72 | | 1 |
| 10 | NESTED LOOPS | | 1 | 40 | | 1157 |
| 11 | NESTED LOOPS | | 1 | 22 | | 1156 |
|* 12 | TABLE ACCESS BY INDEX ROWID| MVW_EES_ICD_STATS | 1 | 16 | | 1155 |
|* 13 | INDEX RANGE SCAN | MVWICDSTATS_DISCQTR_IDX | 13M| | | 26068 |
|* 14 | TABLE ACCESS BY INDEX ROWID| EES_CONS_PROV | 1 | 6 | | 1 |
|* 15 | INDEX UNIQUE SCAN | EES_CONS_PROV_PK | 1 | | | |
|* 16 | INDEX RANGE SCAN | PROV_ID_IDX_2 | 65 | | | 1 |
| 3 | MERGE JOIN CARTESIAN | | 1 | 50 | | 22 |
| 4 | VIEW | | 1 | 13 | | 3 |
| 5 | SORT GROUP BY | | 1 | 13 | | |
| 6 | VIEW | | 3053 | 39689 | | 3 |
| 7 | TABLE ACCESS FULL | SYS_TEMP_0FD9D68B3_C112F95D | 3053 | 110K| | 3 |
| 8 | VIEW | | 1 | 37 | | 19 |
| 9 | SORT GROUP BY | | 1 | 37 | | 19 |
| 10 | VIEW | | 3053 | 110K| | 3 |
| 11 | TABLE ACCESS FULL | SYS_TEMP_0FD9D68B3_C112F95D | 3053 | 110K| | 3 |
Predicate Information (identified by operation id):
4 - access("EES_ENERGY_MASTER"."PROV_ID"="EES_CONS_PROV"."PROV_ID")
5 - filter("EES_CONS_PROV"."CONS_06_09_YN"='N' OR "EES_CONS_PROV"."CONS_06_09_YN"='Y')
6 - filter("EES_ENERGY_MASTER"."DISC_MON">=2006101 AND SUBSTR("EES_ENERGY_MASTER"."ICD_CODE",1,2)='68-gyn'
AND "EES_ENERGY_MASTER"."MANUFACTURER"='EES')
7 - access("EES_ENERGY_MASTER"."PDCT_CAT"='Energy')
9 - filter("EES_HOSP_CHG_PROV"."PDCT_CAT"='Energy' AND "EES_HOSP_CHG_PROV"."MANUFACTURER"='EES')
12 - filter("MVW_EES_ICD_STATS"."ICD_GROUP"='68-gyn')
13 - access("MVW_EES_ICD_STATS"."DISC_QTR">=20061 AND "MVW_EES_ICD_STATS"."DISC_QTR" IS NOT NULL)
14 - filter("EES_CONS_PROV"."CONS_06_09_YN"='N' OR "EES_CONS_PROV"."CONS_06_09_YN"='Y')
15 - access("MVW_EES_ICD_STATS"."PROV_ID"="EES_CONS_PROV"."PROV_ID")
16 - access("MVW_EES_ICD_STATS"."PROV_ID"="EES_HOSP_CHG_PROV"."PROV_ID")
Please help with some solution.OK: the third parameter of the SUBSTR function indicates the (maximum) length of the returnd string.
Therefore SUBSTR("EES_ENERGY_MASTER"."ICD_CODE",1,2) could possibly be '68' , but never '68-gyn'.
'68-gyn' is just 4 characters too long.
Urs -
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? -
Help with a flash html inserting into DW
Hello,
I have created a enquiry section in flash for one of my html DW pages for my site. When I publish the flash doc ti creates a html page (Contact.html). When I open the flash html page in DW or upload it to my server, everything works fine. I recieve an email at my prefered destination etc etc. But as its only a section of my contact page of my website i need to insert it into my site page (get_in_touch.html) soon as i try and take all the stuff from contact.html and insert it into a div in my get_in_touch.html it doesn't respond when the submit button is pressed..... Can someone please help!!!!!
DanThanks for all your help. I've managed to sort out the problem, still not
sure what it was.... My sites live now.
Just one question for you if you dont mind.
The page which has the flash on it (yes this one again!) Well if someone
goes to the page with out having flash player installed on their machine,
i'm looking for some script to detect that there computer doesn't have
Flash and redirect them to another html page I've created.
Would really appreciated any advice you may have.
many thanks,
Dan
pziecina
<[email protected]>
To
09/09/2009 16:40 Daniel Herrington
<[email protected]
m>
Please respond to cc
clearspace-571537347-50
[email protected] Subject
ums.adobe.com Help with a
flash html inserting into DW
Hi
Somewhere above your tag, you will have a line similar to this - Also in your tag the swf file -
These are the files that I said may be wrong or missing.
However if you just edit the flash generated page and include the items you
require in this, and maintain the same file position, you should have no
problems,
PZ -
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. -
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?
Maybe you are looking for
-
The data does not encrypt using Wallet!
Hi All, I've created a wallet to encrypt/decrypt the data, but when I change any column to be ecrypted by this command: alter table accounts modify (ssn encrypt); --accounts is the table containing ssn column to be ecrypted. and then inserting data o
-
my ipod shuffle is showing up when plugged into my computer. Also, isn't the orange light suppose to stay on until charged. Mine lights orange for a minute and then goes off and also it wont be recongnize by my computer .please help
-
How check double entries in Alv_grid OO considering the deleted rows
Hi, I've realized an ALV_Grid that show the contents of a custom table to allow the users to delete and insert data, checking that there are not duplicated keys. This is the problem: if a user delete a row and then insert it again (with the same key)
-
Link between 0RECORDMODE AND ROCANCEL
Hi, could you pls explaint the link between 0RECORDMODE and ROCANCEL I just dont understand why they are mapped in transferrules. and i dont have the field ROCANCEL field in my datasource. actually what scenario makes 0RECORDMODE and ROCANCEL go toge
-
/n/tmwflow/cmsconf
Hi, In Transaction '/n/tmwflow/cmsconf' i am only getting two tabs 1)System Change Option & 2)Critical Objects. I believe it should have someother tab like General Settings,Distribution Routes & Project structure. Why its missing here.I am on Solutio