Sql query to betwen clause for date
i have a interface there user can enter two dates . in my servlet program i am getting it as string by using request .get parameter. i wanan to know how to write sql query for selecting data from database with between clause
i have a interface there user can enter two dates . in my servlet program i am getting it as string by using request .get parameter. i wanan to know how to write sql query for selecting data from database with between clause
Similar Messages
-
Hosting company does not support SQL query with OUTFILE clause
From my mysql database, I want to allow the user to run a query and produce a csv / text file of our membership database. Unfortunately, I just found out my hosting company does not support the SQL query with OUTFILE clause for MySQL database.
Are there any other options available to produce a file besides me running the query in phpadmin and making the file available to users.
Thanks. GeorgeMaybe this external Export Mysql data to CSV - PHP tutorial will be of help
Cheers,
Günter -
Change JDBC select SQL query's where clause at runtime
Hi,
I have one JDBC sender channel with Select SQL Query which helps in fetching data from JDE table. We have defined where clause to fetch some particular records i.e. if ABC = NULL then fetch the record.. and then update query is used to turn that flag to "Y" i.e. ABC ="Y" so that next time the channel don't pick the same records again.
Now the problem is that if we want to fetch some records again whose flag has been set to "Y" we cannot change the select query again and again in the production environment.
Is there any way to change the select query of the JDBC channel at runtime e.g. Picking up some flat file where the conditions for the particular records to be picked are defined (ID=123) and changing the WHERE clause of select query in the JDBC channel for those records to be picked without using BPM.
Thank you!
With regards,
SimranHi Simran,
Yes, it is possible with the help of store procedure. In SQL Server there is a IF-Else Conditional block, which you can use inside store procedure. Create a SP with 2 additional parameter something like FlagReadAgain and KeyField. Pass the flag always as True or False. For the Key field pass the record key which you want to read again if you are passing the Flag as True else pass it as 0 or whatever.
In the procedure check if the value of flag is True -> If yes, Read the entry with key name specified in where part.
In the else part put the query which you are using for the normal flow.
IF (FlagReadAgain) = TRUE
BEGIN
SELECT EmpName, EmpAddress
FROM Employee
WHERE EmpID = 'E001'
END
ELSE
BEGIN
SELECT EmpName, EmpAddress
FROM Employee
WHERE Status = 'N'
END
You may also use the approach which Srini mentioned. Create an application to restore any value to intial stage so that it can be picked up by XI when it poll again.
Choose any approach which you like.
Regards,
Jitender Chauhan -
Sql query to indetify the identical data
Hi
I would like to know the query to identify the identical data in same table.
Example: I have table called 'AA" having same data for load_ctry i.e. 'MY' and 'HK' ,I need sql query to indetify the identical data for above countries in that table.
Thanks
MRHi,
Table called "AA" with columns col1,col2,col3,load_ctry with following sample date
col1 col2 col3 load_ctry
3 bg xx TH
4 op xc TH
3 bg xx MY
4 op xc MY
3 vb nb MY
When query ,if data is identical for both countries ,no data to fecth or data identical .If data is differ ,it will return the mismatching data becuase we are using same table for both countries .
Thanks
MR -
Can we change/Modify BI server generated Sql query and run to fetch data
Hi,
My client is saying that there is an option to modify bi server generated sql query to fetch data from source.
question:As a request is made in presentation services, A dynamic sql query is generated and fetches data from source. all this is loggedin Nqlquery log..well can we change/modify the sql query generated and run modified sql query to fetch data from source. ., if so how? if not why?
Thanks in advance
Edited by: user10794468 on Jun 16, 2009 6:29 PM
Edited by: user10794468 on Aug 12, 2009 6:58 PMThank you so much for your reply..
..Can we also modify sql query generated by bi server to fetech data. the query's which we see in query log file.. -
Hi
I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?
I basically need person name who submitted, date - time it was submitted for approval, then the person who approved it and the date - time that it was approved
Thanks
RubyRuby,
you can start with HXC_TIMECARD_SUMMARY table for submitter detail. But for approver details, i think you need WF tables to get the data for item type HXCEMP. -
How to Use SQL Query having IN Clause With DB Adapter
Hi,
I am using 11.1.1.5 want to find out how to Use SQL Query having IN Clause With DB Adapter. I want to pass the IN values dynamically. Any ideas.
Thanksinvoke a stored procedure, it's safer than trying to put together an arbitrary SQL statement in the JCA adapter
-
Issue with SQL Query with Presentation Variable as Data Source in BI Publisher
Hello All
I have an issue with creating BIP report based on OBIEE reports which is done using direct SQL. There is this one report in OBIEE dashboard, which is written using direct SQL. To create the pixel perfect version of this report, I am creating BIP data model using SQL Query as data source. The physical query that is used to create OBIEE report has several presentation variables in its where clause.
select TILE4,max(APPTS), 'Top Count' from
SELECT c5 as division,nvl(DECODE (C2,0,0,(c1/c2)*100),0) AS APPTS,NTILE (4) OVER ( ORDER BY nvl(DECODE (C2,0,0,(c1/c2)*100),0)) AS TILE4,
c4 as dept,c6 as month FROM
select sum(case when T6736.TYPE = 'ATM' then T7608.COUNT end ) as c1,
sum(case when T6736.TYPE in ('Call Center', 'LSM') then T7608.CONFIRMED_COUNT end ) as c2,
T802.NAME_LEVEL_6 as c3,
T802.NAME_LEVEL_1 as c4,
T6172.CALENDARMONTHNAMEANDYEAR as c5,
T6172.CALENDARMONTHNUMBERINYEAR as c6,
T802.DEPT_CODE as c7
from
DW_date_DIM T6736 /* z_dim_date */ ,
DW_MONTH_DIM T6172 /* z_dim_month */ ,
DW_GEOS_DIM T802 /* z_dim_dept_geo_hierarchy */ ,
DW_Count_MONTH_AGG T7608 /* z_fact_Count_month_agg */
where ( T802.DEpt_CODE = T7608.DEPT_CODE and T802.NAME_LEVEL_1 = '@{PV_D}{RSD}'
and T802.CALENDARMONTHNAMEANDYEAR = 'July 2013'
and T6172.MONTH_KEY = T7608.MONTH_KEY and T6736.DATE_KEY = T7608.DATE_KEY
and (T6172.CALENDARMONTHNUMBERINYEAR between substr('@{Month_Start}',0,6) and substr('@{Month_END}',8,13))
and (T6736.TYPE in ('Call Center', 'LSM')) )
group by T802.DEPT_CODE, T802.NAME_LEVEL_6, T802.NAME_LEVEL_1, T6172.CALENDARMONTHNAMEANDYEAR, T6172.CALENDARMONTHNUMBERINYEAR
order by c4, c3, c6, c7, c5
))where tile4=3 group by tile4
When I try to view data after creating the data set, I get the following error:
Failed to load XML
XML Parsing Error: mismatched tag. Expected: . Location: http://172.20.17.142:9704/xmlpserver/servlet/xdo Line Number 2, Column 580:
Now when I remove those Presention variables (@{PV1}, @{PV2}) in the query with some hard coded values, it is working fine.
So I know it is the PV that's causing this error.
How can I work around it?
There is no way to create equivalent report without using the direct sql..
Thanks in advanceI have found a solution to this problem after some more investigation. PowerQuery does not support to use SQL statement as source for Teradata (possibly same for other sources as well). This is "by design" according to Microsoft. Hence the problem
is not because different PowerQuery versions as mentioned above. When designing the query in PowerQuery in Excel make sure to use the interface/navigation to create the query/select tables and NOT a SQL statement. The SQL statement as source works fine on
a client machine but not when scheduling it in Power BI in the cloud. I would like to see that the functionality within PowerQuery and Excel should be the same as in Power BI in the cloud. And at least when there is a difference it would be nice with documentation
or more descriptive errors.
//Jonas -
SQL Query - store the result for optimization?
Good day experts,
I am looking for advice on a report. I did a lot of analytic functions to get core data that I need to make my report and its takes around 50 min for SQL to complete. Now with this data I need to create 3 different reports and I cant use the same SQL since there is a lot of agregation (example would be group by product in one case and by client in 2nd). For each of those different group bys I need a different report.
So how to create 3 reports from 1 SQL query without running the query 3 times?
First thing that comes to mind is to store the result set into a dummy table and then query the table since the core data I get is around 300 rows and then do different group bys.
Best regards,
IgorSo how to create 3 reports from 1 SQL query without running the query 3 times?
You already know the obvious answer - store the data 'somewhere'.
The appropriate 'somewhere' depends on your actual business requirements and you did not provide ALL of them.
MV - if the query is always the same you could use an MV and do a complete refresh when you want new data. The data is permanent and can be queried by other sessions but the query that accesses the data will be frozen into the MV definition.
GTT (global temp table) - if a NEW data load AND the three reports will ALWAYS be executed by a single session and then the data is NOT needed anymore then a GTT can work. The query that loads the GTT can be different for each run but the data will only be available for a single session and ONLY for the life of that session. So if anything goes wrong and the session terminates the data is gone.
First thing that comes to mind is to store the result set into a dummy table and then query the table since the core data I get is around 300 rows and then do different group bys.
That is commonly referred to as a 'REPORT-READY table'. Those are useful when the data needs to be permanent and available to multiple sessions/users. Typically there is a batch process (e.g. package procedure) that periodically refreshes/updates the data during an outage window. Or the table can have a column (e.g. AS_OF) that lets it contain multiple sets of data and the update process leaves existing data alone and creates a new set of data.
If your core data is around 300 rows you may want to consider a report-ready table and even using it to contain multiple sets of data. Then the reports can be written to query the data using an AS_OF value that rolls up and returns the proper data. You don't need an outage window since older data is always available (but can be deleted when you no longer need it.
If you only need one set of data you could use a partitioned work table (with only one partition) to gather the new set of data and then an EXCHANGE PARTITION to 'swap' in the new data. That 'exchange' only takes a fraction of a second and avoids an outage window. Once the swap is done any user query will get the new data. -
I'm using the LabView Database Connectivity Toolset and am using the following query...
UPDATE IndexStation
SET Signal_Size=200
WHERE 'StartTime=12:05:23'
Now the problem is that this command seems to update all rows in the table IndexStation... Not just specifically the row where StartTime=12:05:23
I have tries all sorts of {} [] / ' " around certain characters and column names but it always seems to update all rows...
I've begun to use the SQL query tab in Access to try and narrow down as to why this happens, but no luck!
Any ideas!?
Thanks,
Chris.Chris Walter wrote:
I completely agree about the Microsoft issue.
But it seems no SQL based manual states that { } will provide a Date/Time constant.
Is this an NI only implementation? Because I can't seem to get it to function correctly within LabView or in any SQL query.
Chris.
There is nothing about the database toolkit in terms of SQL syntax that would be NI specific. The database Toolkit simply interfaces to MS ADO/DAO and the actual SQL syntax is usually implemented in the database driver or database itself although I wouldn't be surprised if ADO/DAO does at times munch a bit with that too.
The Database Toolkit definitely does not. So this might be a documentation error indeed. My understanding of SQL syntax is in fact rather limited so not sure which databases might use what delimiters to format date/time values. I know that SQL Server is rather tricky thanks to MS catering for the local date/time format in all their tools and the so called universal date/time format has borked on me on several occasions.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Hi specialist's,
i have a simple question about a select, but I think I do not see the forrest becaus of too many trees ...
I have a table where timestamps are stored in seconds-since-epoch.
I select a human readble format with this statement:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog;
TIMESTAMP
19-10-2013 09:31:27
19-10-2013 09:31:27
19-10-2013 09:31:27
Now I want to filter i.e. for dates of 19-01....
My first try was this:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog
where timestamp like '19-%'
Result:
ORA-00904: "TIMESTAMP": invalid identifier
My next try was this:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog
where 1 like '19%'
Result: 0 rows!
If I change this to
... where 1 like '%'
I get all rows.
What is wrong with my selects ???Felix_GG wrote:
Hi specialist's,
i have a simple question about a select, but I think I do not see the forrest becaus of too many trees ...
I have a table where timestamps are stored in seconds-since-epoch.
I select a human readble format with this statement:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog;
TIMESTAMP
19-10-2013 09:31:27
19-10-2013 09:31:27
19-10-2013 09:31:27
Now I want to filter i.e. for dates of 19-01....
My first try was this:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog
where timestamp like '19-%'
Result:
ORA-00904: "TIMESTAMP": invalid identifier
My next try was this:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog
where 1 like '19%'
Result: 0 rows!
If I change this to
... where 1 like '%'
I get all rows.
What is wrong with my selects ???
Firstly, why not store timestamps as timestamps?
Anyway, Your first select refers to the alias 'timestamp' which is only accessible in an outer query, not from within the where clause.
Try
Select * from (
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog
where timestamp like '19-%';
But timestamp is not a good choice for an alias, as it is a keyword.
Your second select is obvious - the number 1 will never be like '19%', but it will work
in the third select: as 1 is indeed like '%' (anything). -
Generated schema on a query returns xsd:string for date data type
I'm a complete newbie to oracle's xml generation and have encountered the following problem. But first the important details:
select * from v$version
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
PL/SQL Release 10.2.0.2.0 - Production
"CORE 10.2.0.2.0 Production"
TNS for Linux: Version 10.2.0.2.0 - Production
NLSRTL Version 10.2.0.2.0 - Production
We have a large number of dynamic queries that we would like to generate xml for. I'm currently using the dbms_query.getXML(context, 2) to generate the schema definition for the columns as well as the xml row data. Currently, the problem I have is that the schema definition for date columns is being returned as xsd:string rather than xsd:date. I've no idea why it is coming back that way, and haven't found anything to point me in the direction of any configuration data where this can be changed. Here is the table and code I'm using:
query: select dbms_xmlquery.getxml('select * from clh_xml_test',2) from dual
table definition:
create table CLH_XML_TEST
ID NUMBER not null,
NAME VARCHAR2(50) not null,
DATE_COL DATE,
EMAIL_ADDRESS VARCHAR2(100) not null,
URL VARCHAR2(100) not null,
TIMESTAMP_COL DATE
Sample results:
<?xml version="1.0"?>
<DOCUMENT xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ROWSET">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ROW" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ID" type="xsd:double" minOccurs="0"/>
<xsd:element name="NAME" nillable="true" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="DATE_COL" type="xsd:string" nillable="true" minOccurs="0"/>
<xsd:element name="EMAIL_ADDRESS" nillable="true" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="URL" nillable="true" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="TIMESTAMP_COL" type="xsd:string" nillable="true" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="num" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<ROWSET xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#/DOCUMENT/xsd:schema[not(@targetNamespace)]">
<ROW num="1">
<ID>779451193</ID>
<NAME>Clh Test</NAME>
<DATE_COL>1/1/2001 0:0:0</DATE_COL>
<EMAIL_ADDRESS>[email protected]</EMAIL_ADDRESS>
<URL>http://www.google.com</URL>
<TIMESTAMP_COL>7/8/2004 10:7:4</TIMESTAMP_COL>
</ROW>
</ROWSET>
</DOCUMENT>
Thank you for your help, let me know if I can provide any additional information.
Chris
Message was edited by:
user538302use DBMS_XMLGEN.
-
Dear Sir/Mam
I want SQL query, function or SP which converts binary data to image (.jpg format).
I m able to convert image (.jpg format) to varbinary. But not able to convert vice versa.
thanks in advance.Binary data is binary data - "image" is only an intrepretation of binary data. Therefore your question makes little sense in the context of sql server since it does not have any facilities to utilize images. Since you provide no context, I'm
guessing that you are trying to retrieve an image stored in the database in a varbinary column and have your application use it as an image. If so, you should post your question to a forum that is specific to your development environment. -
How to know which sql query is taking time for concurrent program
Hi sir,
I am running concurrent program,that is taking time to execute ,i want to know which sql query causing performance
Thanaks,
SreekanthHi,
My Learning: Diagnosing Oracle Applications Concurrent Programmes - 11i/R12
How to run a Trace for a Concurrent Program? (Doc ID 415640.1)
FAQ: Common Tracing Techniques in Oracle E-Business Applications 11i and R12 (Doc ID 296559.1)
How To Get Level 12 Trace And FND Debug File For Concurrent Programs (Doc ID 726039.1)
How To Trace a Concurrent Request And Generate TKPROF File (Doc ID 453527.1)
Regards
Yoonas -
SQL query to get DDL for Adding PK.
Guys,
I'm looking for SQL query that gets me the "ALTER TABLE <TABLE_NAME> ADD CONSTRAINT <constraint_name> PRIMARY KEY (X,Y,...);" statments of all tables in my schema containing Primary Keys.
Could someone help me with the query please?
Regards,
BhagatYou need this
SELECT 'ALTER TABLE '||table_name||' ADD CONSTRAINT '||constraint_name||' PRIMARY KEY ('||column_name||');'
FROM ( SELECT uc.table_name
,uc.constraint_name
,RTRIM (XMLAGG (XMLELEMENT (ucc, column_name || ',')).extract ('//text()'), ',') column_name
FROM user_constraints uc
,user_cons_columns ucc
WHERE uc.constraint_type = 'P'
AND uc.constraint_name = ucc.constraint_name
GROUP BY uc.table_name
,uc.constraint_name
ORDER BY table_name; Regards
Arun
Maybe you are looking for
-
Month wise Closing balance of Material Wise and Batch Wise
Hi, We can get period wise closing balance for Plant-Storage Location-materials in MARDH. But i didnt find any table which can provide Plant - S.Loc - Year - Period (or Month) - Batch wise closing Balances. Can any body please suggest a table on the
-
How do I set the placementID of portlet at runtime?
Hi, I want to know the position of portlets on the page. Below is my requirement, I have 2 column layout on my page and each column has 3 different portlets. So when the first time it loads page load the page user see some portlets on each column, wh
-
How can i save the acr changes i make to jpegs (not as sidecar xmps)?
Hi Guys! I have been a full-time pro photog for 16 years and yes, yes, I always shoot in raw. Except on my cameraphone. I am on a pc. We have hundreds of pics that my family took on cameraphones on a recent cruise (when we didn't feel like lug
-
Object or Statement Block locking using synchronized keyword in java
Hi , Can anyone tell me how java is implementing the Object locking and the code block locking mechanism using the 'synchronized' keyword internally?? Thanks in advance Raj
-
What happened to the Startup Disk icon?
I've only had my MacBook Pro for about two weeks (and already seem to have screwed things up). The last couple of day I've notices that my System Preferences > Startup Disk has gone from the harddrive icon to this icon: http://symtym.com/rsc/startupd