CR VS 2010 SQL query issue
Hi all
I'm facing a problem with my code.
Dim cr As New CrystalReport1()
Dim newCmd As SqlCommand
Dim conn As SqlConnection
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim cr As New CrystalReport1
Dim MyConnectionStr As String = "Data Source=MyDB;Initial catalog=MyCat;Integrated Security=true;" ' providerName=System.data.sqlClient"
conn = New SqlConnection(MyConnectionStr)
Dim cmdText As String
cmdText= " SELECT customer.customer_name, customer.customer_tel, orders.order_stuff_name, orders.order_number" & _
" FROM hesabres.dbo.orders orders inner JOIN hesabres.dbo.customer customer ON orders.order_customer_id=customer.customer_id"
da = New SqlDataAdapter(newCmd)
da.fill(ds)
cr.SetDataSource(ds.Tables(0))
crystalviewer1.ReportSource = cr
conn.Close()
newCmd.Dispose()
if i run the query, let's say it returns 2 rows
I my CR veiwer, it shows 4 rows (duplicates 2 x 2),
if the query returns 3 rows, CR displays 9 rows (3 x 3) and so on 10 (10x10)....
How is it possible??
In my Dataset, the number of rows is always correct!
Do you have any idea?
Thanks in advance.
B.
See this wiki on how to troubleshoot issues with CR and datasets:
Troubleshooting Issues with VS .NET Datasets and Crystal Reports - Business Intelligence (BusinessObjects) - SCN Wiki
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center
Canada
Follow us on Twitter
Similar Messages
-
Oracle Sql Query issue Running on Different DB Version
Hello All,
I have come into situation where we are pruning sql queries on different DB version of Oracle and have performance issue. Let me tell you in brief and i really appreciate for your prompt response as its very imperative stuff.
I have a query which is running on a DB of version 7.3.4 and it takes around 30 mins where as the same query when run on 8i it takes 15sec., its a huge difference. I have run the statistics to analyze on 7.3 and its comparatively very high. Question here is, the sql query trys to select data from same schema table and 2 tables from another DB using DB link and 2 other tables from another DB using DB link.So,how can we optimize this stuff and achieve this run as same time as 8i DB in 7.3. Hope i am clear about my question, Eagerly waiting for your replies.
Thanks in Advance.
Message was edited by:
Ram8Difficult to be sure without any more detailed information, but I suspect that O7 is in effect copying the remote tables to local temp space, then joining; 8i is factoring out a better query to send to the remote DBs, which does as much work as possible on the remote DB before shipping remaining rows back to local.
You should be able to use EXPLAIN PLAN to identify what SQL is being shipped to the remote DB, If you can't (and it's been quite a while since I tried DB links or O7) then get the remote DBs to yourself, and set SQL_TRACE on for the remote instances. Execute the query and then examine the remote trace files, And don't forget to turn off the tracing when you're done.
Of course it could just be that the CBO got better,,,
HTH - if not, post your query and plans for the local db, and the remote queries.
Regards Nigel -
SQL Query issue with large varchar column
I have a SQL Query (PL/SQL function body returning SQL query) which contains a large varchar column. Even if I substring the column to 30chars when it displays on the page it wraps. I have tried putting nowrap="wrap" for the HTML table cell attributes and it still wraps. I have tried setting the width attributes on the column even though it's not an updateable column. Does anyone have any ideas on how prevent this from wrapping. In some cases 1 line will take up 3 because of this wrapping issue and it's not nice to look at. It seems that the column is somewhere set to a fixed width, which is less than 30 characters, and anything beyond this fixed width wraps.
Hi Netha,
Can you please provide the DDLs of three tables you are using,
Also post us how many rows you are getting output for this query?
select * from dim.store st where
st.store_code = 'MAUR'
also try to run and update statement on this table as below and execute your query
update dim.store
set store_code
= ltrim(rtrim(store_code))
where
store_code = 'MAUR'
once you run this update, then run your query. Let us know the result. -
VO SQL Query issue... JHeadstart...
Hi,
I am presently using JHeadStart 10.1.3.3.81 in order to convert an Oracle Form FMB via an XML format to an ADF-JSF application as follows:-
1) Using the iff2xml90 utility provided with the Oracle designer converted the Oracle Form FMB to an XML file.
2) Using Jdeveloper(with JHeadstart 10.1.3.3.81) converted the XML file generated in STEP 1 above into a J2EE ADF-JSF project.
3) One of the VO's generated in the project has the following query:-
SELECT INITMV.INSTALLATION_ID,
INITMV.FACILITY_ID,
INITMV.DI_SHORT_NAME
FROM CP_INSTALLATIONS_ALL INITMV
WHERE ( CPPRI.ORG_ID in(select org_id from cp_system_controls ) and CPPRI.DELIVERY_LOCATION_NUMBER=nvl(:b_LOC_LOCATION_NUMBER,CPPRI.DELIVERY_LOCATION_NUMBER) and
(:b_LOC_CATEGORY_ID is null or CPPRI.INVENTORY_ITEM_ID in (select inventory_item_id from di_mtl_item_categories_v where category_id=:b_LOC_CATEGORY_ID)) and exists (select 1
from DI_DISTRIBUTION_PLANS_V dis where trunc(dis.plan_date)=trunc(sysdate) and CPPRI.facility_id=dis.facility_id and CPPRI.installation_id=dis.installation_id and
CPPRI.organization_id=dis.organization_id and CPPRI.inventory_item_id=dis.inventory_item_id and (dis.midcycle_call_flag='Y' or (CPPRI.call_days is not null and trunc
(dis.last_delivery_date+CPPRI.call_days)<=trunc(sysdate)))) ) ORDER BY DI_SHORT_NAME
As can be seen from the above query, the CPPRI reference does not point to any db table/view/synonym. Actually the CPPRI reference should be pointing to the CP_INSTALLATIONS_ALL table.
4) When I checked the XML file for the datablock to which this query belongs, I found the following:-
<Block Name="INITMV" ScrollbarLength="1200" DeleteAllowed="false" OrderByClause="order by DI_SHORT_NAME" WhereClause="where (&#10;CPPRI.ORG_ID in(select org_id from cp_system_controls )&#10;and CPPRI.DELIVERY_LOCATION_NUMBER=nvl(:LOC.LOCATION_NUMBER,CPPRI.DELIVERY_LOCATION_NUMBER)&#10;and (:LOC.CATEGORY_ID is null or CPPRI.INVENTORY_ITEM_ID in (select inventory_item_id from di_mtl_item_categories_v&#10;where category_id=:LOC.CATEGORY_ID))&#10;and exists (select 1&#10;from DI_DISTRIBUTION_PLANS_V dis&#10; where trunc(dis.plan_date)=trunc(sysdate)&#10; and CPPRI.facility_id=dis.facility_id&#10; and CPPRI.installation_id=dis.installation_id&#10; and CPPRI.organization_id=dis.organization_id&#10; and CPPRI.inventory_item_id=dis.inventory_item_id&#10; and (dis.midcycle_call_flag='Y'&#10; or&#10; (CPPRI.call_days is not null and trunc(dis.last_delivery_date+CPPRI.call_days)<=trunc(sysdate))))&#10;)" Alias="CPPRI" UpdateAllowed="false" NextNavigationBlockName="INSHST" InsertAllowed="false" DMLDataName="CP_INSTALLATIONS_ALL" ParentModuleType="25" ScrollbarYPosition="984" ScrollbarTabPageName="" QueryDataSourceName="CP_INSTALLATIONS_ALL" ParentType="3" RecordsBufferedCount="9" ParentName="CGSO$BLOCK_MR" DMLReturnValue="true" ParentFilename="aqmolb65.olb" PreviousNavigationBlockName="LOC" ParentModule="AQMOLB65" PersistentClientInfoLength="41" EnforcedPrimaryKey="true" RecordsDisplayCount="6" ScrollbarXPosition="6700" DirtyInfo="false" ScrollbarCanvasName="CG$PAGE_1">
I am not sure whether the above is at all a bug or whether the Oracle Form from which the sql query was generated in itself had a glitch in the first place(actually it works fine on the Oracle Forms side). If this is a bug, does this belong to the FMB to XML conversion or from the XML to J2EE conversion.
Regards,
Lester.Hi,
JHeadstart questions should be posted to
JHeadstart
Frank -
SQL query issue, how to improve it?
Hello all, I want to create a query with with result in the following result. Every first person of an department starts with the letter A and goes up like this:
Name department
A Person1 3
B Person2 3
C Person3 3
D Person4 3
E Person10 3
A Person6 10
B Person7 10
C Person8 10
A Person4 13
B Person9 13
It has to be a SQL query, unfortunately no PL/SQL
I was able to create this query, but its lacking. Department_id will be a variable, a person can choose one department or several departments, so the query varies in size.
select chr(64+rownum), name, department_id
from ( select name, department_id
from employees
where department_id = 3
order by id_but, naam
union
select chr(64+rownum), name, department_id
from ( select name, department_id
from employees
where department_id = 10
order by id_but, naam
union
select chr(64+rownum), name, department_id
from ( select name, department_id
from employees
where department_id = 13
order by id_but, naam
order by id_but, naam
The employees table has the following columns:
id, name, department_id
Can anyone help me make this query better? parhaps with the With clause?Use analytic function ROW_NUMBER:
with t as (
select 'A' name,3 department from dual union all
select 'B',3 from dual union all
select 'C',3 from dual union all
select 'D',3 from dual union all
select 'E',3 from dual union all
select 'A',10 from dual union all
select 'B',10 from dual union all
select 'C',10 from dual union all
select 'A',13 from dual union all
select 'B',13 from dual
select name,
'Person' || row_number() over(partition by department order by name) person,
department
from t
order by 3,
3
NAME PERSON DEPARTMENT
A Person1 3
B Person2 3
C Person3 3
D Person4 3
E Person5 3
A Person1 10
B Person2 10
C Person3 10
A Person1 13
B Person2 13
10 rows selected.
SQL> SY. -
MS Project 2010: SQL Query Expansion to custom field
In a further forum topic I got the solution for searching for server admins approvals pending, not publisched projects and team members not sended times.
We defined a new enterprise custom field called "Status reporting" from type Flag (yes/no).
Can someone help me to expand the following MS SQL query get the state of "Status Reporting" in the solution table?
SELECT DISTINCT R.RES_NAME as [RESOURCE NAME], RB.RES_NAME STATUS_MANAGER, P.PROJ_NAME,A.TASK_NAME,
[STATUS] = Case TR.ASSN_TRANS_ACTION_ENUM When 0 Then
'Pending' When 1 Then 'Accepted' When 2 Then 'Rejected' End,
IS_PUBLISHED = CASE WHEN P.WPROJ_LAST_PUB >TR.ASSN_TRANS_SUBMIT_DATE THEN 'Yes' ELSE 'No' END,
TASKSTATUS = CASE WHEN AU.ASSN_UID IS NULL AND TR.ASSN_TRANS_ACTION_ENUM = 0 THEN 'Saved' ELSE 'Submitted' END,
BASELINED = CASE AB_BASE_NUM WHEN 0 THEN 'Yes' ELSE 'No' END
FROM MSP_ASSIGNMENT_TRANSACTIONS TR WITH(READPAST)
LEFT OUTER JOIN dbo.MSP_CONVERSIONS C ON ((C.CONV_VALUE =
TR.ASSN_TRANS_ERROR_ENUM) AND (STRING_TYPE_UID = 'A16A340A-4AD1-4F62-880C-564C45021502'))
LEFT OUTER JOIN MSP_ASSIGNMENTS_SAVED A WITH(READPAST) ON TR.ASSN_UID = A.ASSN_UID
LEFT OUTER JOIN MSP_ASSIGNMENTS_SUBMITTED AU WITH(READPAST) ON TR.ASSN_UID = AU.ASSN_UID
LEFT OUTER JOIN MSP_ASSIGNMENT_BASELINES AB WITH(READPAST) ON TR.ASSN_UID = AB.ASSN_UID AND AB.AB_BASE_NUM = 0
LEFT OUTER JOIN MSP_PROJECTS P ON A.PROJ_UID = P.PROJ_UID
LEFT OUTER JOIN MSP_TASKS_SAVED TA ON TR.TASK_UID = TA.TASK_UID
LEFT OUTER JOIN MSP_PROJECT_RESOURCES R ON A.RES_UID = R.RES_UID AND R.PROJ_UID = P.PROJ_UID
LEFT OUTER JOIN MSP_PROJECT_RESOURCES RD ON
TR.ASSN_TRANS_DELEGATEE_RES_UID = RD.RES_UID AND P.PROJ_UID = RD.PROJ_UID
LEFT OUTER JOIN MSP_RESOURCES RD1 ON TR.ASSN_TRANS_DELEGATEE_RES_UID = RD1.RES_UID
LEFT OUTER JOIN MSP_PROJECT_RESOURCES RS ON
TR.ASSN_TRANS_SUBMITTER_RES_UID = RS.RES_UID AND P.PROJ_UID = RS.PROJ_UID
LEFT OUTER JOIN MSP_RESOURCES RS1 ON TR.ASSN_TRANS_SUBMITTER_RES_UID = RS1.RES_UID
LEFT OUTER JOIN MSP_RESOURCES RA ON TR.ASSN_TRANS_APPROVER_RES_UID = RA.RES_UID
LEFT OUTER JOIN MSP_RESOURCES RB ON A.WRES_UID_Manager = RB.RES_UID
LEFT OUTER JOIN PS_TestFarm01__Prodcp20130606_Reporting.dbo.MSP_EpmResource mer on A.WRES_UID_Manager=mer.ResourceUID
MurolHello Paul,
great, it works. I inserted:
Statusreporting =
CASE PV.[Status
Reporting] WHEN 1
THEN
'Yes'
ELSE
'No'
END
LEFT OUTER JOIN PS_TestFarm01__Prodcp20130606_Reporting.dbo.MSP_EpmProject_UserView PV
ON PV.ProjectUID = P.Proj_UID
The first line I understand a little bit but I don't understand
PV.[Status Reporting]
But, the second line "LEFT OUTER ...", I doesn't understand
Many thanks and kind regards
Peter
Murol -
SQL Query Issue - (inner not passing to outer query)
Hello everyone:
Here is my SQL query:
SELECT RD.SITE,
ROUND(
(SELECT COUNT (DISTINCT PB.EMP_ID)
FROM BOOK PB
WHERE PB.EMP_ID IN
(SELECT PB.EMP_ID FROM BOOK PB
(SELECT COUNT (DISTINCT PB.EMP_ID)
FROM BOOK PB
WHERE PB.EMP_ID IN
(SELECT PB.EMP_ID FROM BOOK PB
WHERE MO.QUALIFIER > 4
)* 100, 2) AS PERCENTAGE
FROM BOOK PB
LEFT JOIN POSITION MO
ON PB.EMP_ID = PO.EMP_ID
INNER JOIN PHYS_LOCATION RD
ON MO.HOUSED = RD.SITE_ID
WHERE MO.ACTUAL_END IS NULL
GROUP BY RD.SITE;Why am I getting the overall percentage for all Sites as opposed to each percentage calculating for each individual site. I grouped by RD.SITE, so I presumed it would calculate percentages for each site. What did I do wrong?
Thank you for your assistance.AquaNX4 wrote:
Hello everyone:
Here is my SQL query:
SELECT RD.SITE,
ROUND(
(SELECT COUNT (DISTINCT PB.EMP_ID)
FROM BOOK PB
WHERE PB.EMP_ID IN
(SELECT PB.EMP_ID FROM BOOK PB
(SELECT COUNT (DISTINCT PB.EMP_ID)
FROM BOOK PB
WHERE PB.EMP_ID IN
(SELECT PB.EMP_ID FROM BOOK PB
WHERE MO.QUALIFIER > 4
)* 100, 2) AS PERCENTAGE
FROM BOOK PB
LEFT JOIN POSITION MO
ON PB.EMP_ID = PO.EMP_ID
INNER JOIN PHYS_LOCATION RD
ON MO.HOUSED = RD.SITE_ID
WHERE MO.ACTUAL_END IS NULL
GROUP BY RD.SITE;Why am I getting the overall percentage for all Sites as opposed to each percentage calculating for each individual site. I grouped by RD.SITE, so I presumed it would calculate percentages for each site. What did I do wrong?Because that is what you are requesting. Your scalar subquery to get the percentage is not restricted by the current site. Add filter columns to restrict the selected values for the computation
Edited by: riedelme on May 8, 2013 7:26 AM -
I am attempting to connect to a Progress database using JDBC and am having a few issues with my SQL statement. The code concerned looks like this:
// Get a statement from the connection
Statement stmt = conn.createStatement() ;
// Execute the query
ResultSet rs = stmt.executeQuery( "SELECT * FROM pub.cust" ) ;
// Loop through the result set
while( rs.next() )
System.out.println( rs.getString( "cust-code" ) ) ;
That works just fine. Prints out each of the cust-code values. My issue comes when I try to refine the query to be:
ResultSet rs = stmt.executeQuery( "SELECT * FROM pub.cust WHERE cust.Cust-code='100001-0'" ) ;
or even
ResultSet rs = stmt.executeQuery( "SELECT Cust-code FROM pub.cust" ) ;
Both of these give me an error saying Column not found/specified.
if I wrap Cust-code in single quotes, the script prints Cust-code on each line, not the value for it. If I escape Cust-code like Cust\-code, I get an Illegal escape character. Any ideas?I have never used Progress, but maybe you have to fully qualify the field names like this:
ResultSet rs = stmt.executeQuery( "SELECT * FROM pub.cust WHERE pub.cust.Cust-code='100001-0'" ) ;
ResultSet rs = stmt.executeQuery( "SELECT pub.cust.Cust-code FROM pub.cust" ) ;Just a thought. -
Friends,
We are running ORACLE 11g in Unix enviornment. Every week, our application run a flow from application, its run a query everytime and its not use the right index due to this its take lot of time. I want to set in database, its use everytime our mention index and does not change execution plan. Any ideas?
Regards,
Irfan AhmadHi
Use a sql profile. You can have a hint to you the index so when application use the sql statement it will start using the sql statement with index hint .
DECLARE
test_task_name VARCHAR2(30);
test_sqltext CLOB;
BEGIN
test_sqltext := 'SELECT /*+ index(XX <your index name>) */ * from < your table> XX where co1=''yyyy'')';
test_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(
sql_text => test_sqltext,
user_name => '<your schema name>',
scope => 'COMPREHENSIVE',
time_limit => 60,
task_name => 'test_sql_tuning_task_2',
description => 'Test Task to tune a query');
END;
BEGIN
DBMS_SQLTUNE.EXECUTE_TUNING_TASK( task_name => 'test_sql_tuning_task_2');
end;
Check the oracle support document 271196.1 for further clarification
Cheers
Kanchana.
Edited by: Kanchana Devasurendra on Nov 1, 2010 3:47 PM -
I am trying to use a method to query a database to gather a person's name when the Social Security Number is entered. However in the display, it seems to only bring back the field that you use to compare in the load statement. Can anyone tell me what I am doing wrong? The below example will bring back the SSN but if I change the last line in the example to HISTORY.fullName I get a "Null Value" returned back. Thanks.
input "Social Security Number of Employee to terminate: " : intSSN
//intSSN is a local variable
using title = "Termination Applet",
buttons = ["OK", "Cancel"]
returning selectedButton = selection
//pg 310 of Fuego 5.5 document
//Database name is HISTORY, local variable is ssn, seems to only only display what is in load
//and nothing else
load BpmDB.Dbo.HISTORY using ssn = intSSN
display HISTORY.ssnload BpmDB.Dbo.HISTORY using ssn = intSSN
display HISTORY.ssnTry doing:
load BpmDB.Dbo.HISTORY using ssn = intSSN
display HISTORY //Note the difference, we're asking for the whole object,
not just the ssn
Juan
On Thu, 07 Sep 2006 13:52:39 -0300, Ben Sfanos wrote:
I am trying to use a method to query a database to gather a person's
name when the Social Security Number is entered. However in the
display, it seems to only bring back the field that you use to compare
in the load statement. Can anyone tell me what I am doing wrong? The
below example will bring back the SSN but if I change the last line in
the example to HISTORY.fullName I get a "Null Value" returned back.
Thanks.
input "Social Security Number of Employee to terminate: " : intSSN
//intSSN is a local variable
using title = "Termination Applet",
buttons = ["OK", "Cancel"]
returning selectedButton = selection
//pg 310 of Fuego 5.5 document
//Database name is HISTORY, local variable is ssn, seems to only only
display what is in load
//and nothing else
load BpmDB.Dbo.HISTORY using ssn = intSSN
display HISTORY.ssn -
Regarding accessing SQL query issued by any user in Oracle 10g
Hi all,
i want to know the queries issued by various users accessing a database...
But the in view DBA_AUDIT_TRAIL,I was getting empty value...(in SQLTEXT column) ...how can i get this value...
Thanx
in advance..Straight from the documentation :
The SQL_BIND and SQL_TEXT columns are only populated if the AUDIT_TRAIL initialization parameter is set to db,extended.In addition, you have to make sure you issued the AUDIT command on the objects you would like to AUDIT access on.
[Configuring and Administering Auditing|http://download.oracle.com/docs/cd/B19306_01/network.102/b14266/cfgaudit.htm] -
SQL Query issue find difference in records
Hi All,
I am using oracle 10g. I need urgent help in finding difference in records based on date:
I have table sales as below:
salesman SALES_COUNT DATE
JOHN 20 04/01/2012
DENNY 15 04/01/2012
JOHN 30 04/02/2012
DENNY 30 04/02/2012
JOHN 45 04/03/2012
DENNY 50 04/03/2012
SALES_COUNT is increasing for sales man with date. Its like cumulative count. John has total sales from 04/01/2012 to 04/03/2012 is 50 and same case with Denny. This SALES_COUNT will keep on increasing with dates as sales keep adding in the table for each salesman.
But i want to have seprate counts for each salesman.
for e.g: SALES_COUNT JOHN on 04/02/2012 is 30-20 =10
SALES_COUNT JOHN on 04/03/2012 is 45-30 =15
SALES_COUNT DENNY on 04/02/2012 is 30-15 =15
SALES_COUNT JOHN on 04/03/2012 is 50-30 =20
Please help me with this scenario and let me know if need more information. I will greatly appreciate your help.
Thanks.Does this give you what you want?
with t as (
select 'JOHN' salesman, 20 sales_count, to_date('04/01/2012', 'mm/dd/yyyy') sale_date from dual
union all
select 'DENNY' salesman, 15 sales_count, to_date('04/01/2012', 'mm/dd/yyyy') sale_date from dual
union all
select 'JOHN' salesman, 30 sales_count, to_date('04/02/2012', 'mm/dd/yyyy') sale_date from dual
union all
select 'DENNY' salesman, 30 sales_count, to_date('04/02/2012', 'mm/dd/yyyy') sale_date from dual
union all
select 'JOHN' salesman, 45 sales_count, to_date('04/03/2012', 'mm/dd/yyyy') sale_date from dual
union all
select 'DENNY' salesman, 50 sales_count, to_date('04/03/2012', 'mm/dd/yyyy') sale_date from dual
select salesman,
sales_count sales_todate,
sale_date,
sales_count - lag(sales_count, 1, 0) over (partition by salesman order by sale_date) daily_sales
from t
SALESMAN,SALES_TODATE,SALE_DATE,DAILY_SALES
DENNY,15,4/1/2012,15
DENNY,30,4/2/2012,15
DENNY,50,4/3/2012,20
JOHN,20,4/1/2012,20
JOHN,30,4/2/2012,10
JOHN,45,4/3/2012,15
-
Hi
I have Pure SQL DataBase name of Table as per given Coloumn Name.
User Name StartDate EndDate
Mr.Jack 01/04/2010 05/04/2010
Mr.Perlin 07/04/2010 10/04/2010
Mr.Tinklin 01/05/2010 05/05/2010
Mr.Kerlin 12/04/2010 15/04/2010
Now I am using asp.net Form Using C#...
Name --> TextBox
StartDate -> TextBox
EndDate --> TextBox
Now User enter the Dates after Click Save Button....
Here SQL Query Check Whether the User Dates Clause into Data Base Date's.
For Examble..
User Enter Start Date = 04/04/2010, EndDate =08/04/2010
Now Query it check SQL DataBase, Already 01/04/2010 to 10/04/2010 Available so Dont allow Save.... only allow various dates...
---------------- This is task Condition -------
i am using SQL Query
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate ='02/04/2010' --// This is User Start Date coming from Text Box
SET @EndDate = '10/04/2010' --// This is User End Date coming from Text Box
IF NOT EXISTS (SELECT PollID FROM Polls WHERE (StartDate<= CAST (CONVERT(VARCHAR,@StartDate,101) AS DATETIME) OR EndDate <= CAST (CONVERT (VARCHAR,@EndDate,101) AS DateTime)) AND STATUS<>'D')
SELECT 'OK ALLLOW'
ELSE
SELECT 'NOT ALLOW'
But it is not working Correctly....
Pls give some correctful query for solve task Condition
By
Riyaz
Edited by: 798225 on Sep 28, 2010 10:37 PM
Edited by: 798225 on Sep 28, 2010 10:52 PMNow I am developing Polls Application in asp.net
I am using Polls Concept,
DateBase Name : Polls
Fields : PollID PollName StartDate EndDate UserID
In Asp.Form Having
User Name : TextBox
PollName: TextBox
StartDate: TextBox
EndDate: TextBox
Submit - Button
Task Details
Whenever User Click after fillup all data's... then SQL Query Check
if StartDate or EndDate is exists in Between DataBase Date's.....
Condition true means dont allow save.. else Save.....
Examble:
PollID PollName StartDate EndDate UserName
01 Sample 23/09/2010 26/09/2010 Klit
02 Sample 2 29/09/2010 30/09/2010 Jack
Now User given follwing details and click Submit,
User Name : James
PollName: Test
StartDate: 22/09/2010
EndDate: 27/09/2010
Submit - Button
Here User StartDate: 22/09/2010 , EndDate: 27/09/2010
SQL Query Check ,
Condtion 1 : Those dates are avilable in Datebase???
Result: Yes
Because, Sample Poll date is 23/09/2010 to 26/09/2010, here Start Date is Not Exists, But End Date Exists.
So dnt allow Save Operation....
Now User Again given follwing details and click Submit,
User Name : James
PollName: Test
StartDate: 27/09/2010
EndDate: 28/09/2010
Submit - Button
Here User StartDate: 27/09/2010 , EndDate: 28/09/2010
SQL Query Again Check ,
Condtion 1 : Those dates are avilable in Datebase???
Result: No
Because, Sample Poll date is 23/09/2010 to 26/09/2010,
Sample1 Poll Date is 29/09/2010 to 30/09/2010
here Start Date is Not Exists, But End Date Not Exists.
So Allow Save Operation....
This a My Task....
Could You give SQL Query for help to Check given condition??
regd
Riayz
Edited by: Riyaz on Sep 30, 2010 1:08 AM -
Hi all,
I think I'm being really stupid but I'm having SQL query issues.
I have a table with lots of lines of transactions which all refer to different stores, for example:
Store..............._Sales_............._Month_
Reading............200k..............April
Leeds...............50k................April
Manchester........70k................May
Reading............100k..............May
I need to come up with the average Sales for the combined months as a total. I.e. the average Store revenue for a given period is 200k+ 50k + 70k +100k / *3* (As there are only 3 unique stores) - hopefully this makes sense!
So essentially I am trying to do both a SUM query (and grouping by store) and then outputting the average of all stores together. Is this possible?
Thank you,Hello,
This query returns 140 what seems to be the correct value:
with data as
( select 'Reading' Store
, 200 sales
from dual
union
select 'Leeds'
, 50
from dual
union
select 'Manchester'
, 70
from dual
union
select 'Reading'
, 100
from dual
select sum(sales)
, count( distinct store )
, sum(sales)/count(distinct store)
from dataThere are multiple options:
1. You can get two IR's on one page (by using IFRAMEs - search for that word on the Forum)....
2. You create another region with the query above and position that just below the report
3. In the Region Footer call a PL/SQL process (using AJAX) that calculates the value using the query and prints it there (using htp.p)
Greetings,
Roel
http://roelhartman.blogspot.com/
http://www.bloggingaboutoracle.org/
http://www.logica.com/
You can award this reply to your question by marking it as either Helpful or Correct ;-) -
SQL query performance issues.
Hi All,
I worked on the query a month ago and the fix worked for me in test intance but failed in production. Following is the URL for the previous thread.
SQL query performance issues.
Following is the tkprof file.
CURSOR_ID:76 LENGTH:2383 ADDRESS:f6b40ab0 HASH_VALUE:2459471753 OPTIMIZER_GOAL:ALL_ROWS USER_ID:443 (APPS)
insert into cos_temp(
TRX_DATE, DEPT, PRODUCT_LINE, PART_NUMBER,
CUSTOMER_NUMBER, QUANTITY_SOLD, ORDER_NUMBER,
INVOICE_NUMBER, EXT_SALES, EXT_COS,
GROSS_PROFIT, ACCT_DATE,
SHIPMENT_TYPE,
FROM_ORGANIZATION_ID,
FROM_ORGANIZATION_CODE)
select a.trx_date,
g.segment5 dept,
g.segment4 prd,
m.segment1 part,
d.customer_number customer,
b.quantity_invoiced units,
-- substr(a.sales_order,1,6) order#,
substr(ltrim(b.interface_line_attribute1),1,10) order#,
a.trx_number invoice,
(b.quantity_invoiced * b.unit_selling_price) sales,
(b.quantity_invoiced * nvl(price.operand,0)) cos,
(b.quantity_invoiced * b.unit_selling_price) -
(b.quantity_invoiced * nvl(price.operand,0)) profit,
to_char(to_date('2010/02/28 00:00:00','yyyy/mm/dd HH24:MI:SS'),'DD-MON-RR') acct_date,
'DRP',
l.ship_from_org_id,
p.organization_code
from ra_customers d,
gl_code_combinations g,
mtl_system_items m,
ra_cust_trx_line_gl_dist c,
ra_customer_trx_lines b,
ra_customer_trx_all a,
apps.oe_order_lines l,
apps.HR_ORGANIZATION_INFORMATION i,
apps.MTL_INTERCOMPANY_PARAMETERS inter,
apps.HZ_CUST_SITE_USES_ALL site,
apps.qp_list_lines_v price,
apps.mtl_parameters p
where a.trx_date between to_date('2010/02/01 00:00:00','yyyy/mm/dd HH24:MI:SS')
and to_date('2010/02/28 00:00:00','yyyy/mm/dd HH24:MI:SS')+0.9999
and a.batch_source_id = 1001 -- Sales order shipped other OU
and a.complete_flag = 'Y'
and a.customer_trx_id = b.customer_trx_id
and b.customer_trx_line_id = c.customer_trx_line_id
and a.sold_to_customer_id = d.customer_id
and b.inventory_item_id = m.inventory_item_id
and m.organization_id
= decode(substr(g.segment4,1,2),'01',5004,'03',5004,
'02',5003,'00',5001,5002)
and nvl(m.item_type,'0') <> '111'
and c.code_combination_id = g.code_combination_id+0
and l.line_id = b.interface_line_attribute6
and i.organization_id = l.ship_from_org_id
and p.organization_id = l.ship_from_org_id
and i.org_information3 <> '5108'
and inter.ship_organization_id = i.org_information3
and inter.sell_organization_id = '5108'
and inter.customer_site_id = site.site_use_id
and site.price_list_id = price.list_header_id
and product_attr_value = to_char(m.inventory_item_id)
call count cpu elapsed disk query current rows misses
Parse 1 0.47 0.56 11 197 0 0 1
Execute 1 3733.40 3739.40 34893 519962154 11 188 0
total 2 3733.87 3739.97 34904 519962351 11 188 1
| Rows Row Source Operation
| ------------ ---------------------------------------------------
| 188 HASH JOIN (cr=519962149 pr=34889 pw=0 time=2607.35)
| 741 .TABLE ACCESS BY INDEX ROWID QP_PRICING_ATTRIBUTES (cr=519939426 pr=34889 pw=0 time=2457.32)
| 254644500 ..NESTED LOOPS (cr=519939265 pr=34777 pw=0 time=3819.67)
| 254643758 ...NESTED LOOPS (cr=8921833 pr=29939 pw=0 time=1274.41)
| 741 ....NESTED LOOPS (cr=50042 pr=7230 pw=0 time=11.37)
| 741 .....NESTED LOOPS (cr=48558 pr=7229 pw=0 time=11.35)
| 741 ......NESTED LOOPS (cr=47815 pr=7223 pw=0 time=11.32)
| 3237 .......NESTED LOOPS (cr=41339 pr=7223 pw=0 time=12.42)
| 3237 ........NESTED LOOPS (cr=38100 pr=7223 pw=0 time=12.39)
| 3237 .........NESTED LOOPS (cr=28296 pr=7139 pw=0 time=12.29)
| 1027 ..........NESTED LOOPS (cr=17656 pr=4471 pw=0 time=3.81)
| 1027 ...........NESTED LOOPS (cr=13537 pr=4404 pw=0 time=3.30)
| 486 ............NESTED LOOPS (cr=10873 pr=4240 pw=0 time=0.04)
| 486 .............NESTED LOOPS (cr=10385 pr=4240 pw=0 time=0.03)
| 486 ..............TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_ALL (cr=9411 pr=4240 pw=0 time=0.02)
| 75253 ...............INDEX RANGE SCAN RA_CUSTOMER_TRX_N5 (cr=403 pr=285 pw=0 time=0.38)
| 486 ..............TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=974 pr=0 pw=0 time=0.01)
| 486 ...............INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=488 pr=0 pw=0 time=0.01)
| 486 .............INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=488 pr=0 pw=0 time=0.01)
| 1027 ............TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_LINES_ALL (cr=2664 pr=164 pw=0 time=1.95)
| 2063 .............INDEX RANGE SCAN RA_CUSTOMER_TRX_LINES_N2 (cr=1474 pr=28 pw=0 time=0.22)
| 1027 ...........TABLE ACCESS BY INDEX ROWID RA_CUST_TRX_LINE_GL_DIST_ALL (cr=4119 pr=67 pw=0 time=0.54)
| 1027 ............INDEX RANGE SCAN RA_CUST_TRX_LINE_GL_DIST_N1 (cr=3092 pr=31 pw=0 time=0.20)
| 3237 ..........TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=10640 pr=2668 pw=0 time=15.35)
| 3237 ...........INDEX RANGE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=2062 pr=40 pw=0 time=0.33)
| 3237 .........TABLE ACCESS BY INDEX ROWID OE_ORDER_LINES_ALL (cr=9804 pr=84 pw=0 time=0.77)
| 3237 ..........INDEX UNIQUE SCAN OE_ORDER_LINES_U1 (cr=6476 pr=47 pw=0 time=0.43)
| 3237 ........TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=3239 pr=0 pw=0 time=0.04)
| 3237 .........INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=2 pr=0 pw=0 time=0.01)
| 741 .......TABLE ACCESS BY INDEX ROWID HR_ORGANIZATION_INFORMATION (cr=6476 pr=0 pw=0 time=0.10)
| 6474 ........INDEX RANGE SCAN HR_ORGANIZATION_INFORMATIO_FK2 (cr=3239 pr=0 pw=0 time=0.03)Please help.
Regards
Ashish| 254644500 ..NESTED LOOPS (cr=519939265 pr=34777 pw=0 time=3819.67)
| 254643758 ...NESTED LOOPS (cr=8921833 pr=29939 pw=0 time=1274.41)There is no way the optimizer should choose to process that many rows using nested loops.
Either the statistics are not up to date, the data values are skewed or you have some optimizer parameter set to none default to force index access.
Please post explain plan and optimizer* parameter settings.
Maybe you are looking for
-
Hey, i've got a 1T and a 500G hard drive in my workstation. The 500G drive is my media disk. I initialized a software RAID-1 with one missing drive on a 500G logical volume on the 1T disk. After formatting and copying all the data from the media disk
-
Hello, I'm trying to record start a YouTube channel for doing NBA Basketball videos, but when I go to record on ps4 it always come up that recording has paused or has been blocked, I spoke to playstation about this problem and they said its with the
-
How to add an SG to the Admin Group of a newly created VM in SCVMM cloud
Hi, have given a team access to the SCVMM private cloud to create there own VM's , what I would like todo, is to add the SG that these guys are a member of to that servers Admin Group. Otherwise they cannot log in, when once there server is created.
-
How to change language in pages
How do i change my language in pages from Danish to English?
-
I want to copy the content of a directory to another one, with the external copy command on a UNIX system Process p = Runtime.getRuntime().exec("cp " + f1 + " " + f2); So far it works with single files. But it doens't work with "*.*". The same comman