Selecting dates from friday till sunday???
Hello folks,
Am trying to work on a query where there is a date selection in the where clause. i.e if sysdate is monday i have to get the data from friday until Sunday.
and sh.change_date >=
to_date('20110304 000000', 'YYYYMMDD HH24MISS')
and sh.change_date <=
to_date('20110306 235959', 'YYYYMMDD HH24MISS')Now am hardcoding the dates that i want to see in the change_date. But Is there any way that every time when i run the query i dont have to change these date values??
Thanks a Bunch!
Please see the following
SQL> SELECT * FROM TEST_A;
ID COL CHANGE_DA
1 A 04-MAR-11
2 A1 03-MAR-11
3 A1 04-MAR-11
5 A1 06-MAR-11
6 A1 05-MAR-11
7 A1 07-MAR-11
6 rows selected.
--Today is monday so ruuning as of today.
SQL> SELECT *
2 FROM test_a
3 WHERE TRUNC (change_date) BETWEEN DECODE (TRIM (TO_CHAR ( SYSDATE, 'DAY')),
4 'MONDAY', TRUNC (SYSDATE) - 3,
5 TRUNC (SYSDATE) - 1)
6 AND TRUNC (SYSDATE) - 1;
ID COL CHANGE_DA
1 A 04-MAR-11
3 A1 04-MAR-11
5 A1 06-MAR-11
6 A1 05-MAR-11
--Running as of tomorrow i.e tuesday. So adding 1 to all SYSDATE's
SQL> SELECT *
2 FROM test_a
3 WHERE TRUNC (change_date) BETWEEN DECODE (TRIM (TO_CHAR ( SYSDATE+1, 'DAY')),
4 'MONDAY', TRUNC (SYSDATE+1) - 3,
5 TRUNC (SYSDATE+1) - 1)
6 AND TRUNC (SYSDATE+1) - 1;
ID COL CHANGE_DA
7 A1 07-MAR-11
SQL> Hope this helps.
G.
Similar Messages
-
Error while selecting date from external table
Hello all,
I am getting the follwing error while selecting data from external table. Any idea why?
SQL> CREATE TABLE SE2_EXT (SE_REF_NO VARCHAR2(255),
2 SE_CUST_ID NUMBER(38),
3 SE_TRAN_AMT_LCY FLOAT(126),
4 SE_REVERSAL_MARKER VARCHAR2(255))
5 ORGANIZATION EXTERNAL (
6 TYPE ORACLE_LOADER
7 DEFAULT DIRECTORY ext_tables
8 ACCESS PARAMETERS (
9 RECORDS DELIMITED BY NEWLINE
10 FIELDS TERMINATED BY ','
11 MISSING FIELD VALUES ARE NULL
12 (
13 country_code CHAR(5),
14 country_name CHAR(50),
15 country_language CHAR(50)
16 )
17 )
18 LOCATION ('SE2.csv')
19 )
20 PARALLEL 5
21 REJECT LIMIT UNLIMITED;
Table created.
SQL> select * from se2_ext;
SQL> select count(*) from se2_ext;
select count(*) from se2_ext
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04043: table column not found in external source: SE_REF_NO
ORA-06512: at "SYS.ORACLE_LOADER", line 19It would appear that you external table definition and the external data file data do not match up. Post a few input records so someone can duplicate the problem and determine the fix.
HTH -- Mark D Powell -- -
Selecting data from Multiple Partitions in a single select stmt.
Hi all,
My Database is very large & my tables are partitioned.
My question is:
1) If my data is spread across multiple partitions, is there any way to select data from multiple partitions in a single query?
If we dont mention partition name also it works fine, but perofmance wise it will be very slow. (Using EXPLAIN PLAN)
(Note:I dont want to make use of Union concept, i want to do it in a single select statement)
For ex:
qry1.sql:
select empno from emp_trans partition (P012000)
This above query(qry1.sql) will work fine.
qry2.sql:
select empno from emp_trans partition (P012000,P022000)
The above query(qry2.sql) will return will return the following error:
ORA-00933: SQL command not properly ended
If anybody has any solution for this, pls mail me immediately.
Thanks in advance
bye
nullAll my queries are dynamically generated. All my tables are also indexed partition wise based on date field. My question is, if i want to mention multiple partition names at the time of generating my query(select), then with parformance will be good. I have refered some books, inthat what they say is to use UNION concept, i dont want to use that, instead i want in a single select statement.
Thaks for ur reply
Bye
null -
How to select data from a table using a date field in the where condition?
How to select data from a table using a date field in the where condition?
For eg:
data itab like equk occurs 0 with header line.
select * from equk into table itab where werks = 'C001'
and bdatu = '31129999'.
thanks.Hi Ramesh,
Specify the date format as YYYYMMDD in where condition.
Dates are internally stored in SAP as YYYYMMDD only.
Change your date format in WHERE condition as follows.
data itab like equk occurs 0 with header line.
select * from equk into table itab where werks = 'C001'
and bdatu = <b>'99991231'.</b>
I doubt check your data base table EQUK on this date for the existince of data.
Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
data itab like equk occurs 0 with header line.
select * from equk into table itab where werks = 'C001'
and <b> bdatu <= '99991231'.</b>
Thanks,
Vinay
Thanks,
Vinay -
How to select data from a table by passing document number from another tab
How to select data from a table by passing document number from another table.
for eg:-
I want to display name, adres, region from ADRC table
by using field delivery document number
Kind Regards,
Shanbagavalli.SHi Shanbagavalli,
There are multiple solutions to this questions a few i will try to answer and then you can take the best required for your requirements.
**Consider that you have a Internal table having document number from other table..
SELECT NAME ADRES REGION FROM ADRC
INTO IT_ADRC
FOR ALL ENTRIES IN IT_DOC
WHERE DOCUMENT_NO = IT_DOC-DOCUMENT_NO.
**Consider that you have 1 document number then
SELECT NAME ADRES REGION FROM ADRC
INTO IT_ADRC
WHERE DOCUMENT_NO = W_DOCUMENT_NO.
Hope this solves your problem.
Regards,
Kunjal -
How to select data from a PL/SQL table
Hi,
I am selecting data from database after doing some screening i want to store it in a PL/SQL table (temporary area) and pass it to oracle reports.
Is there any way to select the data from a PL/SQL table as a cursor. Or is there any other way of holding the temporary data and then pass it back as a cursor.
Regards
KamalA PL/SQL "table" is anything but a table. Whoever came up with this term in PL/SQL to describe what is known as dynamic arrays (the correct programming terminology that existed since the 70's if not earlier and what is used in all other programming languages I'm familiar with)... well, several descriptions come to mind and none of them are complimentary.
You cannot "select" from a PL/SQL dynamic array as it is not a table within the Oracle context of tables.
Thus you need to convert (cast) a PL/SQL dynamic array into a temporary Oracle data set/table in order to select from it. This is in general a Bad Idea (tm). Oracle tables and SQL and concurrency controls and all that are especially designed for processing data. PL/SQL arrays is a very simplistic data structure with very limited usage. Why would you want to use that in SQL via a SELECT statement when you can use Oracle tables (or proper temp tables) instead? Besides that, it is also slow to cast a dynamic PL/SQL array into an Oracle SQL data set structure (context switching, copying of memory, etc).
The proper way to use PL/SQL to generate data sets for use via the SQL engine is pipelined table functions.
This is not to say that you should never use PL/SQL arrays and casting in SQL.. simply that you need to make sure that this is the correct and scalable way to do it. And that will also always be an exception to the rule when you do. -
Selecting data from external table
Hi there
I was wondering if somebody could assist me. When I try to select data from an external table, no data is displayed, and in my log file I receive the following error:
KUP-04026: field too long for datatype. Please find attached my external table script.
CREATE TABLE DEMO_FILE_EXT
MACODE NUMBER(7),
MANO NUMBER(7),
DEPNO VARCHAR2(2 BYTE),
DEPTYPE NUMBER(5),
STARTDATE NUMBER(8),
ENDDATE NUMBER(8),
OPTIONSTART NUMBER(8),
BENEFITSTART NUMBER(8),
STARTSUSPEND NUMBER(8),
ENDSUSPEND NUMBER(8),
INITIALS VARCHAR2(5 BYTE),
FIRSTNAME VARCHAR2(20 BYTE),
SURNAME VARCHAR2(25 BYTE),
STR1 VARCHAR2(30 BYTE),
STR2 VARCHAR2(30 BYTE),
STR3 VARCHAR2(30 BYTE),
STR4 VARCHAR2(30 BYTE),
SCODE VARCHAR2(6 BYTE),
POS1 VARCHAR2(30 BYTE),
POS2 VARCHAR2(30 BYTE),
POS3 VARCHAR2(30 BYTE),
POS4 VARCHAR2(30 BYTE),
PCODE VARCHAR2(6 BYTE),
TELH VARCHAR2(10 BYTE),
TELW VARCHAR2(10 BYTE),
TELC VARCHAR2(10 BYTE),
IDNUMBER VARCHAR2(13 BYTE),
DOB NUMBER(8),
GENDER VARCHAR2(1 BYTE),
EMPLOYER_CODE VARCHAR2(10 BYTE),
EMPLOYER_NAME VARCHAR2(900 BYTE)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY DEMO_FILES
ACCESS PARAMETERS
( RECORDS DELIMITED BY newline
BADFILE 'Tinusb.txt'
DISCARDFILE 'Tinusd.txt'
LOGFILE 'Tinusl.txt'
SKIP 1
FIELDS TERMINATED BY '|'
MISSING FIELD VALUES ARE NULL
(MACODE,
MANO,
DEPNO,
DEPTYPE,
STARTDATE,
ENDDATE,
OPTIONSTART,
BENEFITSTART,
STARTSUSPEND,
ENDSUSPEND,
INITIALS,
FIRSTNAME,
SURNAME,
STR1,
STR2,
STR3,
STR4,
SCODE,
POS1,
POS2,
POS3,
POS4,
PCODE,
TELH,
TELW,
TELC,
IDNUMBER,
DOB,
GENDER,
EMPLOYER_CODE,
EMPLOYER_NAME
LOCATION (DEMO_FILES:'Test1.txt')
REJECT LIMIT UNLIMITED
LOGGING
NOCACHE
NOPARALLEL;
I have the correct privileges on the directory, but the error seems to be on the EMPLOYER_NAME field. The file I try to upload is in pipe-delimited format. The last field in the file does not have a pipe-delimiter at the end. Can this be the problem? Must I go and look for any trailing spaces? Can I specify in the external table script how many characters I need for the employer_name field? We receive this file from an external company
Thank you very much for the help
Ferdiecommon mistake, you gave the field sizes in the
column listing of the table, but not in the file
definition. oracle does not apply one to the other.
in the file defintion section, give explict field
sizes.Hi shoblock
Sorry for only coming back to you now, thank you for your help, I had to give the explicit field size for the last column (employer name).
Thank you once again!!
Ferdie -
Select data from ORacle in an orchestration
Hi,
I am looking for an example of orchestration with two way send port. The orchestration should select data from an oracle DB using input to orchestration. Based on the query results, orch has different paths to follow.
Can someone please point me to an example/sample or let meknow what is the best way to do it?
Thanks in advance.
SRGHi ,
You can go ahead with Oracle Polling which have a select statement against the DB.
There is a good post from Bali which i am listing below
dpsbali-biztalkweblog.blogspot.in/2011/10/polling-using-biztalk-wcf-oracle.html
http://pellitterisbiztalkblog.wordpress.com/2013/07/01/polling-oracle-database-using-stored-procedures-functions-or-packaged-procedures-and-functions/
There is also a MSDN link available for this
http://msdn.microsoft.com/en-in/library/dd788467.aspx
Thanks
Abhishek -
Select data from two tables...!
HI Experts...!
i m a beginner user and i want to select data from two tables proj and prps.....using joins.....and internal tables i have written a code...
SELECT prps~pspnr
prps~objnr
prps~psphi
proj~ernam
proj~erdat
proj~pspnr
INTO table itab -
itab is internal table
FROM prps inner join proj
WHERE pspnr in p_no and prpspsphi = projpspnr.
but there is error in from clause ..please help me....
Advance thanx....Hi,
check the sample code bellow above two reply will solve out your problem but one more extra line in your code pointed out bellow.
TABLES: prps, proj.
TYPES: BEGIN OF ty_test,
pspnr LIKE prps-pspnr,
objnr LIKE prps-objnr,
psphi LIKE prps-psphi,
ernam LIKE proj-ernam,
erdat LIKE proj-erdat,
END OF ty_test.
DATA: itab TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.
SELECT-OPTIONS: p_no FOR prps-pspnr.
SELECT prps~pspnr
prps~objnr
prps~psphi
proj~ernam
proj~erdat
* proj~pspnr " No need for this you have selected this in
* the first line because it is commone so you only need to select from any one
INTO TABLE itab
FROM prps INNER JOIN proj ON ( prps~pspnr = proj~pspnr )
WHERE prps~pspnr IN p_no.
Best Regards,
Faisal
Edited by: Rob Burbank on Dec 24, 2009 12:24 PM -
Select data from table where field is initial
I have table that has 10 million records.
I want to select data from this table where certain date field is blank.
*SELECT * FROM table*
INTO TABLE internal table
WHERE PSTNG_DATE = BLANK.
Does anybody know how to select data from data base table when certain field is blank.
I cont select all data once and delete which i dont want, the table is big, it will blow up app server.
thanks in advance,
Sachin
Moderator: Pls do not lock the posting instead provide me the link, its disrespecting.Respect the forum rules and common sense, and you will be respected.
"how to select data from a database table when the field is blank" is very basic, and basic questions will be locked, because they have been asked many times and you can find the answer yourself with a little effort. There is nothing disrespectful about it.
Thread locked.
Thomas -
Select data from view ( V_T856 ).
Hi All,
i need to download transaction type and text from V_T856 , but the data is not selected from V_T856 view.
how to select data from a view, is there any special conditions.
i declared V_T856 in tables statement, even though select statement not exicuted.
pls suggest me with relevant information..
thank you
Regards
Ramesh.hi ramesh,
using Select statement you cannot retrieve the data from view.
use the FM - VIEW_GET_DATA.
call function 'VIEW_GET_DATA' " func. mod to get data from maintenance view.
exporting
view_name = view
tables
data = gt_data.
Regards,
Sakthi. -
Select Data from 2 intern tables
Hi Experts,
how I can select Data from 2 intern Tables into another intern table?
For Example:
My Result Table has the fields: mandt, user, ID, ID_Name.
My select table no. 1 has the fields mandt, XYZ (like A_Name), ID, ID_Name, ...
My select table no. 2 has the fields mandt, A_Name, User, ...
I want to search for all entries in select table no. 1 and 2. where are a_name have the same worth.
How I can select my Dates?
Regards,
Mikehii
you can do it by using for all entries and with READ statement ..do like follow code
IF i_marc[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
lgort " Storage Location
FROM mard
INTO TABLE i_mard
FOR ALL ENTRIES IN i_marc
WHERE matnr EQ i_marc-matnr
AND werks EQ i_marc-werks
AND lgort IN s_lgort.
ENDIF. " IF i_mara[] IS NOT INITIAL
IF sy-subrc EQ 0.
LOOP AT i_output INTO wa_output.
READ TABLE i_mard INTO wa_mard WITH KEY matnr = wa_output-matnr.
wa_output-lgort = wa_mard-lgort.
MODIFY i_output FROM wa_output.
CLEAR wa_output.
ENDLOOP. " LOOP AT i_output
ENDIF. " IF sy-subrc EQ 0
regards
twinkal -
Select data from Table1 based on Table2
Hi Guys,
Can you guide me up on how to select data from Table1 based on Table2?
I want to fetch data which is not there in table2 in my table1 select query.
Is that I have to do it with the loops after I select data from both tables or can it be handled directly in my select query?
Please suggest.
Regards,
Kumar.hi
Try This
In Where condition filedname (Not Equal) < > itab2-fieldname.
select * from itab1
into table lt_tab.
seect * from itab2
into table lt_tab
for all entries in lt_tab
where name < >(Not Equal to)itab2-fieldname. -
Select data from database tables with high performance
hi all,
how to select data from different database tables with high performance.
im using for all entries instead of inner joins, even though burden on data base tables is going very high ( 90 % in se30)
hw to increase the performance.
kindly, reply.
thnksAlso Check you are not using open sql much like distict order by group by , use abap techniques on internal table to acive the same.
also Dont use select endselect.
if possible use up to n rows claus....
taht will limit the data base hits.
also dont run select in siode any loops.
i guess these are some of the trics oyu can use to avoid frequent DATA BASE HITS AND ABVOID THE DATA BASE LAOD. -
Select data from BKPF for a date range
Hi,
I want to select data from BKPF depending upon the date range given in the selection screen.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
" Selection Criteria
SELECT-OPTIONS : S_DATE FOR SY-DATUM OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK B1.
How do I do that??.. Please help.
Thank You,
SB.HI SB,
Create Indexes and select the data ...
i.e,
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
" Selection Criteria
<b>SELECT-OPTIONS : S_DATE FOR BKPF-BLDAT OBLIGATORY.</b>
SELECTION-SCREEN : END OF BLOCK B1.
<b> SELECT * FROM BKPF WHERE BLDAT IN s_date.</b>
Regards,
Santosh P
Message was edited by: Santosh Kumar Patha
Maybe you are looking for
-
Flash won't install - HELP!!
Hi All, I'm running Windows Vista and had some trouble the other day with Adobe Flash - so I disabled it in the add-on tab. Then I rebooted and reinstalled it. Supposedly, it reinstalled successfully and was now listed as enabled in the add-on tab. E
-
Setting the default display (monitor)
I use my TV as my second monitor to stream Netflix. If I'm watching something in a separate window and close out/shut down for the night FF will default to the TV instead of the active monitor (I don't keep the TV on all the time). This happens even
-
Just recently my display on my macbook pro i5 has started behaving oddly [IMG]http://i165.photobucket.com/albums/u77/lewis1989_2007/Screenshot2010-11-16at2019 15.png[/IMG] just wondered if anyone knows what could be causing this and how to fix it Tha
-
Hi, I have a concern about document server. We need to create the document server via watched folder concept. Is there any option in the document server like Livecycle PS to PDF Generator? Regards, Subbu
-
New Mac Pro not really working
I just got my new Mac Pro in and I'm having some problems. I've had to do a hard reboot 3 times over the last 4 days, I get the SBBOD very frequently, and Spotlight doesn't seem to be working. My biggest issue with spotlight now is I can't get one of