How to display contineous 10 dates from today date using SQL query
Hi All
I need a requirement of displaying 10 dates and numbers contineously, I have written a query for getting 10 numbers like this
select rownum from dual where rownum < 10 connect by rownum = level;
But i am not able to get the dates, Can any one help me ?
Hi Satyaki,
No issues on my 9.2.0.8 client.
SQL*Plus: Release 9.2.0.8.0 - Production on Sat May 3 09:49:17 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> conn test/test@db10g
Connected.
SQL> select rownum, trunc(sysdate) + rownum from dual where rownum <= 10 connect by rownum = level;
ROWNUM TRUNC(SYS
1 04-MAY-08
2 05-MAY-08
3 06-MAY-08
4 07-MAY-08
5 08-MAY-08
6 09-MAY-08
7 10-MAY-08
8 11-MAY-08
9 12-MAY-08
10 13-MAY-08
10 rows selected.
SQL> Regards
Similar Messages
-
How to retrive the blob data from a table using sql query
Hi gurus,
I have a table which has " BLOB "content in a column .I want to view the data From BLOB column using sql query .It would be helpfull If some one share their idea.
Regards,
vardhani.You can use data templates.
See this: http://blogs.oracle.com/xmlpublisher/entry/blob_clob_raw_and_looooong
http://blogs.oracle.com/xmlpublisher/entry/inserting_blobs_into_your_repo
Thanks,
Bipuser -
How can I validate a date using sql
How can I validate a date using sql or pl/sql
select to_date('01/01/2009','mm/dd/yyyy') from dual this is a good date
but how can I check for a bad date
select to_date('0a/01/2009','mm/dd/yyyy') from dual
HowardWilliam Robertson wrote:
It'll be complicated in pure SQL, as you'll have to parse out day, month and year and then validate the day against the month and year bearing in mind the rules for leap years. It would be simpler to write a PL/SQL function and call that.Nah, not that complicated, you just need to generate a calender to validate against.
SQL> ed
Wrote file afiedt.buf
1 with yrs as (select rownum-1 as yr from dual connect by rownum <= 100)
2 ,mnth as (select rownum as mn, case when rownum in (4,6,9,11) then 30
3 when rownum = 2 then 28
4 else 31
5 end as dy
6 from dual
7 connect by rownum <= 12)
8 ,cent as (select (rownum-1) as cen from dual connect by rownum <= 21)
9 ,cal as (select cen, yr, mn,
10 case when ((yr = 0 and mod(cen,400) = 0)
11 or (mod(yr,4) = 0 and yr > 0))
12 and mn = 2 then dy+1
13 else dy
14 end as dy
15 from cent, yrs, mnth)
16 --
17 ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
18 --
19 select case when cal.cen is null then 'Invalid Date'
20 when not regexp_like(dt,'^[0-9]{1,2}[\/.-_][0-9]{1,2}[\/.-_][0-9]{4}$') then 'Invalid Date'
21 else dt
22 end as dt
23 from dt left outer join
24 cal on (to_number(regexp_substr(dt,'[0-9]+')) between 1 and cal.dy
25 and to_number(regexp_substr(dt,'[0-9]+',1,2)) = cal.mn
26 and floor(to_number(regexp_substr(dt,'[0-9]+',1,3))/100) = cal.cen
27* and to_number(substr(regexp_substr(dt,'[0-9]+',1,3),-2)) = cal.yr)
SQL> /
Enter value for date_dd_mm_yyyy: a1/02/2008
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select 'a1/02/2008' as dt from dual)
DT
Invalid Date
SQL> /
Enter value for date_dd_mm_yyyy: 01/02/2008
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '01/02/2008' as dt from dual)
DT
01/02/2008
SQL> /
Enter value for date_dd_mm_yyyy: 29/02/2008
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '29/02/2008' as dt from dual)
DT
29/02/2008
SQL> /
Enter value for date_dd_mm_yyyy: 30/02/2008
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '30/02/2008' as dt from dual)
DT
Invalid Date
SQL> /
Enter value for date_dd_mm_yyyy: 29/02/2009
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '29/02/2009' as dt from dual)
DT
Invalid Date
SQL> /
Enter value for date_dd_mm_yyyy: 28/02/2009
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '28/02/2009' as dt from dual)
DT
28/02/2009
SQL> /
Enter value for date_dd_mm_yyyy: 0a/01/2009
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '0a/01/2009' as dt from dual)
DT
Invalid Date
SQL> /
Enter value for date_dd_mm_yyyy: 00/01/2009
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '00/01/2009' as dt from dual)
DT
Invalid Date
SQL> -
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. -
How to display table field data using checkbox
Dear sir,
I have created PR using ME51N. Our PR datas in EKPO table.
I have created select-option with prdat and Checkbox for to view PR open or closed status.
I want check PR status details from date to date using check box.
I have created the following code, but i will not generate output
DATA: BEGIN OF leban OCCURS 0.
INCLUDE STRUCTURE ekpo.
DATA END OF leban.
DATA new(1).
SELECT-OPTIONS ldat FOR sy-datum. "NO-DISPLAY.
parameters lopen like new AS CHECKBOX USER-COMMAND opn.
parameters lclose like new as checkbox user-command cls.
at selection-screen.
if ldat is initial.
message 'Enter a value' type 'W'.
endif.
case sy-ucomm.
when 'opn'.
perform getpr.
perform findopenpr tables leban.
endcase.
form getpr.
select * from ekpo into leban where PRDAT in ldat.
append leban.
endselect.
endform.
form findopenpr tables ekpo.
IF LOPEN = 'X'.
select single * from ekpo into leban where PRDAT IN LDAT AND banfn = lopen.
SORT leban BY bnfpo.
CLEAR leban.
if not sy-subrc = 0.
message 'PR OPEN' type 'S'.
ENDIF.
WRITE: / LEBAN-BANFN.
ENDIF.
endform.
With Regards,
BaskaranHi,
Try this way,
You shouldnt be writing two select statements into the same internal table. Also i dont see any use of perform getpr. so remove that and try
DATA: BEGIN OF leban OCCURS 0.
INCLUDE STRUCTURE ekpo.
DATA END OF leban.
DATA: BEGIN OF leban1 OCCURS 0.
INCLUDE STRUCTURE ekpo.
DATA END OF leban1.
DATA new(1).
SELECT-OPTIONS ldat FOR sy-datum. "NO-DISPLAY.
parameters lopen like new AS CHECKBOX USER-COMMAND opn.
parameters lclose like new as checkbox user-command cls.
at selection-screen.
if ldat is initial.
message 'Enter a value' type 'W'.
endif.
IF LOPEN = 'X'.
select single * from ekpo into leban where PRDAT IN LDAT AND banfn = lopen.
if sy-subrc = 0.
message 'PR OPEN' type 'S'.
ENDIF.
WRITE: / LEBAN-BANFN.
endif.
if LCLOSE = 'X'.
select single * from ekpo into leban1 where PRDAT IN LDAT AND banfn eq space.
if sy-subrc = 0.
message 'PR CLOSE' type 'S'.
ENDIF.
WRITE: / LEBAN1-BANFN.
ENDIF.
Regards,
Vik
Edited by: vikred on Aug 7, 2009 6:55 PM
Edited by: vikred on Aug 7, 2009 7:23 PM -
Failing to import data using SQL query
I am trying to import data from a sql query to analysis service in SSDT. i went to model > import from data source >Microsoft SQL Server and i chose from query. I typed my query which works fin in SSMS and when i press import if gives me a error. what
is going on please help here is the error
DirectQuery error: All tables used when querying in DirectQuery Mode must be from a single relational Data Source.
here is my query:
USE AdventureWorks2012;
SELECT SalesPersonID, [29484] Brian, [29485] Peter, [29486] Frank, [29518] Sarah, [29519] Janet, [29520] Alice, [29608] Martin, [29609] Patrick, [29610] Wasu, [29780] Samanyika, [29781] Vladmire
FROM
SELECT SalesOrderID, SalesPersonID, CustomerID
FROM Sales.SalesOrderHeader
WHERE SalesPersonID IS NOT NULL
As P PIVOT
COUNT (SalesOrderID) FOR CustomerID IN ([29484], [29485], [29486], [29518], [29519], [29520], [29608], [29609], [29610], [29780], [29781])
AS PVT
ORDER BY SalesPersonID ASC;Hi,
When importing data from relational data source, the steps are:
In SQL Server Data Tools (SSDT), click the Model menu, and then click Import
from Data Source.
On the Connect to a Data Source page, select the type of database to connect to, and then click Next.
Follow the steps in the Table Import Wizard. On subsequent pages, you will be able to select specific tables and views or apply filters by using the Select
Tables and Views page or by creating a SQL query on Specify a SQL Query page.
As we can see on the steps, we need to select one database, so we needn't to write "USE AdventureWorks2012" on the query.
Reference:Import from a Relational Data Source
Regards,
Charlie Liao
TechNet Community Support -
Filtering data using sql query
I am pulling data from a database which is a log of events type data. It consists of entries at a certain time, entry text, and even has an entry type. One of those types is known as "open item." This entry has the potential to be present on multiple days over and over. The problem is I only want the "open item" entries to appear that occur on the most recent day of a date range that is input by the user, but also not excluding all other entries from all of the other days that are not "open item." The "is_open=0" is what is excluding the "open items" from all of the entries, but now there needs to be a way to include (ie. "is_open=1") the "open items" on the current day. My query is as follows:
SELECT b.log_title, a.log_id, MIN(a.shift_date) AS shift_date,a.shift_id,a.operator_position_descr,a.is_open,a.user_id, MAX(a.annotation_number) AS annotation_number,
a.entry_text, MIN(a.entry_time) AS entry_time,a.font_num
FROM log_entries AS a INNER JOIN
log_list AS b ON a.log_id = b.log_id
WHERE ((entry_type_code NOT LIKE '%NLOG%'
AND entry_type_code <> 'daily'
AND entry_type_code <> 'shift act') or entry_type_code is null)
AND (is_open = 0 AND is_standing_order = 0 AND is_rolled_forward is null)
GROUP BY b.log_title, a.log_id, a.user_id,a.shift_id,a.operator_position_descr,a.is_open, a.entry_text,a.font_num
Order by entry_timeChange you WHERE clause to something like this... (You didn't say what kind of DB you were using so I used SQL Server syntax)
WHERE ((entry_type_code NOT LIKE '%NLOG%'
AND entry_type_code IN ('daily', 'shift act')) OR entry_type_code is null)
AND (is_open = 0 OR (is_open = 1 AND a.shift_date >= DateAdd(dd, DateDiff(dd, 0, GetDate()), 0)))
AND is_standing_order = 0
AND is_rolled_forward is null
The biggest change is this... AND (is_open = 0 OR (is_open = 1 AND a.shift_date >= DateAdd(dd, DateDiff(dd, 0, GetDate()), 0))).
It allows is_open = 1 if the shift_date is => midnight of the of the current day.
HTH,
Jason -
How to delete entire data from MDS UI using SQL query or Using SSIS
Hi All,
Using SSIS i loaded data in MDS UI(Subcription view),I want when i execute my package next time and load data in MDS it should be blank or data should not be in UI.Hi
please checked following url to insert data in your MDM
http://msdn.microsoft.com/en-us/library/jj819772.aspx -
How to get AD reconciliation event data using SQL query.
Hi All,
I was trying to get all recon data for Target AD Recon from OIM db, but it seems that in OIM 11g we do not have recon data in tables: RCU, RCE, etc. We have to use "RECON_..." tables, my question is does any bady has sample query to fetch data from recon tables?
best
mpIt should be a question of linking your AD user reconciliation table (beginning RA_) with the RECON_EVENTS table by RE_KEY.
In my case I have OID user reconciliation (so my RA_ table will be different to yours) and can use something like:
SELECT RECON_EVENTS.RE_STATUS, RA_OIDUSER5.* FROM RECON_EVENTS, RA_OIDUSER5 WHERE RECON_EVENTS.RE_KEY = RA_OIDUSER5.RE_KEY;
Obviously it then depends on what information you want to filter on and retrieve. -
Retreving Hexadecimal Values from a table using SQL query.
Hi,
I'm looking for a query to retreive Hexadecimal values contained in a column using SQL query.
The column contains the values of all types, alphanumeric, numeric and hexadecimal.
I need to retreive only hexadecimal values.
any help to me in this regard will be appreciated.
ThanksPresumably, you can be sure that any valid hex value is indeed MEANT to BE a hex value. For example the value 'ACE' is meant to be a hexadecimal value and not the word.
-
How to view clob data using sql
Hi,
In our database, we have one table that is having one column of CLOB datatype but now i want to view the data using sql select query but it throws error: "Datatype not supported".
Could any one please let me know how to view the clob data using select query.
Oracle DB version : 10.2.0.3
Thanksh5.
use read procedure
PROCEDURE READ (
lobsrc IN BFILE|BLOB|CLOB ,
amount IN OUT BINARY_INTEGER,
offset IN INTEGER,
buffer OUT RAW|VARCHAR2 );
example Updating LOB by Using DBMS_LOB in PL/SQL
DECLARE
lobloc CLOB; -- serves as the LOB locator
text VARCHAR2(32767):='Resigned: 5 August 2000';
amount NUMBER ; -- amount to be written
offset INTEGER; -- where to start writing
BEGIN
SELECT resume INTO lobloc
FROM employees
WHERE employee_id = 405 FOR UPDATE;
offset := DBMS_LOB.GETLENGTH(lobloc) + 2;
amount := length(text);
DBMS_LOB.WRITE (lobloc, amount, offset, text );
text := ' Resigned: 30 September 2000';
SELECT resume INTO lobloc
FROM employees
WHERE employee_id = 170 FOR UPDATE;
amount := length(text);
DBMS_LOB.WRITEAPPEND(lobloc, amount, text);
COMMIT;
END; -
How to display the current date in the prompt value.
Hi,
How to display the current date in the prompt value. When the user runs the query he want the current date to be displayed in the prompt value and he should also be able to change the date if required ...... I am using web Intellegency BO XI3.0.
Thanks,
Shakthi.Please refer the below link.
Prompt with default date ( currentdate-1 and current date-8)
http://www.dagira.com/2008/07/15/how-can-i-make-today-my-default-prompt-value/
http://www.dagira.com/2008/07/21/using-a-magic-date-value-in-prompts/
Regards,
Bilahari -
How to display a oracle table from a java program?
How to display a oracle table from a java program.
Hello friends, I have written a Java program, using oracle 10g as backend.
I want to display a oracle table as output. Im not getting how to display oracle table as a output table.. Pls help me
Thank youjayanthds, you're not going to get a satisfactory
answer to this here. it's too big a task to justbe
quickly outlined in a forum - the reply "all youneed
to do is to query you table and return it asJTable"
is worthless, for example, since the solution to
any problem can be distilled to such a
soundbite, if need be. doesn't make the solutionany
simpler
essentially you're asking "how do I write adatabase
application?". all you'll get is snippets of code
that, when fitted together, will eventually helpyou
do this, but you'll spend days and days comingback
saying "right, I've done that, now what?" until
either you or the forum gets frustrated with the
whole affair and the process stops
there are entire books written about this subject,
and countless tutorials and guides on theinternet.
you're better off going down that routehehehe.well, it's true! I used to have a manager that would outline the solution to a problem in a few lines of pseudocode, and then firmly believe that the actual solution would be just as brief and simple. shame his pseudocode included such lofty abstractions as "reformat all data" -
How to display planned movement date and actual movement date together?
Hi, Professionals,
My purpose is to list delayed outbound deliveries.
Anyone could tell me how to display planned movement date and actual movement date?
Appreciate your help.Thanks Shiva.
I tried another way to do it. It works only for a short period of time.
By using VL06O, I list all outbound deliveries by limiting both planned goods movement dates and actual goods movements dates to the same week I would like to inspect. Say both from 7th/11 to 14th/11.
then I list outbound delivery list with planned goods movement date to 7th/11 but left out actual goods movements dates this time.
In excel, I compare those two lists and filter out those unique ones because those unique documents means delayed deliveries which cannot delivery according to planned date.
However, the "delayed" list generated by this method has some noises. Not all of documents are really delayed although most of them do.
I'm also looking for a way to list sales documents number of these delayed delivery documents so i can retrieve order details from it such as order value.
Help still needed. -
Creating BOM using BDC :How to display no of records from flat file under
Hi,
How to display no of records from flat file under one (Alternative BOM) vertically.
When i execute, the records are replacing one by one.
Here my coding:
report ZBOM1
no standard page heading line-size 255.
*include bdcrecx1.
DATA: BEGIN OF bdc OCCURS 0,
matnr(18),
werks(4),
stlan(1),
END OF BDC.
DATA: BEGIN OF BDC1 OCCURS 0,
idnrk(18),
MENGE(18),
MEINS(3),
postp(1),
END OF bdc1.
DATA: BEGIN OF BDCDATA OCCURS 0,
matnr(18),
werks(4),
stlan(1),
idnrk(18),
MENGE(18),
MEINS(3),
postp(1),
posnr(4),
END OF BDCDATA.
data: ibdcdata type standard table of bdcdata WITH HEADER LINE.
*start-of-selection.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\Documents and Settings\dilipkumar.b\Desktop\soft.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ','
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = BDCDATA
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*perform open_group.
loop at bdcdata.
perform bdc_dynpro using 'SAPLCSDI' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RC29N-STLAN'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RC29N-MATNR'
'SOFTDRINKS'.
perform bdc_field using 'RC29N-WERKS'
'WIND'.
perform bdc_field using 'RC29N-STLAN'
'1'.
perform bdc_field using 'RC29N-DATUV'
'16.09.2008'.
perform bdc_dynpro using 'SAPLCSDI' '0110'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RC29K-BMENG'
'1'.
perform bdc_field using 'RC29K-STLST'
'1'.
perform bdc_field using 'BDC_CURSOR'
'RC29K-EXSTL'.
perform bdc_dynpro using 'SAPLCSDI' '0111'.
perform bdc_field using 'BDC_CURSOR'
'RC29K-LABOR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLCSDI' '0140'.
perform bdc_field using 'BDC_CURSOR'
'RC29P-POSTP(01)'.
perform bdc_field using 'BDC_OKCODE'
'=FCBU'.
perform bdc_field using 'RC29P-IDNRK(01)'
BDCDATA-IDNRK.
perform bdc_field using 'RC29P-MENGE(01)'
BDCDATA-MENGE.
perform bdc_field using 'RC29P-MEINS(01)'
BDCDATA-MEINS.
perform bdc_field using 'RC29P-POSTP(01)'
BDCDATA-POSTP.
perform bdc_dynpro using 'SAPLCSDI' '0130'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RC29P-POSNR'.
perform bdc_field using 'RC29P-POSNR'
BDCDATA-POSNR. "'0010'.
perform bdc_field using 'RC29P-IDNRK'
BDCDATA-IDNRK. "'15'.
perform bdc_field using 'RC29P-MENGE'
BDCDATA-MENGE. "'1'.
perform bdc_field using 'RC29P-MEINS'
BDCDATA-MEINS. "'ml'.
perform bdc_dynpro using 'SAPLCSDI' '0131'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RC29P-POTX1'.
perform bdc_field using 'RC29P-SANKA'
'X'.
*perform bdc_transaction using 'CS01'.
*perform close_group.
CALL TRANSACTION 'CS01' USING IBDCDATA MODE 'A' UPDATE 'S'.
REFRESH IBDCDATA.
endloop.
Start new screen *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR iBDCDATA.
iBDCDATA-PROGRAM = PROGRAM.
iBDCDATA-DYNPRO = DYNPRO.
iBDCDATA-DYNBEGIN = 'X'.
APPEND ibDCDATA .
ENDFORM.
Insert field *
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> NODATA.
CLEAR iBDCDATA.
iBDCDATA-FNAM = FNAM.
iBDCDATA-FVAL = FVAL.
APPEND iBDCDATA .
ENDIF.
ENDFORM.Hi,
the BDCDATA structure must be fnam, fval,dynbegin,dynpro,program.
You have to declare like this and pass this in your CALL TRANSACTION statement.
Please give some other table name for BDCDATA you declared for and also for IBDCDATA.
Maybe you are looking for
-
Why can't I copy text from ibooks?
I have just downloaded Mavericks and I am looking into the desktop version of ibooks. It seems like I can copy text from free books but not from a book that I bought. It is the first and only book that I have bought on ibooks. I would like to start u
-
PS CC 2014 extensions do not show
I have updated Extension Manager. I have reloaded extensions with most current (Russell Browns Paper Textures, Flypaper textures). I have checked my settings. The only extension that will who in the Extension panel (Window>Extensions) is Kuler. How c
-
Hi, I wanted to know if I could export my entire library into folders of Artists and Albums as they are listed in iTunes..and keep their artwork? I see the export library option under File, but it exports in xml which I'm assuming isn't what I want..
-
Ipod is disabled how to connect to itunes
ipod is disabled how to connect to itunes
-
I have been unable to add an HP Photosmart C4480 printer to my existing printer list using a USB connection. Software seems to be available and thought I had downloaded it, but doesn't work. Any suggestions?