Problem With The Query
Hi gurus,
I have a problem in a query
I have a lot of records that are the same and I dont want to sum the value of them more than once. How can this be done??
The following table should illustrate my problem:
DEPT--MONTHCFBID----SCORE
ALST--APR100--
3
ALST--MAY100--
3
ALST--JUN101--
4
ALST--APR102--
5
Overall Score 15
I want the Overall Score to be 12. (only summing up unique records Of CFBID).
Any help will be greatly appreciated.
Regards
Supraja.K
Hi,
I had Done with Formula with Excveption Aggregation as Average And reference charecterstic as CFBID
DEPT--MONTHCFBID----SCORE
ALST--APR100--
3
ALST--MAY100--
3
ALST--JUN101--
4
ALST--APR102--
5
Overall Score 15
I want the Average Score12/3 = 4.
but I am getting as 15/3 = 5
What to Do any other Solution please
Similar Messages
-
Hi
DECLARE @XMLA nvarchar(3000)
, @DateSerial nvarchar(35);
-- Change date to format YYYYMMDDHHMMSS
SET @DateSerial = CAST(GETDATE() AS DATE);
--SELECT @DateSerial
Set @XMLA =
N' <Batch xmlns="http://schemas.microsoft.com/analysis services/2003/engine">
<ErrorConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2"
xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200"
xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200">
<KeyErrorLimit>-1</KeyErrorLimit>
<KeyNotFound>IgnoreError</KeyNotFound>
<NullKeyNotAllowed>IgnoreError</NullKeyNotAllowed>
</ErrorConfiguration>
<Parallel>
<Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2"
xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200"
xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300" xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300">
<Object>
<DatabaseID>MultidimensionalProject5</DatabaseID>
<CubeID>giri</CubeID>
<MeasureGroupID>Fact Internet Sales</MeasureGroupID>
</Object>
<Type>ProcessFull</Type>
<WriteBackTableCreation>UseExisting</WriteBackTableCreation>
</Process>
</Parallel>
</Batch>';
EXEC (@XMLA) At SHALL-PCAdventureWorksDw ;
iam executive the query when iam getting below error.
[Execute SQL Task] Error: Executing the query "DECLARE
@XMLA nvarchar(3000)
, @DateSerial nvarch..." failed with the following error: "Incorrect syntax near '-'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set
correctly, or connection not established correctly.
how to solve this error;
please help meWhat are you trying to do? What sort of data source is SHALL-PCAdventureWorksDw?
When you use EXEC() AT, I would execpt to see an SQL string to be passed to EXEC(), but you are passing an XML string????
If you explain why you think this would work in the first place, maybe we can help you.
Erland Sommarskog, SQL Server MVP, [email protected] -
Hi .
I was creating the pass the values t in temp tables though s sis package vs2012 .
First I was taken on executive SQL TASK.
IN EXCUTIVE SQL TASK . I was write the stored proce:
Sp;
reate procedure USP_GETEMP2333
AS
begin
Select eid,ename,dept,salary from emp
end;
create table #temp(eid int,ename varchar(20),dept varchar(20),salary int)
insert into #temp
exec USP_GETMP02333
go.
It was executive correctly.
I was taken another sequence container. In the sequence container iam creating one executive sql
In 2<sup>nd</sup> excutive sql task: sql statements is
if object_id('emp_fact_sal') is not null
drop table emp_fact_sal
select eid,ename as emp_name,sal_bar=
case when salary<=5000 then 'l'
when salary >5000 and salary<=7000 then 'm'
else
'h'
end
into emp_fact_sal from #temp.
and one falt flies it was taken to designation .
iam changing all connection properties:
in oldeb connection:
in excutive sal task properties .
delay validation is true,
and retain connection maner is also true,
and package mode is 64 bit is false.
But iwas excutive in 2<sup>nd</sup> excutive ql task .
Iam getting this type of errors,
[Execute SQL Task] Error: Executing the query " if object_id('emp_fact_sal') is not null
drop ta..." failed with the following error: "Invalid object name '#Temp'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
correctly.
Please help meArthur suggestion works but you shouldnt even be doing this on a SQL Task.
Use a data flow task. You'll have better control over the data that is being transfered and get better performance because no staging table will be used.
Just because there are clouds in the sky it doesn't mean it isn't blue. But someone will come and argue that in addition to clouds, birds, airplanes, pollution, sunsets, daltonism and nuclear bombs, all adding different colours to the sky, this
is an undocumented behavior and should not be relied upon. -
Problem with the query of Sharepoint Calculated Fields
Hello,
I am developing an application in sharepoint 2013 foundation. but i have problems with a list, when executing a caml query on a calculated field. I try the solution of this blog
http://sptalks.wordpress.com/2013/03/25/query-on-calculated-field-problem
but i got no result
attentive to any comments
thanksHello,
This is my CAML Query
<View>
<ViewFields>
<FieldRef Name="ID" />
<FieldRef Name="PermMask" />
<FieldRef Name="FSObjType" />
<FieldRef Name="Nombre" AutoHyperLink="TRUE" />
<FieldRef Name="Apellidos" AutoHyperLink="TRUE" />
<FieldRef Name="Cargo" /><FieldRef Name="Edad" />
<FieldRef Name="Compa_x00f1_ia" />
<FieldRef Name="Created" />
</ViewFields>
<Query>
<GroupBy Collapse="TRUE" GroupLimit="30">
<FieldRef Name="Compa_x00f1_ia" />
<FieldRef Name="Edad" />
</GroupBy>
<OrderBy>
<FieldRef Name="ID" />
</OrderBy>
<Where>
<Contains>
<FieldRef Name="Ano" LookupId="FALSE" />
<Value Type="Text">2014</Value>
</Contains>
</Where>
</Query>
</View> -
Problem with the query in group by clause
hi, i have problem with group by clause, can some one please help me.
select
header_id,
(select sum(nvl(dr,0) - nvl(cr ,0)) from temp_tab a1
where
a1.country=a.country
and a1.source='AP'
and a1.header_id=a.header_id) WHT,
sum(dr),
sum(cr) from temp_tab a
group by header_id,
(select sum(nvl(dr,0) - nvl(cr ,0)) from temp_tab a1
where
a1.country=a.country
and a1.source='AP'
and a1.header_id=a.header_id)
select * from temp_tab
drop table temp_tab
create table temp_tab(header_id number ,line_num number, country varchar2(2),
source varchar2(2), dr number, cr number,primary key(header_id,line_num));
insert into temp_tab(header_id, line_num,country, source, dr,cr) values(1, 1,'NL','AP',100,20);
insert into temp_tab(header_id, line_num,country, source, dr,cr) values(1, 2,'PO','AP',20,20);
insert into temp_tab(header_id, line_num,country, source, dr,cr) values(1, 3,'NL','AP',70,20);
insert into temp_tab(header_id, line_num,country, source, dr,cr) values(2, 1,'NL','PA',100,20);
insert into temp_tab(header_id, line_num,country, source, dr,cr) values(2, 2,'NL','PA',100,20);
insert into temp_tab(header_id, line_num,country, source, dr,cr) values(3, 1,'KR','PO',100,20);
commit;
Appreciate your help.
Thanks,select header_id,
(select sum(nvl(dr,0) - nvl(cr ,0)) from temp_tab a1
where a1.country=a.country
and a1.source='AP'
and a1.header_id=a.header_id) WHT,
sum(dr),
sum(cr)
from temp_tab a
group by header_id
,countryIt's kinda hard to follow what your query does... maybe because I'm only at my second coffee..
Edited by: Alex Nuijten on Oct 2, 2009 8:07 AM -
Hi,
I'm having a problem with the stabilization all of a sudden. I did an analyze. The amount of shake isn't terrible but it's there. There are no squiggly lines in the clip I'm trying to stabilize. As you can see in the screenshot that it allows me to click the "Smooth clip motion" but the slider is not there for zoom. Any ideas why this is happening all of a sudden? It happens on all clips in this event. The entire event was analyzed after importing.What program are you using for this editing?
We can ask a Host should move your query over to that forum. -
Problem with a query with a BLOB data type
Hi i've a problem with this query in 11g. R1
SELECT
LOGTIMESTAMP,
LOGTIMEMILLIS,
MSGID,
XMLTYPE(MESSAGEBODY, nls_charset_id('AL32UTF8')).getClobVal() as LLamada
FROM
vordel.AUDIT_MESSAGE_PAYLOAD,
vordel.AUDIT_LOG_POINTS
WHERE
AUDIT_LOG_POINTS.LOGPOINTSPK = AUDIT_MESSAGE_PAYLOAD.MP_LOGPOINTSPK AND
LOGTIMESTAMP between TO_TIMESTAMP('03-12-2011 00:00','DD-MM-YYYY HH24:MI') and TO_TIMESTAMP('03-12-2011 12:00','DD-MM-YYYY HH24:MI')
and filtertype = 'LogMessagePayloadFilter'
and filtername like 'Log Llamada%'MESSAGEBODY: data type of the Column is BLOB
throw this error after execute the query
Error:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00200: could not convert from encoding UTF-8 to UCS2
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 283
ORA-06512: at line 1Could you check the BLOB really contains UTF-8 encoded XML?
What's your database character set?The BLOB contains UTF-8 Encoded
and the database where i am connectes have AL32UTF8 character set, but my internal instance have "AMERICAN_AMERICA.WE8ISO8859P1"
that is a problem?
How could I change the character set of the oracle local client to the character set of the remote oracle data base? -
Hai All,
I have created a login form in screen painter (which contains two textbox and a login button). When login button is clicked, I want to check whether the username and password matches in the table (@EMPA).
I have a problem while checking with the query
This is User Defined Function a have used
Private Sub UDFCheckInTableLog()
Try
Dim rs As SAPbobsCOM.Recordset = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
rs.DoQuery("SELECT T0.U_user FROM [dbo].[@EMPA] T0 WHERE T0.U_user ='" & euser & "' AND TO.U_pass ='" & epass & "'")
rscount = rs.RecordCount
If rscount > 0 Then
'//There is a record that Matches
REC = True
'//To clear the values in the text box
UDFClear()
Else
'//This means NO Record Matches
REC = False
End If
Catch ex As Exception
SBO_Application.MessageBox("UDFCheckInTableLog :" & ex.Message)
End Try
End Sub
I get this error message
UDFCheckInTableLog:
1)[microsoft][ODBC SQL Server Driver][SQL Server] Incorrect syntax near the keyword 'TO'.
2))[microsoft][ODBC SQL Server Driver][SQL Server] Statement(s) could not be prepared.Hi,
You're trying to use Table Alias(T0), i'm guessing its not allowed. Try also to remove dbo, try @EMPA or just EMPA.
HTH
Manuel -
Hi all,
From Page 354 of the the Book "Pro T-SQL 2008 Programmer's Guide" written by Michael Coles (published by apress), I copied the following code (Listing 12-9 Retrieving Job Candidates with the query Method):
--Coles12_9.sql // saved in C:/Documemnts/SQL Server Management Studio
-- Coles Listing 12-9 Retrieving Job Candidates with the query Method
-- Doing XQuery and the xml Data Type in AdvantureWorks
-- 17 March 2015 1105 AM
USE AdventureWorks;
GO
SELECT Resume.query
N'//*:Name.First,
//*:Name.Middle,
//*:Name.Last,
//*:Edu.Level
FROM HumanResources.JobCandidate;
I executed this set of Listing 12-9 code in my SQL Server 2012 Management Studio and I got the following error messages:
Msg 105, Level 15, State 1, Line 4
Unclosed quotation mark after the character string '//*:Name.First,
//*:Name.Middle,
//*:Name.Last,
//*:Edu.Level
FROM HumanResources.JobCandidate;
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near '//*:Name.First,
//*:Name.Middle,
//*:Name.Last,
//*:Edu.Level
FROM HumanResources.JobCandidate;
I am not able to figure out why I got the error messages. Please kindly help and advise me how to correct this set of sql codes.
Thanks in advance,
Scott ChangHi Scott,
I don't have that book at hand, but your problem is the "Unclosed quotationmark after the character string",as the error message shows. You have to enclose the 'XQUERY' string quotation in the
query().
SELECT jobcandidateid, Resume.query
N'//*:resume,
//*:Name.Middle,
//*:Name.Last,
//*:Edu.Level' --enclose the quotation here
FROM HumanResources.JobCandidate;
For XQUERY learning, here is a good
link.
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Fact tables are compatible with the query request
Hi,
i am using 11g.In 10g working fine without any error.After migrate 10g into 11g below error will returning. What is the problem and How we will fix.Could you pls let me know.Thanks
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 14020] None of the fact tables are compatible with the query request FACT_AGENT_TIME_STATISTICS.FKEY. (HY000)
SQL Issued: SELECT s_0, s_1, s_2, s_3, s_4, s_5, s_6, s_7, s_8, s_9, s_10 FROM ( SELECT 0 s_0, "Team Performance"."DIMENSION - LOCATION"."COUNTRY CODE" s_1, "Team Performance"."DIMENSION - TIME"."BUSINESS DATE" s_2, CASE WHEN "Team Performance"."DIMENSION - TEAM"."ROLE" ='TEAM LEADER' THEN 'Team Leader' ELSE "Team Performance"."DIMENSION - TEAM"."TEAM" END s_3, CASE WHEN '30 Mins Interval' ='15 Mins Interval' THEN "Team Performance"."DIMENSION - TIME"."15 Mins Interval" ELSE "Team Performance"."DIMENSION - TIME"."30 Mins Interval" END s_4, ((SUM("Team Performance"."FACT - AGENT CALL STATISTICS"."TIME - ACD CALL HANDLING"+"Team Performance"."FACT - AGENT CALL STATISTICS"."TIME - AFTER CALL WORK (ACW)")+SUM("Team Performance"."FACT - AGENT TIME STATISTICS"."AVAILABLE TIME"))/60)/(COUNT(DISTINCT "Team Performance"."FACT - AGENT TIME STATISTICS"."DATE ID")*"Team Performance"."FACT - AGENT TIME STATISTICS"."INTERVAL TYPE") s_5, (SUM("Team Performance"."FACT - AGENT TIME STATISTICS"."AUX3 - TRAINING"+"Team Performance"."FACT - AGENT TIME STATISTICS"."AUX4 - MEETING"+"Team Performance"."FACT - AGENT TIME STATISTICS"."AUX5 - PROJECT"+"Team Performance"."FACT - AGENT TIME STATISTICS"."AUX6 - COACHING")/60)/(COUNT(DISTINCT "Team Performance"."FACT - AGENT TIME STATISTICS"."DATE ID")*"Team Performance"."FACT - AGENT TIME STATISTICS"."INTERVAL TYPE") s_6, (SUM("Team Performance"."FACT - AGENT TIME STATISTICS"."STAFFED TIME")/60)/(COUNT(DISTINCT "Team Performance"."FACT - AGENT TIME STATISTICS"."DATE ID")*"Team Performance"."FACT - AGENT TIME STATISTICS"."INTERVAL TYPE") s_7, COUNT(DISTINCT "Team Performance"."FACT - AGENT TIME STATISTICS"."DATE ID")*"Team Performance"."FACT - AGENT TIME STATISTICS"."INTERVAL TYPE" s_8, MIN("Team Performance"."DIMENSION - TIME"."FULL DATE TIME") s_9, REPORT_AGGREGATE(((SUM("Team Performance"."FACT - AGENT CALL STATISTICS"."TIME - ACD CALL HANDLING"+"Team Performance"."FACT - AGENT CALL STATISTICS"."TIME - AFTER CALL WORK (ACW)")+SUM("Team Performance"."FACT - AGENT TIME STATISTICS"."AVAILABLE TIME"))/60)/(COUNT(DISTINCT "Team Performance"."FACT - AGENT TIME STATISTICS"."DATE ID")*"Team Performance"."FACT - AGENT TIME STATISTICS"."INTERVAL TYPE") BY CASE WHEN '30 Mins Interval' ='15 Mins Interval' THEN "Team Performance"."DIMENSION - TIME"."15 Mins Interval" ELSE "Team Performance"."DIMENSION - TIME"."30 Mins Interval" END, CASE WHEN "Team Performance"."DIMENSION - TEAM"."ROLE" ='TEAM LEADER' THEN 'Team Leader' ELSE "Team Performance"."DIMENSION - TEAM"."TEAM" END) s_10 FROM "Team Performance" WHERE (("DIMENSION - TIME"."BUSINESS DATE" BETWEEN timestamp '2012-11-23 00:00:00' AND timestamp '2012-11-23 00:00:00') AND ("DIMENSION - LOCATION"."COUNTRY CODE" = 'US') AND ("DIMENSION - LOCATION".DEPARTMENT = 'CSG')) ) djm FETCH FIRST 65001 ROWS ONLYBack up your repository before following these steps:
1 Reduce the problem report to minimum number of columns required to generate the error. This will usually identify which dimension and which fact are incompatible.
2 Open the repository in the Administration tool and verify that the dimension and fact table join at the physical layer of the repository
3 Verify that there is a complex join between the dimension and the fact in the business layer.
4 Check the logical table sources for the fact table. At least one of them must have the Content tab set to a level in the hierarchy that represents the problem dimension. This is usually the detailed level.
5 Check the logical table source Content tab for the dimension table. Unless there is a valid reason, this should be set to blank.
6. Save any changes to the repository. -
Hi Friends,
I am having a problem with this query. The query is to fetch all the elements for the employees. The elements that need to be fetched are set up in the flex sets.
In the table fnd_flex_values there are columns start_date_active and end_date_active fields and these are null. In the below query when I use the condition
and trunc(sysdate) between NVL(ffv.start_Date_active,TO_DATE('01-JAN-1951','DD-MON-YYYY')) and NVL(ffv.end_Date_active,TO_DATE('31-DEC-4712','DD-MON-YYYY'))
the query fetches the results in 5seconds
but when I replace the same query with the statement
and to_date(to_char(ppa.date_earned,'DD-MON-YYYY'),'DD-MON-YYYY') between NVL(ffv.start_Date_active,TO_DATE('01-JAN-1951','DD-MON-YYYY')) and NVL(ffv.end_Date_active,TO_DATE('31-DEC-4712','DD-MON-YYYY'))
the query takes a lot of time. Infact it gets timed out
Columns start_date_active and end_date_active fields are date type. Can anyone say what is the issue with this query
When I give the sysdate instead of ppa.date_earned date
select papf.person_id, papf.full_name, papf.employee_number
,petf.element_name, pivf.name,
prrv.result_value, ppa.date_earned,ppa.effective_date, to_char(ppa.date_earned,'DD-MON-YYYY') date_earned, paaf.assignment_id, petf.effective_start_date
,petf.effective_end_date, ffv.*
from per_all_people_f papf
,per_all_assignments_f paaf
,pay_payroll_actions ppa
,pay_assignment_actions paa
,pay_element_types_f petf
,pay_input_values_f pivf
,pay_run_results prr
,pay_run_result_values prrv
,per_person_type_usages_f pptuf
,per_person_types ppt
,fnd_flex_values ffv
,fnd_flex_value_sets ffvs
where 1=1
and papf.person_id = paaf.person_id
and trunc(ppa.date_earned) between trunc(papf.effective_start_date) and trunc(papf.effective_end_date)
and trunc(ppa.date_earned) between trunc(paaf.effective_start_date) and trunc(paaf.effective_end_date)
and paa.assignment_id = paaf.assignment_id
and paa.action_status='C'
and ppa.payroll_id = 61
--and ppa.consolidation_set_id = 108
and ppa.payroll_action_id = paa.payroll_action_id
and prr.assignment_action_id = paa.assignment_action_id
and prr.element_type_id = petf.element_type_id
-- and trunc(ppa.date_earned) between trunc(petf.effective_start_date) and trunc(petf.effective_end_date)
and trunc(sysdate) between petf.effective_start_date and petf.effective_end_date
and prrv.run_result_id = prr.run_result_id
and prrv.input_value_id = pivf.input_value_id
and prr.status in ('P','PA')
and pivf.name ='Pay Value'
and ppa.date_earned between pivf.effective_start_date and pivf.effective_end_date
and ppa.time_period_id=145
and paaf.person_id = pptuf.person_id
and pptuf.person_type_id = ppt.person_type_id
and ppt.user_person_type = nvl('Employee',ppt.user_person_type)
and trunc(ppa.date_earned) between pptuf.effective_start_date and pptuf.effective_end_date
and petf.element_name = ffv.flex_value
and ffv.flex_value_set_id = ffvs.flex_value_set_id
and ffv.enabled_flag ='Y'
and ffvs.flex_value_set_name='GROUP_ELEMENTS'
and trunc(sysdate) between NVL(ffv.start_Date_active,TO_DATE('01-JAN-1951','DD-MON-YYYY')) and NVL(ffv.end_Date_active,TO_DATE('31-DEC-4712','DD-MON-YYYY'))
-- and trunc(ppa.effective_date) between nvl(ffv.start_Date_active,trunc(ppa.effective_date)) and NVL(ffv.end_Date_active,trunc(ppa.effective_date))
-- and to_date(to_char(ppa.date_earned,'DD-MON-YYYY'),'DD-MON-YYYY') between NVL(ffv.start_Date_active,TO_DATE('01-JAN-1951','DD-MON-YYYY')) and
order by ffv.parent_flex_value_low, papf.employee_number;
Thanksʃʃp wrote:
/* Formatted on 2012/06/11 13:34 (Formatter Plus v4.8.8) */
SELECT DISTINCT fr_ir_code, fr_fc_code1, product1, param_rep_prd, no_of_links_start_ir, no_of_supps_start_ir
FROM comm_exst_rp_comit_aggr_irview
WHERE fr_ir_code = 'AS01'
AND srta_period = 2
AND srta_year = 2011
AND param_rep_prd = '2011-2'
AND DECODE (:bind_variable, 'All', 1, 0) = DECODE (:bind_variable, 'All', 1, 1)
GROUP BY fr_ir_code, fr_fc_code1, product1, param_rep_prd, no_of_links_start_ir, no_of_supps_start_ir
UNION
SELECT DISTINCT fr_ir_code, fr_fc_code1, product1, param_rep_prd, no_of_links_start_irda AS no_of_links_start_ir,
no_of_supps_start__irda AS no_of_supps_start_ir
FROM comm_exst_rp_comit_aggr_irview
WHERE fr_ir_code = 'AS01'
AND srta_period = 2
AND srta_year = 2011
AND param_rep_prd = '2011-2'
AND da_status = 'N'
AND DECODE (:bind_variable, 'All', 1, 0) = DECODE (:bind_variable, 'All', 0, 0)
GROUP BY fr_ir_code, fr_fc_code1, product1, param_rep_prd, no_of_links_start_irda, no_of_supps_start__irdaYes Union is one of the best solutions for handling two queries.
As per my understanding DECODE function use is:
DECODE (value,<if this value>,<return this value>,
<if this value>,<return this value>,
<otherwise this value>)
But I am little bit jumbled for understanding below two lines in the query..
1)
AND DECODE (:bind_variable, 'All', 1, 0) = DECODE (:bind_variable, 'All', 1, 1)
2)
AND DECODE (:bind_variable, 'All', 1, 0) = DECODE (:bind_variable, 'All', 0, 0)Can you please tell me how the comparision is done using DECODE function? -
Hi,
I'm having a problem with the following simple XSQL document:
<?xml version="1.0"?>
<xsql:query connection="xsqltest" xmlns:xsql="urn:oracle-xsql">
SELECT concat(concat(forename, ' '), surname) AS Name
, d.name AS Department
FROM emp, dept d
WHERE emp.dept_no = d.id
ORDER BY surname
</xsql:query>When I transform this using the command line xsql, it produces the following (as expected):
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<Name>Cindy Delight</Name>
<Department>Accounting</Department>
</ROW>
<ROW num="2">
<Name>Adrian Rue</Name>
<Department>Product Development</Department>
</ROW>
<ROW num="3">
<Name>Dwight Dweeb</Name>
<Department>Accounting</Department>
</ROW>
</ROWSET>However, when I access the same page through my browser, the output is:
<?xml version = '1.0'?>
<xsql:query>
SELECT concat(concat(forename, ' '), surname) AS Name
, d.name AS Department
FROM emp, dept d
WHERE emp.dept_no = d.id
ORDER BY surname
</xsql:query>(this is the same as the input document, except the namespace declaration has been stripped out, making the XML invalid).
I've tried including other xsql tags in the same document (e.g. xsql:include-xsql), these seem to work fine. Also, if I change the connect details, XSQL fails as expected, so it would appear xsql is being invoked by Tomcat (.xsql is mapped to the servlet), and XSQL successfully connecting to the database.
My setup is slightly unusual: I'm trying to use XSQL 1.0.4.1 with MySQL 3.23.32 using the mm.mysql 2.0.4 JDBC drivers. This is running on Tomcat 3.2.1 with JDK 1.3 (OJVM 1.2.330). But, since it works with the command line xsql, I'm at a loss as to why it's misbehaving through the servlet engine only... any ideas?
SteveHmm,
Even more confusing - the same .xsql document works fine with WebToGo - so I guess this is a Tomcat problem, somehow... Just can't understand why xsql:include-xsql works and xsql:query doesn't.
Steve -
Problem with Hierarchical query
Gurus,
I have a problem with hierarchical query, which I am pasting below.
select sys_connect_by_path (Fname,'/')"PATH",Fname,id,level
,(SELECT COUNT(ID)-1 FROM (SELECT CONNECT_BY_ROOT LNAME LNAME,ID FROM CMT_PERSON
START WITH ID = 'emplo000000000126009'
CONNECT BY PRIOR ID=MANAGER_ID)
GROUP BY FNAME)"COUNT"
from CMT_PERSON
WHERE
LEVEL <= 4
----And ID='emplo000000000001877'
CONNECT BY PRIOR id=manager_id
----AND NOT LEVEL > 3
START WITH ID='emplo000000000126009'
As per the result, count is getting repeated for all the levels. That is, count is coming 16100 for every level, Can you please help where exactly I am going wrong
RegardsYou do not say anything about what count you want to get?
A wild guess could be:
select
sys_connect_by_path (p1.fname, '/') "PATH",
p1.fname,
p1.id,
level,
(select count (id) - 1
from
(select connect_by_root p2.lname lname, p2.id
from cmt_person p2
start with p2.id = p1.id
connect by prior p2.id = p2.manager_id)
) "COUNT"
from cmt_person p1
where level <= 4
connect by prior p1.id = p1.manager_id
start with p1.id = 'emplo000000000126009';Since your inner query simply starts with the hardcoded employee id, naturally it will give you the same count.
My guess is your inner query should start with the person id from the outer query?
If that is not the case - please state in plain english what you are trying to accomplish ;-)
(Oh, and please paste code within tags so we can read it more easily...) -
Hi,
I have a problem with af:query. Here's what I do:
1. create a VO, define view criteria
2. drag and drop view criteria from data controls to an empty form, choosing query and table
3. When I run the page and click any of the buttons, I get: "Because of inactivity, your session has timed out and is no longer active...."
I see no exceptions in output window. What am I doing wrong?
Here is my view defenition:
<?xml version="1.0" encoding="windows-1250" ?>
<!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
<!---->
<ViewObject
xmlns="http://xmlns.oracle.com/bc4j"
Name="EmployeesView"
Version="11.1.1.49.49"
SelectList="Employees.EMPLOYEE_ID,
Employees.FIRST_NAME,
Employees.LAST_NAME,
Employees.EMAIL,
Employees.PHONE_NUMBER,
Employees.HIRE_DATE,
Employees.JOB_ID,
Employees.SALARY,
Employees.COMMISSION_PCT,
Employees.MANAGER_ID,
Employees.DEPARTMENT_ID"
FromList="EMPLOYEES Employees"
BindingStyle="OracleName"
CustomQuery="false"
PageIterMode="Full"
UseGlueCode="false">
<DesignTime>
<Attr Name="_codeGenFlag2" Value="Access|VarAccess"/>
</DesignTime>
<Variable
Name="firstName"
Kind="viewcriteria"
Type="java.lang.String"
DefaultValue="0"/>
<EntityUsage
Name="Employees"
Entity="project3.Employees"
JoinType="INNER JOIN"/>
<ViewAttribute
Name="EmployeeId"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="EmployeeId"
EntityUsage="Employees"
AliasName="EMPLOYEE_ID"/>
<ViewAttribute
Name="FirstName"
PrecisionRule="true"
EntityAttrName="FirstName"
EntityUsage="Employees"
AliasName="FIRST_NAME"/>
<ViewAttribute
Name="LastName"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="LastName"
EntityUsage="Employees"
AliasName="LAST_NAME"/>
<ViewAttribute
Name="Email"
IsUnique="true"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="Email"
EntityUsage="Employees"
AliasName="EMAIL"/>
<ViewAttribute
Name="PhoneNumber"
PrecisionRule="true"
EntityAttrName="PhoneNumber"
EntityUsage="Employees"
AliasName="PHONE_NUMBER"/>
<ViewAttribute
Name="HireDate"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="HireDate"
EntityUsage="Employees"
AliasName="HIRE_DATE"/>
<ViewAttribute
Name="JobId"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="JobId"
EntityUsage="Employees"
AliasName="JOB_ID"/>
<ViewAttribute
Name="Salary"
PrecisionRule="true"
EntityAttrName="Salary"
EntityUsage="Employees"
AliasName="SALARY"/>
<ViewAttribute
Name="CommissionPct"
PrecisionRule="true"
EntityAttrName="CommissionPct"
EntityUsage="Employees"
AliasName="COMMISSION_PCT"/>
<ViewAttribute
Name="ManagerId"
PrecisionRule="true"
EntityAttrName="ManagerId"
EntityUsage="Employees"
AliasName="MANAGER_ID"/>
<ViewAttribute
Name="DepartmentId"
PrecisionRule="true"
EntityAttrName="DepartmentId"
EntityUsage="Employees"
AliasName="DEPARTMENT_ID"/>
<ViewCriteria
Name="EmployeesViewCriteria"
ViewObjectName="project3.EmployeesView"
Conjunction="AND">
<Properties>
<CustomProperties>
<Property
Name="mode"
Value="Basic"/>
<Property
Name="allowConjunctionOverride"
Value="true"/>
<Property
Name="autoExecute"
Value="false"/>
<Property
Name="showInList"
Value="true"/>
<Property
Name="displayOperators"
Value="InAdvancedMode"/>
</CustomProperties>
</Properties>
<ViewCriteriaRow
Name="vcrow24"
UpperColumns="1">
<ViewCriteriaItem
Name="FirstName"
ViewAttribute="FirstName"
Operator="STARTSWITH"
Conjunction="AND"
UpperColumns="0"
Required="Optional">
<ViewCriteriaItemValue
Name="EmployeesViewCriteria_vcrow24_EmployeeId_vcval0"
Value=":firstName"
IsBindVarValue="true"/>
</ViewCriteriaItem>
</ViewCriteriaRow>
</ViewCriteria>
<ViewLinkAccessor
Name="EmployeesView"
ViewLink="project3.EmpManagerFkLink"
Type="oracle.jbo.RowIterator"
IsUpdateable="false"/>
</ViewObject>
And JSF page:
<af:panelGroupLayout layout="vertical">
<af:panelHeader text="Employees">
<af:query id="employeesViewCriteriaQueryId" headerText="Search"
disclosed="true"
resultComponentId="employeesViewCriteriaQueryResultId"
value="#{bindings.EmployeesViewCriteriaQuery.queryDescriptor}"
model="#{bindings.EmployeesViewCriteriaQuery.queryModel}"
queryListener="#{bindings.EmployeesViewCriteriaQuery.processQuery}"
queryOperationListener="#{bindings.EmployeesViewCriteriaQuery.processQueryOperation}"/>
</af:panelHeader>
<af:table value="#{bindings.EmployeesView1.collectionModel}" var="row"
rows="#{bindings.EmployeesView1.rangeSize}"
emptyText="#{bindings.EmployeesView1.viewable ? 'No rows yet.' : 'Access Denied.'}"
fetchSize="#{bindings.EmployeesView1.rangeSize}"
id="employeesViewCriteriaQueryResultId">
<af:column sortProperty="EmployeeId" sortable="false"
headerText="#{bindings.EmployeesView1.hints.EmployeeId.label}">
<af:outputText value="#{row.EmployeeId}">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.EmployeesView1.hints.EmployeeId.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="FirstName" sortable="false"
headerText="#{bindings.EmployeesView1.hints.FirstName.label}">
<af:outputText value="#{row.FirstName}"/>
</af:column>
<af:column sortProperty="LastName" sortable="false"
headerText="#{bindings.EmployeesView1.hints.LastName.label}">
<af:outputText value="#{row.LastName}"/>
</af:column>
</af:table>
</af:panelGroupLayout>
Regards
Jernej
Message was edited by:
Jernej KaseIt also seems that quick queries don't work with SQL92 sqlBuilder.
I get the following error:
Messages for this page are listed below.
Error
SQL error during statement preparation. Statement: SELECT Employees.EMPLOYEE_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.EMAIL, Employees.PHONE_NUMBER, Employees.HIRE_DATE, Employees.JOB_ID, Employees.SALARY, Employees.COMMISSION_PCT, Employees.MANAGER_ID, Employees.DEPARTMENT_ID FROM EMPLOYEES Employees WHERE (( ( ( UPPER(Employees.FIRST_NAME) LIKE UPPER(:vc_temp_1) ) OR ( ? IS NULL ) ) ) )
Error
Missing IN or OUT parameter at index:: 2
Is this a bug or this doesn't work by design?
Edit: and if I create named query I get the following error:
Caused by: oracle.jbo.NoDefException: JBO-25058: Definition fn of type Attribute not found in EmployeesView1
at oracle.jbo.server.ViewObjectImpl.findAttributeDef(ViewObjectImpl.java:5634)
at oracle.jbo.uicli.binding.JUSearchBindingCustomizer.getQuickSearchVC(JUSearchBindingCustomizer.java:847)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding.processQuery(FacesCtrlSearchBinding.java:222)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
... 47 more
I think just ran out of options...
Message was edited by:
Jernej Kase -
Hallo,
i have a problem with following query. I wanna update the columns in the nutzung table. There are 7 columns but my query updates the geometry that in all columns is the same geometry or I can not update because the query gives more than 1 row in the subquery.
update nutzung
set geometrie=(SELECT F1840_GEOM FROM UG_F1840_GEOM,Nutzung WHERE NUTZUNG.OBJNR=UG_F1840_GEOM.F1840_OBJNR AND GETFEATUREID(UG_F1840_GEOM.F1840_FID) IN(SELECT MSLINK FROM FEATURE WHERE FCODE like '%0000'));
Maybe I need the ug_f1840_geom table in the update query. Don't know how to change the query.
Regards, Katrinhi it's me again .I am getting error for this
statement
if(numOfUsers>0)
stmt.executeUpdate("update defaultchatrooms set
s set nodename =
'"+chatTopic+"'('"+numOfUsers+"')'");
1. Your update string looks like this:
update defaultchatrooms set nodename = 'someChatTopic'('0')'
Does that look right to you?
2. This will update the column nodename in every row in the table defaultchatrooms. Aren't you missing a "where" condition?
Maybe you are looking for
-
Can't convert the swf to MovieClip
I have a problem where i have an as3 project loading in an AS3 SWF which contains another AS3 SWF containing a videoplayer, and i'm getting the type coercian fail error as above. TypeError: Error #1034: Type Coercion failed: cannot convert work_clien
-
Touchscreen is not working after updates on Windows
Hi My touchscreen stopped working after the Windows updates on my laptop froze. I have went through all the settings of the pen and touch and others to resolve this problem and unfortunately it is still not working. I have also rebooted the laptop to
-
OK, I have finally had a chance to play around with my newly purchases iMac 24" yesterday! So far so good, and as a now ex Windows users I am very impressed with the OS However, I have one little niggle, and if there's a solution I would love to see
-
Is there a way to put a resume on an ipad?
Is there a way to make a resume on an ipad?
-
====================================================== Can i install 10.2.0.4 patch set 14 on my client when SERVER is at 10.2.0.4 patchset 5? ====================================================== We have a customer with DB on windows-2003 64 bit wi