Anything Wrong with this query?
I have been trying to create a report based on this query:
SELECT call_type.call_type_detail,
code_city.code_city_detail, area_code.area_code_detail,
call_reason.call_reason_detail, cform.cform_phone_number_body,
call_outcome.call_outcome_detail,
outcome_reason.outcome_reason_detail, cform.cform_date_time ,
cform.cform_comments
FROM call_type, code_city, area_code, call_reason, cform,
call_outcome, outcome_reason
I have verified all fields to make sure they match and when I
try to test it CFR crashes...any idea as to why this may be
happening? Thanks!
The funny thing is I WAS using inner join already, but didn't
know it was called that and didn't add it to the post since I have
quite a few variables as criteria and thought it would make it
difficult to understand. In the end it was stalling because of an
error in a table I had not properly specified.
This is what I had from the start!
SELECT call_type.call_type_detail,
code_city.code_city_detail, area_code.area_code_detail,
call_reason.call_reason_detail, cform.cform_phone_number_body,
call_outcome.call_outcome_detail,
outcome_reason.outcome_reason_detail, cform.cform_date_time ,
cform.cform_comments
FROM call_type, code_city, area_code, call_reason, cform,
call_outcome, outcome_reason
WHERE cform.cform_date_time BETWEEN
#CreateODBCDateTime(param.CustomFullStartDate)# AND
#CreateODBCDateTime(param.CustomFullEndDate)# AND
cform.cform_call_product=#param.GetCustomProduct# AND
cform.call_service= #param.GetCustomService# AND
cform.cform_call_reason=#param.GetCustomCallReason# AND
cform.cform_call_outcome=#param.GetCustomCallOutcome# AND
cform.cform_call_outcome_reason=#param.GetCustomReason# AND
call_type.call_type_id=cform.cform_call_type AND
call_city.call_city_id=cform.cform_call_city AND
area_code.area_code_id=cform.cform_area_code AND
call_reason.call_reason_id=cform.cform_call_reason AND
call_outcome.call_outcome_id=cform.cform_call_outcome AND
outcome_reason.outcome_reason_id=cform.cform_outcome_reason AND
cform.cform_date_time
Similar Messages
-
Do you see anything wrong with this GL mapping in a cube?
hi,
Can you verify if something is wring with this mapping:
In model 1:
0fi_gl_4 --> 0figl_O02 --> 0figl_C02
the standard cube shows the following key figures and I mapped them to the following fields from the datasource:
DMSOL(in datasource) to 0Debit_LC (in DSO) to 0Debit (in cube)
DMHAB(in datasource) to 0Credit_LC (in DSO) to 0Credit (in cube)
In model 2:
0fi_gl_6 --> 0figl_C01
the standard cube shows the following key figures and I mapped them to the following fields from the datasource:
UMSOL(in datasource) to 0Debit (in cube)
UMHAB(in datasource) to 0Credit (in cube)
1. Do you see anything wrong with this mapping? And what is the solution?
2. What is the problem with the mapping if both cubes sit under the same multiprovider, since 0debit and 0credit are from differnt souce fields?
thnxHi,
Thanks for the explanation.
on #1,
if my goal is to provide a sort of trial balance, credits and debits as two columns, will it be ok to assume that it should be Local Currency or could it be Document Currency, Local Currency 2 or Local Currency 3? If the latter, then how do I decide?
on #2,
i. why will there be difficulty creating a union between the two?
ii. will there also be an inconsistency if I created 2 separate multiproviders for each model, and create a jump query from the 0fi gl_6 model to 0fi gl_c4 model. If not, why not in this case?
iii. So, is there any advantage in placing a multiprovider on each of these models separately? i.e. instead of directly reporting off the cubes separately?
3. I am wondering why in the case of gl_6 (the totals) help.sap recomended to go directly from the datasource to the cube i.e. without DSO in between.
If without the DSO step is an advantage, what are the advantages?
And why then do we use DSOs in most model instead? I will appreciate any reasons you may think of..
Thnx.
Edited by: AmandaBaah on Jul 28, 2009 11:07 AM
Edited by: AmandaBaah on Jul 29, 2009 2:25 AM -
Please tell me anything wrong in this query please help me follwing query
SELECT o100161.ORG_STRUCTURE_VERSION_ID as E100351,AVG(o100163.PLANNED) as E100360_AVG,AVG(o100163.ACTUAL) as E100180_AVG,( SUM(fx102) )-( SUM(fx103) ) as C_1,( SUM(fx105) )-( SUM(fx106) ) as C_2,( SUM(fx108) )-( SUM(fx109) ) as C_3
FROM ( SELECT o100165.SEGMENT1 AS fx100, SUM(o100165.ACR) AS fx102, SUM(o100165.ADR) AS fx103, SUM(o100165.BDR) AS fx105, SUM(o100165.BCR) AS fx106, SUM(o100165.ECR) AS fx108, SUM(o100165.EDR) AS fx109 FROM ( SELECT
nvl(src.user_je_source_name, '**************') SOURCE,
nvl(cat.user_je_category_name, '**************') CATEGORY,
jeh.name NAME,
jel.code_combination_id CCID,
jeh.DEFAULT_EFFECTIVE_DATE,
jel.period_name PERIOD_NAME,
jel.effective_date EFFECTIVE_DATE,
jel.description DESCRIPTION,
seq.name SEQUENCE_NAME,
jeh.doc_sequence_value DOCUMENT_NUMBER,
jel.accounted_dr,
jel.accounted_cr,
decode(jeh.actual_flag,'B',jel.accounted_dr,'E',0,'A',0)bdr,
decode(jeh.actual_flag,'B',jel.accounted_Cr,'E',0,'A',0)bcr,
decode(jeh.actual_flag,'B',0,'E',jel.accounted_Dr,'A',0)EDr,
decode(jeh.actual_flag,'B',0,'E',jel.accounted_Cr,'A',0)ECr,
decode(jeh.actual_flag,'B',0,'E',0,'A',jel.accounted_Dr)ADr,
decode(jeh.actual_flag,'B',0,'E',0,'A',jel.accounted_Cr)ACr,
jel.JE_LINE_NUM,
cc.segment7 Project_COA_No,
cc.description Segment_description,
pa.segment1,
jeh.actual_flag,
PA.NAME PROJECT_NAME,
cc.segment1||'.'||cc.segment2||'.'||cc.segment3||'.'||cc.segment4||'.'||cc.segment5 seg_desc
FROM gl_je_lines jel,
gl_code_combinations cc,
gl_je_headers jeh,
-- gl_je_batches jeb,
gl_je_categories cat,
gl_je_sources src,
fnd_document_sequences seq,
pa_projects_all pa,
XXEPM_FINANCE_INTEGRATION XX
WHERE
((nvl(accounted_dr,0) != 0 OR nvl(accounted_cr,0) != 0) OR
(nvl(accounted_dr,0) = 0 AND nvl(accounted_cr,0) = 0 AND
stat_amount is not NULL))
AND jeh.je_header_id = jel.je_header_id
AND src.je_source_name = jeh.je_source
AND cat.je_category_name = jeh.je_category
AND seq.doc_sequence_id(+) = jeh.doc_sequence_id
AND jel.code_combination_id = cc.code_combination_id
AND XX.EPM_PA_NO=PA.SEGMENT1
AND XX.FINANCE_PA_COA_SEG=CC.SEGMENT7
ORDER BY jeh.name, jel.je_line_num
) o100165 GROUP BY o100165.SEGMENT1) ,
( select * from PER_ORG_STRUCTURE_ELEMENTS_V
) o100161,
( SELECT PPA.CARRYING_OUT_ORGANIZATION_ID Organization, PPA.PROJECT_ID as "Project ID",ppa.segment1 as "Project No" ,PPA.NAME as "Project Name",
nvl(trunc(((sysdate - PPA.SCHEDULED_START_DATE)/( PPA.scheduled_finish_date - PPA.SCHEDULED_START_DATE) *100 )),0) Planned,
nvl(TRUNC(AVG(PPC.COMPLETED_PERCENTAGE)),0) Actual
FROM PA_PROJECTS_ALL PPA , PA_PERCENT_COMPLETES PPC
WHERE PPA.CARRYING_OUT_ORGANIZATION_ID IN (SELECT A.ORGANIZATION_ID_CHILD
FROM PER_ORG_STRUCTURE_ELEMENTS_V A, PA_IMPLEMENTATIONS_ALL B
WHERE A.ORG_STRUCTURE_VERSION_ID= B.ORG_STRUCTURE_VERSION_ID)
AND PPA.TEMPLATE_FLAG='N'
AND PPC.PROJECT_ID(+) = PPA.PROJECT_ID
GROUP BY PPA.CARRYING_OUT_ORGANIZATION_ID,PPA.PROJECT_ID,ppa.segment1, PPA.NAME ,PPA.SCHEDULED_START_DATE,PPA.scheduled_finish_date
) o100163
WHERE ( (o100163."Project No" = fx100)
and (o100161.ORGANIZATION_ID_CHILD = o100163.ORGANIZATION))
GROUP BY o100161.ORG_STRUCTURE_VERSION_ID;
the second query is as follows
SELECT o100163."Project Name" as E100386,( SUM(o100165.ACR) )-( SUM(o100165.ADR) ) as C_1,( SUM(o100165.BDR) )-( SUM(o100165.BCR) ) as C_2,( SUM(o100165.ECR) )-( SUM(o100165.EDR) ) as C_3
FROM ( SELECT PPA.CARRYING_OUT_ORGANIZATION_ID Organization, PPA.PROJECT_ID as "Project ID",ppa.segment1 as "Project No" ,PPA.NAME as "Project Name",
nvl(trunc(((sysdate - PPA.SCHEDULED_START_DATE)/( PPA.scheduled_finish_date - PPA.SCHEDULED_START_DATE) *100 )),0) Planned,
nvl(TRUNC(AVG(PPC.COMPLETED_PERCENTAGE)),0) Actual
FROM PA_PROJECTS_ALL PPA , PA_PERCENT_COMPLETES PPC
WHERE PPA.CARRYING_OUT_ORGANIZATION_ID IN (SELECT A.ORGANIZATION_ID_CHILD
FROM PER_ORG_STRUCTURE_ELEMENTS_V A, PA_IMPLEMENTATIONS_ALL B
WHERE A.ORG_STRUCTURE_VERSION_ID= B.ORG_STRUCTURE_VERSION_ID)
AND PPA.TEMPLATE_FLAG='N'
AND PPC.PROJECT_ID(+) = PPA.PROJECT_ID
GROUP BY PPA.CARRYING_OUT_ORGANIZATION_ID,PPA.PROJECT_ID,ppa.segment1, PPA.NAME ,PPA.SCHEDULED_START_DATE,PPA.scheduled_finish_date
) o100163,
( SELECT
nvl(src.user_je_source_name, '**************') SOURCE,
nvl(cat.user_je_category_name, '**************') CATEGORY,
jeh.name NAME,
jel.code_combination_id CCID,
jeh.DEFAULT_EFFECTIVE_DATE,
jel.period_name PERIOD_NAME,
jel.effective_date EFFECTIVE_DATE,
jel.description DESCRIPTION,
seq.name SEQUENCE_NAME,
jeh.doc_sequence_value DOCUMENT_NUMBER,
jel.accounted_dr,
jel.accounted_cr,
decode(jeh.actual_flag,'B',jel.accounted_dr,'E',0,'A',0)bdr,
decode(jeh.actual_flag,'B',jel.accounted_Cr,'E',0,'A',0)bcr,
decode(jeh.actual_flag,'B',0,'E',jel.accounted_Dr,'A',0)EDr,
decode(jeh.actual_flag,'B',0,'E',jel.accounted_Cr,'A',0)ECr,
decode(jeh.actual_flag,'B',0,'E',0,'A',jel.accounted_Dr)ADr,
decode(jeh.actual_flag,'B',0,'E',0,'A',jel.accounted_Cr)ACr,
jel.JE_LINE_NUM,
cc.segment7 Project_COA_No,
cc.description Segment_description,
pa.segment1,
jeh.actual_flag,
PA.NAME PROJECT_NAME,
cc.segment1||'.'||cc.segment2||'.'||cc.segment3||'.'||cc.segment4||'.'||cc.segment5 seg_desc
FROM gl_je_lines jel,
gl_code_combinations cc,
gl_je_headers jeh,
-- gl_je_batches jeb,
gl_je_categories cat,
gl_je_sources src,
fnd_document_sequences seq,
pa_projects_all pa,
XXEPM_FINANCE_INTEGRATION XX
WHERE
((nvl(accounted_dr,0) != 0 OR nvl(accounted_cr,0) != 0) OR
(nvl(accounted_dr,0) = 0 AND nvl(accounted_cr,0) = 0 AND
stat_amount is not NULL))
AND jeh.je_header_id = jel.je_header_id
AND src.je_source_name = jeh.je_source
AND cat.je_category_name = jeh.je_category
AND seq.doc_sequence_id(+) = jeh.doc_sequence_id
AND jel.code_combination_id = cc.code_combination_id
AND XX.EPM_PA_NO=PA.SEGMENT1
AND XX.FINANCE_PA_COA_SEG=CC.SEGMENT7
ORDER BY jeh.name, jel.je_line_num
) o100165
WHERE ( (o100163."Project No" = o100165.SEGMENT1))
GROUP BY o100163."Project Name";> please tell me anything wrong in this query
Umm, it's completely unreadable?
Even formatted (with a little help from the wangz.net online SQL formatter, though it needed some manual editing) it's pretty hard to see what it's meant to be doing, due to all the nesting and cryptic naming. This is just the first one:
SELECT o100161.org_structure_version_id AS e100351
, AVG(o100163.planned) AS e100360_avg
, AVG(o100163.actual) AS e100180_avg
, SUM(fx102) - SUM(fx103) AS c_1
, SUM(fx105) - SUM(fx106) AS c_2
, SUM(fx108) - SUM(fx109) AS c_3
FROM ( SELECT o100165.segment1 AS fx100
, SUM(o100165.acr) AS fx102
, SUM(o100165.adr) AS fx103
, SUM(o100165.bdr) AS fx105
, SUM(o100165.bcr) AS fx106
, SUM(o100165.ecr) AS fx108
, SUM(o100165.edr) AS fx109
FROM GG( SELECT NVL(src.user_je_source_name,'**************') source
, NVL(cat.user_je_category_name,'**************') category
, jeh.NAME NAME
, jel.code_combination_id ccid
, jeh.default_effective_date
, jel.period_name period_name
, jel.effective_date effective_date
, jel.description description
, seq.NAME sequence_name
, jeh.doc_sequence_value document_number
, jel.accounted_dr
, jel.accounted_cr
, DECODE(jeh.actual_flag, 'B',jel.accounted_dr, 'E',0, 'A',0) bdr
, DECODE(jeh.actual_flag, 'B',jel.accounted_cr, 'E',0, 'A',0) bcr
, DECODE(jeh.actual_flag, 'B',0, 'E',jel.accounted_dr, 'A',0) edr
, DECODE(jeh.actual_flag, 'B',0, 'E',jel.accounted_cr, 'A',0) ecr
, DECODE(jeh.actual_flag, 'B',0, 'E',0, 'A',jel.accounted_dr) adr
, DECODE(jeh.actual_flag, 'B',0, 'E',0, 'A',jel.accounted_cr) acr
, jel.je_line_num
, cc.segment7 project_coa_no
, cc.description segment_description
, pa.segment1
, jeh.actual_flag
, pa.NAME project_name
, cc.segment1 ||'.' ||cc.segment2 ||'.' ||cc.segment3 ||'.'
||cc.segment4 ||'.' ||cc.segment5 seg_desc
FROM gl_je_lines jel
, gl_code_combinations cc
, gl_je_headers jeh
, gl_je_categories cat
, gl_je_sources src
, fnd_document_sequences seq
, pa_projects_all pa
, xxepm_finance_integration xx
WHERE ( ( NVL(accounted_dr,0) != 0 OR NVL(accounted_cr,0) != 0 )
OR ( NVL(accounted_dr,0) = 0
AND NVL(accounted_cr,0) = 0
AND stat_amount IS NOT NULL ) )
AND jeh.je_header_id = jel.je_header_id
AND src.je_source_name = jeh.je_source
AND cat.je_category_name = jeh.je_category
AND seq.doc_sequence_id (+) = jeh.doc_sequence_id
AND jel.code_combination_id = cc.code_combination_id
AND xx.epm_pa_no = pa.segment1
AND xx.finance_pa_coa_seg = cc.segment7
ORDER BY jeh.NAME, jel.je_line_num) o100165
GROUP BY o100165.segment1)
, ( SELECT *
FROM per_org_structure_elements_v) o100161
, ( SELECT ppa.carrying_out_organization_id organization
, ppa.project_id AS "Project ID"
, ppa.segment1 AS "Project No"
, ppa.NAME AS "Project Name"
, NVL
( TRUNC
( ( (SYSDATE - ppa.scheduled_start_date) /
(ppa.scheduled_finish_date - ppa.scheduled_start_date) * 100)
, 0) planned
, NVL(TRUNC(AVG(ppc.completed_percentage)),0) actual
FROM pa_projects_all ppa
, pa_percent_completes ppc
WHERE ppa.carrying_out_organization_id IN
( SELECT a.organization_id_child
FROM per_org_structure_elements_v a
, pa_implementations_all b
WHERE a.org_structure_version_id = b.org_structure_version_id )
AND ppa.template_flag = 'N'
AND ppc.project_id (+) = ppa.project_id
GROUP BY
ppa.carrying_out_organization_id
, ppa.project_id
, ppa.segment1
, ppa.NAME
, ppa.scheduled_start_date
, ppa.scheduled_finish_date ) o100163
WHERE o100163."Project No" = fx100
AND o100161.organization_id_child = o100163.organization
GROUP BY o100161.org_structure_version_id; -
select CASE WHEN TO_NUMBER(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'DDMMYYYY HH24:MM:SS'),13,2))>0 AND TO_NUMBER(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MM:SS'),13,2)) <14
THEN TO_DATE(CONCAT(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MM:SS'),13,2)||'00',SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MI:SS'),16)||'00'),'DD-MM-YYYY HH24:MI:SS') end
from table;
i have written this query.whats wrong with this query..........
the error is "literal does not match format string"
Reegards soumenWhy does your date_format loose, ununify and not fix ?
And what is your exact requirement?
>>
CASE WHEN
TO_NUMBER(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'DDMMYYYY HH24:MM:SS'),13,2))>0
AND TO_NUMBER(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MM:SS'),13,2)) <14
<<
This is
CASE WHEN TO_CHAR(START_TIME_TIMESTAMP,'MM') between '01' and '13'
>>
THEN TO_DATE(CONCAT(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MM:SS'),13,2)
||'00',
SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MI:SS'),16)||'00'),
'DD-MM-YYYY HH24:MI:SS')
<<
This is
TO_DATE(
TO_CHAR(START_TIME_TIMESTAMP,'MM"00"SS"00"),
'DD-MM-YYYY HH24:MI:SS')
Obviously, format is not matching !
SQL> select to_char(sysdate,'MM"00"SS"00') from dual;
TO_CHAR(
06004900
SQL> select to_date('06004900','DD-MM-YYYY HH24:MI:SS') from dual;
select to_date('06004900','DD-MM-YYYY HH24:MI:SS') from dual
ERROR at line 1:
ORA-01861: literal does not match format string -
I have purchased a 'adobe font folio 11'.
The ci in this font was made.
Is there anything wrong with this post copyright if the Web site?These machines in themselves are usually pretty good, with the occasional aberration. Let's hope you do not have a rogue.
Looking at the problems there seem to me (as a guess) two problems: incomplete processes and memory. The two may be related. The camera problem I would dismiss as simply that -- batteries run out and the Mac is trying to complete an impossible process: expecting data, data never arrives.
The Firefox problem may be something external: a badly coded page; something the browser (or Mac) was not equipped to handle (a plug-in for example) and this could put a strain on RAM.
Maya, I am not familiar with, but it is (if I remember rightly) graphics-oriented and that can be memory intensive).
Which all comes down to the RAM you bought. Without knowing what it is or where it came from, or your experience in installing it, that in itself could be a problem. You need to make sure that it is properly seated for one thing, that it is the correct type (although the information here suggests that you are on the right track) and that it is OK.
You might also want to think about posting a crash log here (find these in Console) as someone -- not me -- might be able to pinpoint a cause. -
Hi i need to execute the following query using decode
select decode(blob_content,(select blob_content from a_images2 where employee_number not in (select employee_number from a_images2 )),(select blob_content from a_images2 where employee_number='FINALPHOTO'),(SELECT BLOB_CONTENT FROM A_IMAGES2 WHERE EMPLOYEE_NUMBER=:APP_USER)) photo
from a_images2;
but im getting the following error
ORA-00932: inconsistent datatypes: expected - got BLOB
why this causing problem, what is wrong with the above query.
Regards,
MiniBLOBs are not supported by decode.
Please take a look at this:
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions049.htm#sthref1080 -
Help: Anything wrong with this spatial query?
The error messages are as follows:
SELECT * FROM M_RGSERVERDB1 WHERE sdo_relate(M_RGSERVERDB1.geometry, mdsys.sdo_geometry(2003,NULL,NULL,mdsys.sdo_elem_info_array 1,1003,3),mdsys.sdo_ordinate_array(-97.3 ,35.1 , -97.1 , 35.3)),'mask=COVERS querytype=window') = 'TRUE'
java.sql.SQLException: ORA-06509: PL/SQL: ICD vector missing for this package
ORA-06512: at "JZHANG.MD", line 1723
ORA-06512: at "JZHANG.MDERR", line 8
ORA-06512: at "JZHANG.SDO_3GL", line 57
ORA-06512: at line 1
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:889)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.jav
a:1681)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
nt.java:1870)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:
538)
at
TestSpatial.main(TestSpatial.java:60)
nullHi, Jean-Marc:
Thanks very much for your help. However, I don't think I missed the parenthesis after I double-checked it-- maybe due to copy/paste.
In fact, SQLPLUS will remind me if I miss a parenthesis. The following is the SQL that casuse the problem.
SELECT * FROM M_RGSERVERDB1 WHERE sdo_relate(M_RGSERVERDB1.geometry, mdsys.sdo_geometry(2003,NULL,NULL,mdsys.sdo_elem_info_array (1,1003,3),mdsys.sdo_ordinate_array(-97.3 ,35.1 , -97.1 , 35.3)),'mask=COVERS querytype=window') = 'TRUE';
Do you have any ideas on version compatibility of 8.1.7 and 8.1.6 which might casue the problem?
Thanks.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Jean-Marc Prevost ([email protected]):
You have a missing opening parenthesis just after mdsys.sdo_elem_info_array.
You have:
mdsys.sdo_elem_info_array 1,1003,3)
You should have:
mdsys.sdo_elem_info_array (1,1003,3)
Hope this helps!<HR></BLOCKQUOTE>
null -
What is wrong with this query?
Hi,
The below query is showing this error:
ORA-01788:CONNECT BY LOOP in user data.
Please let me know where i am going wrong?
The data in the table xx_dates is :
Empno date1 date2
1 20-JAN-2008 24-JAN-2008
2 20-JAN-2008 20-JAN-2008The query i am using is:
select empno,date1,date2,date1+level-1,level,DBMS_RANDOM.random
from xx_dates
connect by empno=prior empno start with empno=1
and date1 <= date2-level + 1Edited by: Sreekanth Munagala on Nov 17, 2008 6:01 AMOr maybe it's this you are looking for...
SQL> ed
Wrote file afiedt.buf
1 with xx_dates as (select 1 as empno, to_date('20-JAN-2008','DD-MON-YYYY') as date1, to_date('24-JAN-2008','DD-MON-YYYY') as date2 from dual union all
2 select 2, to_date('20-JAN-2008','DD-MON-YYYY'), to_date('20-JAN-2008','DD-MON-YYYY') from dual)
3 --
4 select empno,date1,date2,date1+level-1,level,DBMS_RANDOM.random
5 from xx_dates
6 connect by level <= (date2-date1) + 1
7* start with empno=1
SQL> /
EMPNO DATE1 DATE2 DATE1+LEVEL-1 LEVEL RANDOM
1 20-JAN-2008 00:00:00 24-JAN-2008 00:00:00 20-JAN-2008 00:00:00 1 -291581367
1 20-JAN-2008 00:00:00 24-JAN-2008 00:00:00 21-JAN-2008 00:00:00 2 1347815622
1 20-JAN-2008 00:00:00 24-JAN-2008 00:00:00 22-JAN-2008 00:00:00 3 -595509310
1 20-JAN-2008 00:00:00 24-JAN-2008 00:00:00 23-JAN-2008 00:00:00 4 -1.602E+09
1 20-JAN-2008 00:00:00 24-JAN-2008 00:00:00 24-JAN-2008 00:00:00 5 -1.511E+09
SQL> -
Is anything wrong with this part of my code?
Hi all,
I am making a program with lots of methods inside the one class
whenever I call this method it stuffs up... it may be the way I call it or it may be the code is wrong.... could u please tell me if there is an error in the code or if this section is ok?
public static int seatSearch(String[][] reservation, String target)
// cycle through the array
for (int i = 0; i < reservation.length; i++)
// if the target is found, return the index
if (reservation[0] == target)
System.out.println("found at [" + i + "][0]");
return i;
// if it finished the loop and still hasn't returned anything
// then return -1 to signal the data wasn't found
System.out.println("the data was not found!");
return -1;
oh yeh... it compiles but when I call it it always returns -1 even when its meant to return the index...
Thanks,
Mikedo some defensive coding and check for nulls,
put some printlnwhat do u mean?
If you have a NullPointer Exception, then your code has a reference variable that does not point to an object.
If the exception comes from the code you posted, either the target variable, the reference variable, or one of the contents of the reference array must be null. To determine which it is, put a System.out.println(target+"\t"+reservation; at the start of the method and put a System.out.println(i+"\t"+reservation[0]); as the first line in the for loop. When your run the code, it will display null somewhere - and that's what you have to fix.
My guess is you have null references in the reservation array and you must decide what to do with those in your code. For exampleif (reservation[0] != null && reservation[i][0].equals(target)) -
Is there something wrong with this query
my query in a prepared statement is:
select * from RAC.v_ABRIDGEMENTS where ((? BETWEEN left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1) AND right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)) OR (? BETWEEN left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1) AND right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)) and ENTRY_DATE = ? and COUNTY = ? ) its obviusly wrong - the between stuff where i place two years - a lowYearLimit and an upperYearLimit they some how override the entry_date match that i'm trying to do :
so eg .
select * from RAC.v_ABRIDGEMENTS where (('1870' BETWEEN left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1) AND right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)) OR ('1870' BETWEEN left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1) AND right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)) and ENTRY_DATE = '1870-01-03 00:00:00.000' and COUNTY = 'Wigtown' )
will give all stuff 1870 and not just the 1870-01-03 matching stuff in 1870 ---how can i fix this ? ---basically the year stuff is in format of upperyear and lower year to account for occurances where the year is in a year range - such as 1870-1873 --this is in the same columnOK, reformatting this so I can read it (and getting rid of the useless sets of parenthesis), this is:
select *
from RAC.v_ABRIDGEMENTS
where ? BETWEEN left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1) AND right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)
OR ? BETWEEN left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1) AND right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)
and ENTRY_DATE = ?
and COUNTY = ?Now, if you understand operator precendence, the answer should be obvious; however, you probably don't so I'll spell it out....
Your WHERE clause has:
WHERE condition A
OR condition B
AND condition C
AND condition DApplying standard operator precedence, this is the same as:
A or (B and C and D)What I think you want is:
select *
from RAC.v_ABRIDGEMENTS
where (
? BETWEEN left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1) AND right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)
OR ? BETWEEN left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1) AND right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)
and ENTRY_DATE = ?
and COUNTY = ?This gives you:
WHERE (A or B) and C and D -
What's wrong with this query ?
v_SQL := 'OPEN RCT' || v_iLevel || ' FOR
SELECT datasets.*,
CASE fn_GetSupplierStatus(:p_SupplierID, DatasetID)
WHEN 1 THEN SMfn_GetSpecifiedRow(:p_SupplierStatus, 1)
WHEN 3 THEN SMfn_GetSpecifiedRow(:p_SupplierStatus, 2)
WHEN 4 THEN SMfn_GetSpecifiedRow(:p_SupplierStatus, 3)
WHEN 5 THEN SMfn_GetSpecifiedRow(:p_SupplierStatus, 4)
ELSE
CASE IsDataset
WHEN 0 THEN SMfn_GetSpecifiedRow(:p_SupplierStatus, 5)
ELSE SMfn_GetSpecifiedRow(:p_SupplierStatus, 5)
END
END AS CStatus,
CASE fn_GetUserPermission(:p_UserID, DatasetID)
WHEN 2 THEN SMfn_GetSpecifiedRow(:p_UserPermission, 1)
ELSE
CASE IsDataset
WHEN 0 THEN ''''
ELSE SMfn_GetSpecifiedRow(:p_UserPermission, 2)
END
END AS UStatus,
SMfn_DatasetHasChildren(DatasetID) as HasChildren,
:p_RoleID as RoleID
FROM datasets
WHERE Level_ = :v_iLevel';
raise_application_error(-20001, v_SQL);
execute immediate v_SQL
using p_SupplierID, p_SupplierStatus, p_SupplierStatus, p_SupplierStatus, p_SupplierStatus,
p_SupplierStatus, p_SupplierStatus, p_UserID, p_UserPermission, p_UserPermission, p_RoleID, v_iLevel;
What I am trying to do is to populate the cursor using a dynamic query, so that I can change cursor name each time.
All functions used exist, and still I get this error: Invalid SQL statement.
Is it possible to populate a cursor which is a parameter to the procedure (ref cursor) with a dynamic query ?
Thanks.this is the query that gets executed:
OPEN RCT1 FOR
SELECT datasets.*,
CASE fn_GetSupplierStatus(:p_SupplierID, DatasetID)
WHEN 1 THEN SMfn_GetSpecifiedRow(:p_SupplierStatus, 1)
WHEN 3 THEN SMfn_GetSpecifiedRow(:p_SupplierStatus, 2)
WHEN 4 THEN SMfn_GetSpecifiedRow(:p_SupplierStatus, 3)
WHEN 5 THEN SMfn_GetSpecifiedRow(:p_SupplierStatus, 4)
ELSE
CASE IsDataset
WHEN 0 THEN SMfn_GetSpecifiedRow(:p_SupplierStatus, 5)
ELSE SMfn_GetSpecifiedRow(:p_SupplierStatus, 5)
END
END AS CStatus,
CASE fn_GetUserPermission(:p_UserID, DatasetID)
WHEN 2 THEN SMfn_GetSpecifiedRow(:p_UserPermission, 1)
ELSE
CASE IsDataset
WHEN 0 THEN ''
ELSE SMfn_GetSpecifiedRow(:p_UserPermission, 2)
END
END AS UStatus,
SMfn_DatasetHasChildren(DatasetID) as HasChildren,
:p_RoleID as RoleID
FROM datasets
WHERE Level_ = :v_iLevel
The select works fine (without "Open RCT1 FOR") if I try to run it, but when trying to populate the cursor, I get the error Ivalid SQL statement. -
What's wrong with this query--need help
Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
select ename
from emp
where to_char(hiredate,'day')='tuesday';
when i execute the query
o/p is no rows selected
please help.
thanks in advance.Hi,
861173 wrote:
Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
select ename
from emp
where to_char(hiredate,'day')='tuesday';
when i execute the query
o/p is no rows selected Try:
WHERE TO_CHAR (hiredate, 'fmday') = 'tuesday'Without 'FM" in the 2nd argument, TO_CHAR pads the results to make it a consistent length. If your NLS_DATE_LANGUAGE=ENGLISH, that means it will always return a 9-character string, since the longest name in English ('Wednesday') has 9 letters. 'FM' (case-insernsitive) tells TO_CHAR not to add that kind of padding. -
Anything wrong with this repo?
following the beginners guide on wiki, doing the rankmirror
It says my best option is
mirror.neotuli.net
second best is
homes.umflint.edu
third is
ftp.archlinux.org
4th
mrrors.easynew.com
I am in USA, Oklahoma
any suggestions.If it's fast for you with rankmirror, generally choose the order that it gives.
This great website gives status updates on current mirrors. -
Anybody see anything wrong with this syntax ?
I tried to compile the following, but tells me there is an else without an if :
import javax.swing.JOptionPane;
class Test {
public static void main (String[] args) {
String response;
int togo = 0;
response = JOptionPane.showInputDialog ("What is your age?");
if (response == null)
JOptionPane.showMessageDialog
(null, "You clicked on the Cancel button");
else
if (response.equals (""))
JOptionPane.showMessageDialog
(null, "You must make an entry");
else
if ((Integer.parseInt(response)) < 65)
togo = (65 - (Integer.parseInt(response)));
JOptionPane.showMessageDialog
(null, "You have " + togo + " years to go until
retirement");
else
JOptionPane.showMessageDialog
(null, "You are already able to retire");
System.exit (0);import javax.swing.JOptionPane;
class Test {
public static void main (String[] args) {
String response;
int togo = 0;
response = JOptionPane.showInputDialog ("What is your age?");
if (response == null) { // -- Whenever you have more than one line of commands, you must enclose your statements with braces
JOptionPane.showMessageDialog
(null, "You clicked on the Cancel button");
} else if (response.equals ("")) { // same problem
JOptionPane.showMessageDialog
(null, "You must make an entry");
} else if ((Integer.parseInt(response)) < 65) {// same problem
togo = (65 - (Integer.parseInt(response)));
JOptionPane.showMessageDialog
(null, "You have " + togo + " years to go until
retirement");
} else { // same problem
JOptionPane.showMessageDialog
(null, "You are already able to retire");
System.exit (0);
} // close that last else statement
when you have more than one statement for your if i.e.
if ( condition ) {
statement 1;
statement 2;
} else if ( condition2 ) {
statement 1;
statement 2;
} else {
hope that this helped -
Is their anything wrong with this stored procedure?
CREATE PROCEDURE [dbo].[DeleteAllUserReferences]
@UserName NVARCHAR(256),
@Id NVARCHAR(128),
@Role NVARCHAR(256),
@RowsAffected int OUTPUT
AS
BEGIN TRY
/*Declare @RowsAffected int;*/
EXEC aspnet_UsersInRoles_RemoveUsersFromRoles "mainwebsite",@UserName,@Role
EXEC aspnet_Users_DeleteUser "mainwebsite",@UserName,15,@RowsAffected
DELETE FROM [AspNetUserRoles] WHERE UserId = @Id
DELETE FROM [AspNetUsers] WHERE UserName = @UserName
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
RETURN 0
I have a stored procedure above which executes fine when I execute it manually but does not when I execute it via asp.net. Only the first statement executes and the rest does not. Is their anything that might not be proper SQL in this code causing it to stop
functioning properly?
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering
- Yoda. Blog - http://www.computerprofessions.co.nrSince I don't know anything about the contents in that procedure I cannot comment on it. But if an error occurred, you would be taken the CATCH block and the error would be reraised.
Erland Sommarskog, SQL Server MVP, [email protected]
Here's the code you requested:
CREATE PROCEDURE [dbo].aspnet_Users_DeleteUser
@ApplicationName nvarchar(256),
@UserName nvarchar(256),
@TablesToDeleteFrom int,
@NumTablesDeletedFrom int OUTPUT
AS
BEGIN
DECLARE @UserId uniqueidentifier
SELECT @UserId = NULL
SELECT @NumTablesDeletedFrom = 0
DECLARE @TranStarted bit
SET @TranStarted = 0
IF( @@TRANCOUNT = 0 )
BEGIN
BEGIN TRANSACTION
SET @TranStarted = 1
END
ELSE
SET @TranStarted = 0
DECLARE @ErrorCode int
DECLARE @RowCount int
SET @ErrorCode = 0
SET @RowCount = 0
SELECT @UserId = u.UserId
FROM dbo.aspnet_Users u, dbo.aspnet_Applications a
WHERE u.LoweredUserName = LOWER(@UserName)
AND u.ApplicationId = a.ApplicationId
AND LOWER(@ApplicationName) = a.LoweredApplicationName
IF (@UserId IS NULL)
BEGIN
GOTO Cleanup
END
-- Delete from Membership table if (@TablesToDeleteFrom & 1) is set
IF ((@TablesToDeleteFrom & 1) <> 0 AND
(EXISTS (SELECT name FROM sysobjects WHERE (name = N'vw_aspnet_MembershipUsers') AND (type = 'V'))))
BEGIN
DELETE FROM dbo.aspnet_Membership WHERE @UserId = UserId
SELECT @ErrorCode = @@ERROR,
@RowCount = @@ROWCOUNT
IF( @ErrorCode <> 0 )
GOTO Cleanup
IF (@RowCount <> 0)
SELECT @NumTablesDeletedFrom = @NumTablesDeletedFrom + 1
END
-- Delete from aspnet_UsersInRoles table if (@TablesToDeleteFrom & 2) is set
IF ((@TablesToDeleteFrom & 2) <> 0 AND
(EXISTS (SELECT name FROM sysobjects WHERE (name = N'vw_aspnet_UsersInRoles') AND (type = 'V'))) )
BEGIN
DELETE FROM dbo.aspnet_UsersInRoles WHERE @UserId = UserId
SELECT @ErrorCode = @@ERROR,
@RowCount = @@ROWCOUNT
IF( @ErrorCode <> 0 )
GOTO Cleanup
IF (@RowCount <> 0)
SELECT @NumTablesDeletedFrom = @NumTablesDeletedFrom + 1
END
-- Delete from aspnet_Profile table if (@TablesToDeleteFrom & 4) is set
IF ((@TablesToDeleteFrom & 4) <> 0 AND
(EXISTS (SELECT name FROM sysobjects WHERE (name = N'vw_aspnet_Profiles') AND (type = 'V'))) )
BEGIN
DELETE FROM dbo.aspnet_Profile WHERE @UserId = UserId
SELECT @ErrorCode = @@ERROR,
@RowCount = @@ROWCOUNT
IF( @ErrorCode <> 0 )
GOTO Cleanup
IF (@RowCount <> 0)
SELECT @NumTablesDeletedFrom = @NumTablesDeletedFrom + 1
END
-- Delete from aspnet_PersonalizationPerUser table if (@TablesToDeleteFrom & 8) is set
IF ((@TablesToDeleteFrom & 8) <> 0 AND
(EXISTS (SELECT name FROM sysobjects WHERE (name = N'vw_aspnet_WebPartState_User') AND (type = 'V'))) )
BEGIN
DELETE FROM dbo.aspnet_PersonalizationPerUser WHERE @UserId = UserId
SELECT @ErrorCode = @@ERROR,
@RowCount = @@ROWCOUNT
IF( @ErrorCode <> 0 )
GOTO Cleanup
IF (@RowCount <> 0)
SELECT @NumTablesDeletedFrom = @NumTablesDeletedFrom + 1
END
-- Delete from aspnet_Users table if (@TablesToDeleteFrom & 1,2,4 & 8) are all set
IF ((@TablesToDeleteFrom & 1) <> 0 AND
(@TablesToDeleteFrom & 2) <> 0 AND
(@TablesToDeleteFrom & 4) <> 0 AND
(@TablesToDeleteFrom & 8) <> 0 AND
(EXISTS (SELECT UserId FROM dbo.aspnet_Users WHERE @UserId = UserId)))
BEGIN
DELETE FROM dbo.aspnet_Users WHERE @UserId = UserId
SELECT @ErrorCode = @@ERROR,
@RowCount = @@ROWCOUNT
IF( @ErrorCode <> 0 )
GOTO Cleanup
IF (@RowCount <> 0)
SELECT @NumTablesDeletedFrom = @NumTablesDeletedFrom + 1
END
IF( @TranStarted = 1 )
BEGIN
SET @TranStarted = 0
COMMIT TRANSACTION
END
RETURN 0
Cleanup:
SET @NumTablesDeletedFrom = 0
IF( @TranStarted = 1 )
BEGIN
SET @TranStarted = 0
ROLLBACK TRANSACTION
END
RETURN @ErrorCode
END
Sorry, about the delay. If you think this helps then I will finally be able to finish my stored procedure and move on.
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to
suffering - Yoda. Blog - http://www.computerprofessions.co.nr
Maybe you are looking for
-
Ipod 4th Generation - Won't turn on or charge - Reset didn't work
No charging, no turning on, no recognition by my iTunes for my 4th Gen iPod Touch. It is only about 6 months old. I tried the holding home and sleep buttons for 10 or more seconds but that did not work. Any other option besides going to the Apple
-
Sent mail does not sync between devices
My sent mail does not sync between devices. For example, if I send an email from my Iphone it does not show in my sent box on the MAC mail (postage stamp). If I send mail from MAC mail it does not show on my phone. But if I go to Yahoo (mail) I can
-
BT SPORT Broadband problems moving Hub near TV
My Hub fired up immediately when sited upstairs by my Computer, however would not connect to Broadband when moved near the TV. Spent hours on the 'phone with BT technitians, testing cables, moving Hub away from TV etc. Guess what I moved the BT ADS F
-
Creating Quality Notification via BAPI
I am attempting to create a quality notification using BAPI_QUALNOT_CREATE but am running into an issue. I need the ability to link the inspection lot number to the quality notification but I do not see a field for inspection lot in any of the BAPI
-
Hi, I have a session bean, that references some external classes. I am deploying the application as a ear file. The session beans are stored in a jar file and the external classes are stored in a separate jar file. Both the jar files go into an ear f