Selecting values between 2 dates for an SQL query report region
I have a region where im selecting between 2 dates
select hp.NAME, hp.VALUE, hp.UPDATEDATE, hp.DESCRIPTION, hp.UPDATE_COMMENT, hp.HASH, hp.IDCATEGORY
from HIST_REPORT hr, HIST_PARAM hp
where hp.dbid = hr.dbid and hr.id = :P7_ID and hp.UPDATEDATE between :P7_BDATE and :P7_EDATE
The problem is that if I have a row thats dated today (april 1) and if I set the beginning date (BDATE) to april 1 as well as the ending date (EDATE), no rows show and I would like the april 1 row to show. How can I modify my query to fix this?
and hp.UPDATEDATE between :P7_BDATE
and decode(:P7_EDATE,:P7_BDATE,:P7_EDATE+1,:P7_EDATE)This assumes, though, that the time component of your items is implicitly 00:00.
Joel
Similar Messages
-
SQL Query report region that only queries on first load
Hello all,
Is there any way in which you can prevent a SQL Query report region from quering data after every refresh?
I would like to make a report that queries on the first load, but then I would like to change the individual values, and reload to show the change, but every time I reload the page the columns are queried and the original values are displayed once again...
any ideas?
-MuxChet,
I created a header process to create the HTMLDB_COLLECTION. It is something like:
HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY(
p_collection_name => 'Course_Data',
p_query => 'SELECT DISTINCT COURSE_ID, HTMLDB_ITEM.CHECKBOX(14,COURSE_ID) as "checker", TITLE, SUBJECT, COURSE_NUMB, SECTION, ENROLLED, null as "temp_term", null as "temp_title", null as "temp_crse_id", null as "temp_subj", null as "temp_crse_numb", null as "temp_sect", FROM DB_TBL_A, DB_TBL_B, DB_TBL_C, DB_TBL_D, DB_TBL_E, DB_TBL_F WHERE ...');
The names were changed, for obvious reasons.
I then created an SQL Report Region to see if it would work. The SQL is:
SELECT c001, c002, c003
FROM htmldb_collections
WHERE collection_name = 'COURSE_DATA'
When I run the page it says:
ORA-20104: create_collection_from_query Error:ORA-20104: create_collection_from_query ExecErr:ORA-01008: not all variables bound
Any idea why this is happening?
I'm new to HTMLDB_COLLECTIONS, so I may be doing something wrong
-Mux -
How to Get Default Value of a Data Type in SQL Query.
Hi all,
I am creating a procedure which will take input the table name and Column Name.
In the Output i would like to have the data type and default value of that data type which will be used by a another procedure to blank the selected column in the database.
I tried with SET NULL on the column but as the database is of navision the table have property set to NOT NULL.
Here is what i have done till now.
Create Procedure Get_Column_type
@parm_table_name nvarchar(200),
@parm_column_name nvarchar(20),
@parm_result nvarchar(20)OUTPUT
AS
BEGIN
select @parm_result =
DATA_TYPE from INFORMATION_SCHEMA.COLUMNS IC
where TABLE_NAME = '[' + @parm_table_name +']' and COLUMN_NAME = '[' + @parm_column_name + ']'
END
GO
Now instead on write a case statement for so many data types in SQL, i was thinking is it possible someway that above procedure also returns the default value which i can set in another procedure.
Let me know if its possible or not? Thanks in advance.Do you looking for something like this?
create table t10 ( c int default 1)
SELECT so.name AS table_name,
sc.name AS column_name,
sm.text AS default_value
FROM sys.sysobjects so
JOIN sys.syscolumns sc ON sc.id = so.id
LEFT JOIN sys.syscomments SM ON sm.id = sc.cdefault
WHERE so.xtype = 'U'
AND SO.name = 't10'
ORDER BY so.[name], sc.colid
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Displaying a radio group in SQL QUERY report region
Good morning everyone,
I have a report in which a column - ORDER STATUS, will come in with a value of 1, 2 or 3...being order unfilled, order partially filled, or order filled, respectively.
I would like to display the order status as a radio group on the report so that it will be easy to run down the column of radio buttons to see what is filled, etc.
I've gone to the manual and checked the doco on HTMLDB_ITEM.RADIOGROUP. But the example given there is actually for CHECKBOX (is this an error?!?).
I went to the forums and found nothing suitable.
My region is an SQL QUERY. Can I display the STATUS as a radio group in the SELECT ?
This is the question.
Thankyou in anticipation. TC. 23/11/2004Tony,
There may be better solutions, but here's what I was thinking: create table orders (id number, status number, customer varchar(30))
insert into orders (id,status,customer) values(1,1,'ACME')
insert into orders (id,status,customer) values(2,2,'BENSON')
insert into orders (id,status,customer) values(3,3,'CLARKE')
commit
Query Source
select
id "ORDER NUMBER",
decode(status,
1,htmldb_item.RADIOGROUP(1,status,'1','unfilled')||htmldb_item.RADIOGROUP(2,status,'2','partial','"disabled=true"')||htmldb_item.RADIOGROUP(3,status,'3','filled','"disabled=true"'),
2,htmldb_item.RADIOGROUP(1,status,'1','unfilled','"disabled=true"')||htmldb_item.RADIOGROUP(2,status,'2','partial')||htmldb_item.RADIOGROUP(3,status,'3','filled','"disabled=true"'),
3,htmldb_item.RADIOGROUP(1,status,'1','unfilled','"disabled=true"')||htmldb_item.RADIOGROUP(2,status,'2','partial','"disabled=true"')||htmldb_item.RADIOGROUP(3,status,'3','filled'))
"STATUS",
customer "Customer Name"
from orders;Scott -
SQL Query (report region) without full page reset
Hello,
I have a page with several items, some of them with default values, and a report region, performing SQL query based on one of the items text field (always submits page when Enter pressed). When the page submits, the HTML DB engine performs and display the query, but at the same time, reset the other page items to their default values.
Is it possible to run the query without the HTML DB reset the item values to their default state?
Thanks,
Arie.Hi Peter,
Well, this is not exactly the case. I have an Item File Browse which defined as "Only when current value in session state is null", and a HTML text region, which contain Iframe, with default src tag (which I'm changing, using JavaScript, prior to the running of the SQL query). After running the query in a report region both the item and the Iframe reset to their original state.
Any Ideas on how to prevent that?
Thanks,
Arie. -
How do you select a clob column in an SQL query report?
I must be missing something fundamental as there is practically no help on this on the forum.
All I want to do is ...
select numcol,aclob_col from table
in an SQL Query report.
Sounds easy??? I get no data appearing in the clob column. Doesn't work in SQL Workshop either. What's the catch??
regards
Paul PPaul,
It works when I try it. What version of Application Express, what is the table DDL, the exact query, and how much data is in the clob columns?
Scott -
Between specific dates per month SQL
All,
I am creating a query that I need to pull between certain dates for each month. If this was a one time thing, I could do the simple between call, but.... What I am trying to do is have a query from our system run at the end of each month to pull the pay period dates. For example, for a pay run period between 24-JAN-2012 and 23-FEB-2012 the query would pull those dates at the end of FEB, and the same for end of MAR that would pull between 24-FEB-2012 and 23-MAR-2012,
and so on, and so on.
CREATE TABLE ps_paycal
(emplid NUMBER (6) PRIMARY KEY
, name VARCHAR2 (12)
, frozen_dt date
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','24-JAN-2012');
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','23-FEB-2012');
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','24-FEB-2012');
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','23-MAR-2012');
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','24-MAR-2012');
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','23-APR-2012');
Hope this makes sense. Anyway, this is Oracle 11g.
Thanks for the help!
KarstenKarsten Hilton wrote:
All,
I am creating a query that I need to pull between certain dates for each month. If this was a one time thing, I could do the simple between call, but.... What I am trying to do is have a query from our system run at the end of each month to pull the pay period dates. For example, for a pay run period between 24-JAN-2012 and 23-FEB-2012 the query would pull those dates at the end of FEB, and the same for end of MAR that would pull between 24-FEB-2012 and 23-MAR-2012,
and so on, and so on.
CREATE TABLE ps_paycal
(emplid NUMBER (6) PRIMARY KEY
, name VARCHAR2 (12)
, frozen_dt date
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','24-JAN-2012');
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','23-FEB-2012');
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','24-FEB-2012');
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','23-MAR-2012');
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','24-MAR-2012');
INSERT INTO ps_employees (emplid,name,date)
VALUES (111111,'JOHN DOE','23-APR-2012');
Hope this makes sense. Anyway, this is Oracle 11g.
Thanks for the help!
KarstenWell, assuming that's a constant (the pay period start date being the 24th of the previous month) you could do something like this to get your pay period start / end dates.
select pay_start, add_months(pay_start, 1) - 1
from
select to_date(to_char(add_months(sysdate, -1), 'yyyy-mm') || '-24', 'yyyy-mm-dd') as pay_start
from dual
) -
Selecting multiple values in a prompt for a BI Publisher report
Hi,
I selected multiple values in a prompt for a BI Publisher report and ran the report. The report run fine with single value. But it run to error with mutiliple value. The Oracle Business Intelligence Publisher version is release 11g (11.1.1).
Thanks in advance
SusanThanks for your replies !
Is there any other way to achieve this ?
There is 1 InfoObject which has 2 fields Employee and Department.
Employee Department
001 A
001 B
001 C
In the report there should be 1 row for Employee 001 with all the Departments displayed in the same cell separated by commas.
Can this be done in the backend through a ABAP code? -
Hi Team,
I am looking for an SQL query to check the data (ECC + CallVariable) received following a RUN SCRIPT RESULT when requesting an external VRU with a Translation Route to VRU with a "Run External Script".
I believe the data are parsed between the Termination Call Detail + Termination Call Variable .
If you already have such an SQL query I would very much appreciate to have it.
Thank you and Regards
NickOmar,
with all due respect, shortening a one day's interval might not be an option for a historical report ;-)
I would recommend to take a look the following SQL query:
DECLARE @dateFrom DATETIME, @dateTo DATETIME
SET @dateFrom = '2014-01-24 00:00:00'
SET @dateTo = '2014-01-25 00:00:00'
SELECT
tcv.DateTime,
tcd.RecoveryKey,
tcd.RouterCallKeyDay,
tcd.RouterCallKey,
ecv.EnterpriseName AS [ECVEnterpriseName],
tcv.ArrayIndex,
tcv.ECCValue
FROM Termination_Call_Variable tcv
JOIN
(SELECT RouterCallKeyDay,RouterCallKey,RecoveryKey FROM Termination_Call_Detail WHERE DateTime > @dateFrom AND DateTime < @dateTo) tcd
ON tcv.TCDRecoveryKey = tcd.RecoveryKey
LEFT OUTER JOIN Expanded_Call_Variable ecv ON tcv.ExpandedCallVariableID = ecv.ExpandedCallVariableID
WHERE tcv.DateTime > @dateFrom AND tcv.DateTime < @dateTo
With variables, you can parametrize your code (for instance, you could write SET @dateFrom = ? and let the calling application fill in the datetime value in for you).
Plus joining two large tables with all rows like you did (TCD-TCV) is never a good option.
Another aspect to consider: all ECC's are actually arrays (always), so it's not good to leave out the index value (tcv.ArrayIndex).
G. -
Setting a Default Value in SQL Query Report
Hello:
We are using a SQL Query Report to provide a mass update to a table. We are using the apex.collection and having it display a number of records in a SQL Query Report for mass update. We have 14 columns in the report, for which the first 11 are populated via the collection. The remaining 3 are open for input but the individual making the updates. We've were able to provide a default value for 2 of the remaining 3 columns using a named LOV's - however the fourth column we would like to default a sysdate - but we are not successful.
We've attempted many things but none seem to work, including adding that column to the collection and assigning it a default sysdate value. We've also tried changing the settings in the report attributes --> Tabular Form Elements by setting the Display as to: Datepicker, Default type to PL/SQL Expression and setting the default to sysdate. We've also tried caputuring a date on the previous page and loading it onto the report page and trying to default the date column to a page item default.
I'd appreciate any help.
Thanks
FYI - we are using version 3.2use as default
to_char(sysdate, 'dd/mm/yyy') where the format is your application or item date format -
Can we use Data Pump to export data, using a SQL query, doing a join
Folks,
I have a quick question.
Using Oracle 10g R2 on Solaris 10.
Can Data Pump be used to export data, using a SQL query which is doing a join between 3 tables ?
Thanks,
AshishHello,
No , this is from expdp help=Y
QUERY Predicate clause used to export a subset of a table.
Regards -
Hi All,
I am looking for an SQL query to request the HDS database to find out which Directory Number / instrument was associated with a specific CTI OS agent login ID.
Has anyone done such a query before ?
Thanks and Regards
NickHi,
this should work in 8.0 and 8.5:
SELECT
ag.PeripheralNumber AS [LoginID],
al.Extension,
al.LogoutDateTime
FROM [instance]_hds.dbo.Agent_Logout al
JOIN [instance]_awdb.dbo.Agent ag ON al.SkillTargetID = ag.SkillTargetID
Of course, replace [instance] with the ICM instance.
The query returns a table with three columns, first is the login ID aka PeripheralNumber, Extension is... well, the agent's extension, and LogoutDateTime is the timestamp when the agent logged out.
G. -
SELECT records larger than date specified in sub query
Dear All
Thank you for your attention.
I would like to select records larger than date specified in sub query
query should be something like the following
SELECT my_order_number, my_date, my_task
FROM MYTB
WHERE my_order_number IN order_no AND my_date > date (SELECT order_no, date FROM MySubQueryResult)
(it is incorrect)
Sub query result:
order_no | date
A1 | 2014-12-21 09:06:00
A2 | 2014-12-20 09:07:00
A3 | 2014-12-20 08:53:00
A4 | 2014-12-20 08:57:00
MYTB:
my_order_number | my_task | my_date
A1 | T1 | 2014-12-21 09:06:00
A1 | T2 | 2014-12-22 10:01:00
A2 | T1 | 2014-12-20 09:07:00
A3 | T2 | 2014-12-20 08:53:00
A3 | T4 | 2014-12-21 09:30:00
A3 | T8 | 2014-12-23 20:32:00
A4 | T6 | 2014-12-20 08:57:00
expected result:
my_order_number | my_task | my_date
A1 | T2 | 2014-12-22 10:01:00
A3 | T4 | 2014-12-21 09:30:00
A3 | T8 | 2014-12-23 20:32:00
Any ideas? Thanks.
swivanHi,
try this
SELECT my_order_number, my_date, my_task
FROM MYTB
WHERE my_order_number IN (SELECT order_no FROM MySubQueryResult)
AND my_date > (SELECT date FROM MySubQueryResult)
Alternatively, you can also make use of joins to achieve the same.
Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
Praveen Dsa | MCITP - Database Administrator 2008 |
My Blog | My Page
Dear Praveen Dsa
Thanks for your reply, but order_no and date are paired and related, cannot separate.
each order have its own date, so it is not working
Best Regards
swivan -
How to show the VALUE as the Column Header using SQL query?
Hi
I have a requirement to show the picked value as the column header using SQL query.
Example:
======
SELECT EMPNO FROM EMP
WHERE EMPNO=7934;
Result Should be:
7934
7934I have a requirement to show the picked value as the column header using SQL query.In sql*plus you can do
SQL> set verify on
SQL> def e = 7934
old: SELECT empno "&&e" FROM emp WHERE empno = &&e
new: SELECT empno "7934" FROM emp WHERE empno = 7934
SQL> SELECT empno "7934" FROM emp WHERE empno = 7934
7934
7934
1 row selected. -
SQL Query Report (Customize link)
I have an SQL query report with bind variables so that users can choose conditions for the query. If I don't have any conditions, the report is empty. How do I get it to display all the records. I tried typing * but it didn't work.
Basically I want it to act like the Query Wizard's Customize feature. The report give me all the records. I can query one field or all the fields.
In the SQL report's Customize feature, I have to enter a value for all the bind variables I have. What if I just want to query one field. What do I put in the others to indicate that I want all. I hope this makes some sort of sense and that someone out there knows what I'm blabbing about.Hi,
I h've same type of requirement in most of my reports in the application and I h've solved this in the sql of the report itself. Let's see a example report from the table scott.emp with a sql like
Select EMPNO,
ENAME,
JOB,
MGR,
HIREDATE,
SAL,
DEPTNO
From scott.emp
Where EMPNO = nvl(:v_empno,EMPNO)
and DEPTNO = nvl(:v_deptno,DEPTNO)
where :v_empno and :v_deptno are bind variables to this report and if there is no arguements passed to these arguements all the records will be retrieved from the table ..likeley if value for any one of these arguements is passed then this sql will return only those records which meet that condition.
Hope this helps
-Krishnamurthy
Maybe you are looking for
-
Questions in regard to a "stepped" migration
We are moving from an existing Tree to a new tree but we are doing it in steps. As the users move from the old tree to the new tree I would like to move them to Groupwise in the new tree. Can someone give me some advise on how best to go about this?
-
How to creat navigation pane or tabs in a document
Dear Friends! I have prepared my thesis report having different chapters, each chapter has various sections. I want to create a navigation pane (just like tabs, a tab for each chapter and sub-tabs after opening a specific chapter) for my thesis, beca
-
H.264 streaming on SAFARI
Hello guys. I am a university student and I am doing a project regard of getting live stream from IP camera via vlc and send it to a particular browser using HTML5 video player (Projekktor and VideoJS). Basically I receive RTSP live streaming from IP
-
Sections and Titles in Slideshow
I hope to be putting together a slideshow covering about 600 pics from a trip. Would like to "chapter" or section out and title each location, to identify what the viewer is looking at, e.g. Ketchican, Sitka, (you guessed it - - an Alaska cruise). Do
-
Switching from Parallels to Fusion. How hard is it?
I'm strongly considering switching from Parallels, which I currently use, to Fusion. However, I do not want to open myself up to a mind numbing, drive to drink experience. Has anybody made this switch? How hard is it? The only thing I use Parallels f