Wildcard in select query
Hi,
I am having one requirement,
In my report i need to give cost centre in
selection screen(select-options).
Based on that i need to fetch WOGBTR from COEP table.
eg : cost center i need to give like this
imagine
select-options : s_kostl for csks-kostl.
now in s_kostl-low if i give value klnnn12345* and
in s_kostl-high if i give value klnnn12350*
now based on these input i need to write a select query in
the program to fetch the records from COEP table.
can any body please let me know how to code where condition
in the select query in this case...
Thanks and regards,
vasu
Hi Vasu,
you will reach information of the field WOGBTR in the table COEP over the criteria costcenter (KOSTL).
The costcenter isn't an attribute of table COEP, but of table CSKS.
The link between CSKS and COEP is the attribute KOKRS.
So you have to do the following steps:
1. Get the values of KOKRS from table CSKS over your select-options s_kostl (... where kostl in s_kostl)
select * into table <itab_csks> from csks
where kostl in s_skostl.
2. Build a new rangetable for KOKRS
loop at <itab_csks> into ls_csks.
lr_kokrs-sign = 'I'.
lr_kokrs-option = 'EQ'.
lr_kokrs-low = ls_csks-kokrs.
collect lr_kokrs into lrt_kokrs.
endloop.
3. Start a new query for the table COEP with your new tangetable for KOKRS
Select * into table <itab_coep> from coep
where kokrs into lrt_kokrs.
now you have the information you needed.
Greetings
Joerg
Similar Messages
-
Case-sensitive wild-cards in Select Query
Hi,
I have to make a search help for Portal like it is in standard SAP's Who's Who search help in HR-ESS.
I have to fetch data (wildcards) from Portal & on the basis of that I need to give them the actual no. of matching data.
In short, I'll take only one data, say 'Short Text of Organizational Unit' - T527X-ORGTX .... ( 'Organizational unit' - PA0002-ORGEH ).
Here, in this case, I'm converting all '*' with '%' with this statement :
ORGTX1 = ORGTX.
REPLACE ALL OCCURRENCES OF '*' IN
ORGTX1 WITH '%' .
SELECT ORGEH FROM T527X
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE ORGTX like ORGTX1
and SPRSL = 'EN'.
My problem comes, when the user enters data like HR dep and the actual data in the table is HR Department, then the select query doesn't work.
I'm providing some other cases:
Provided data by User Actual Data in Syatem
emp Employee
EMP1* Employee1
hr HR
Hr HR
so many, other permutations & combinations like this.
I've checked so many threads, but didn't get the actual answer. Some persons are saying to use translate, but I can only use translate after fetching the data. here the problem is with fetching itself & I can't judge at runtime that which letter the user will put in upper case & which in lowercase.
Can someone please guide me, how to tackle this problem ???Hello Mohit,
First of all, welcome to SDN!
What you have done as far as the implementation of the solution is concerned is quite correct. Please understand that wildcard search in SAP is case sensitive - so if the user enters data like HR dep * and the actual data in the table is HR Department then the user will not get any results back which is fully justified i.e. that's the way it should be. If you refer back to the table T527X and try a wildcard search on field ORGTX, the result is the same if you enter what the user is entering on the Portal i.e. HR dep*.
I think the users should be aware that this is how wildcard searches are designed to behave in SAP - this could be part of their training or you can even produce a message in your program when the select query fails.
The other option is of course to use TRANSLATE but there could be so many scenarios / permutation combinations - I don't suggest anyone goes that way to "guess" (or read) user's mind then deliver the solution because there will come a scenario when the program will be unable to "read" the user's mind as a result the select query will inevitably fail.
Hope this helps.
Cheers,
Sougata. -
Hi Experts,
I am having a select query in which I am using a variable in the where condition but it is giving error. Please suggest how to use variable in the select query.
The query I am using is a s below.
select * from zexc_rec into table it_ZEXC_REC
where
LIFNR in S_LIFNR and
DOCNO in S_DOCNO and
DOCTYP in doc_typ and
DATE1 in S_DATE1 and
MATNR in S_MATNR.
Here doc_typ is a variable.
Thanks.Rahul,
use RANGES type variable instead of variable . It acts as a select-options variable. Thn use this variable in SELECT query with IN.
Eg :
RANGES r_t510 FOR t510-lgart.
r_t510-low = '1600'.
APPEND r_t510.
r_t510-low = '3190'.
APPEND r_t510.
Note : can be use SIGN, OPTIONS properties too in RANGES type.
More deatils go through on HELP of RANGES
Rgds,
Ranjith -
Oracle 11g :SELECT query blocked..??
Hi Experts,
could you please explain why the below SQL query is blocked?
SELECT 1 FROM DUAL is blocking the SQL statement on GTTAPPUSR@gttccuatcriba04 ( SID=469 ) blocked SQL -> DELETE FROM GTTDB.PURCHASE_ENTRY_ID=:1
SELECT 1 FROM DUAL is blocking the SQL statement on GTTAPPUSR@gttccuatcriba04 ( SID=367 ) blocked SQL -> DELETE FROM GTTDB.PURCHASE_ENTRY_ID=:1
I am scratching my head without any solution when I had a look at the db today. Thanks in advance for your help.
Regards,
Boris
Edited by: user12075620 on Dec 4, 2012 8:58 AMThe SELECT statement is not blocking the UPDATE. As I said in the previous reply, the string that this query produces does not match the logic.
This query is (at least on the surface) correctly identifying that session 1 is blocking session 2. Session 1 holds some lock that session 2 is waiting on. So far, so good. Since session 2 is waiting on the lock, we can easily enough see what session 2 is running (the UPDATE statement). But since session 1 is not blocked, it is potentially off running a ton of other SQL statements (or no SQL statement at all). The query is looking to see what session 1 is running currently. It has no way of determining what session 1 ran at some point in the past to acquire the lock in the first place.
Going back to my KING example,
At noon, session 1 runs
UPDATE emp
SET sal = sal * 2
WHERE ename = 'KING'Session 1 now has a lock on the KING row in the EMP table. But session 1 neither commits nor rolls back, it is still in a transaction. Session 1 might not have any more activity for a long time-- the user might go off to lunch, for example (obviously, applications should not be designed to allow users to maintain open transactions indefinitely, but not all applications are designed correctly). Or it might start running other queries. Let's say that session 1 now runs a query that is going to go for an hour
SELECT *
FROM giant_view_with_lots_of_computationsNow, at 12:45, session 2 comes in and runs
UPDATE emp
SET bonus = 100
WHERE ename = 'KING'Session 2 is blocked. Session 2 is running the UPDATE statement. Session 1 still holds the lock but it is running some completely unrelated SQL statement.
If we run the query you posted, the query will correctly report that session 1 is running the query against the GIANT_VIEW_WITH_LOTS_OF_COMPUTATIONS but incorrectly imply that this SELECT query is the source of the lock. It is not. It simply happens to be the query that the session that does hold the lock happens to be executing at the current moment (why the application seems to be running a lot of queries that select a constant from dual is a separate question).
Justin -
Oracle SQL Select query takes long time than expected.
Hi,
I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
The query is as follows.
select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
Kindly advice what is going wrong??
Regards,
PurushothamSQL> @/alcatel/omc1/data/query.sql
2 ;
9 rows selected.
Execution Plan
Plan hash value: 3745571015
| Id | Operation | Name |
| 0 | SELECT STATEMENT | |
| 1 | SORT ORDER BY | |
| 2 | NESTED LOOPS | |
| 3 | NESTED LOOPS | |
| 4 | TABLE ACCESS FULL | PARAMETERTABLE |
|* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
|* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
|* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
|* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
Predicate Information (identified by operation id):
5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
6 - access("P1"."ID"="F1"."ID")
7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
8 - access("F1"."ID"="ID")
Note
- rule based optimizer used (consider using cbo)
Statistics
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
0 bytes sent via SQL*Net to client
0 bytes received via SQL*Net from client
0 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
9 rows processed
SQL> -
Select query differences between oracle 9 and oracle 8.
Hi,
I have a problem using the select query between oracle 7 and oracle 9i I don't have the same result :
ex:
With oracle7
SQL> select 'champ1','champ2' from DUAL;
'CHAMP 'CHAMP
champ1 champ2
With Oracle 9
SQL> select 'champ1','champ2' from DUAL;
'CHAMP1' 'CHAMP2'
champ1 champ2
So Can someone tell me how to solve this problem ? Is there a parameter in oracle 9 to set?
Thanx.Whenever you are posting anything over internet forums like this - you should be very careful about not just posting the details which requires to solve the problem - also should be sensible about your question.
This is not at all desired when you are posting such question. It may be because - you may not well aware of the fact.
My suggestion is -> First Go through the basics Of SQL in general.
Then go for any specific product like Oracle/ SQL Server/ Sybase etc.
And, finally learn the advanced commands of that DB.
You asked it - may be you thought the difference in output in terms of lines. But, that is not your actual output. That is the graphical display part only.
Anyway,
You can get the quite familier output by first type the following command ->
set lin 310Regards.
Satyaki De. -
Select Query resulting in Scientific Notation
Hello all,
I am running a Select query through a batch file that extracts data from an Oracle database. Several of the fields that I am extracting from contain numbers that are up to 38 digits long. When I extract the data, it converts the numbers into scientific notation and it is important for me to have the entire field. Is there something I can change to my query that will pull the data in its entire form? This is what I'm running now:
select * FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy'
I apologize in advance if this has been answered already.
Thanks!>
When the extractor finishes, it returns the data into a flat file.
don't quite understand the TO_CHAR function. Does this function mean I need to say something like this: select "TO_CHAR('column name', 99999999999999999999999999999999999999" FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy')
>
Yes- if the tool you use to extract the data (your 'extractor') is converting the numeric data to a string then it is responsible for creating the string in the proper format. If the number is an integer that can have as many digits as you have '9's in your sample format string then that is what you need to do.
Here is how sql*plus (Oracle's tool) will display the data using default settings
SQL> select 12345678901234567890123456789012345678 no_format,
2 to_char(12345678901234567890123456789012345678, '99999999999999999999999999
999999999999') with_format
3 from dual;
NO_FORMAT WITH_FORMAT
1.2346E+37 12345678901234567890123456789012345678
SQL>
----- TOAD will display something similiar but the default uses more decimal digits in the scientific notation data
NO_FORMAT,WITH_FORMAT
1.23456789012346E37, 12345678901234567890123456789012345678You can either format the numeric data in the query using TO_CHAR or the 'extractor' can do it when it converts the data to a string. -
Select-options in SELECT query - syntax error
Hi all,
I get the error below when I try to use the select options in a SELECT query . Please help me.
"The IN operator with "SO_AWART" is followed neither by an internal
table nor by a value list."
The code i have used(Logical database PNP is used):
TABLES: pernr,
catsdb.
INCLUDE ztime_cwtr_top. " global Data
INCLUDE ztime_cwtr_f01.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS SO_AWART FOR CATSDB-AWART.
PARAMETERS P_THRES TYPE I.
SELECTION-SCREEN END OF BLOCK B1.
Get data from CATSDB table. Workdates within the date interval are considered.
SELECT pernr workdate awart catsquantity beguz enduz status
FROM catsdb
INTO TABLE it_catsdb
WHERE pernr = pernr-pernr AND
workdate GE pn-begda AND
workdate LE pn-endda AND
status IN ('20', '30') AND
awart IN so_awart .
awart IN ('1100', '1137', '1138', '1139', '1140',
'1147', '1148', '1149', '1157', '2003' ).
when I give the values directly i do not get any syntax error, but when I use select options in the where condition I get the syntax error.
I have tried different options like using only the select-options in the where condition.
Thanks in advance.....
MadhuSolved.
Code with syntax error:
include z...top .
include z...fo1.
select-options: xxxxxxx
Code with no syntax error:
select-options: xxxxxxx
include z...top .
include z...fo1.
Thanks for all your help,
Madhu -
Query in Select query operation
Please excuse me for posting this again.
I'm stuck up with this for 3 days. Lenghty post pls do read and help me.
How is the select query going to be changed in the SAP so that the original database behind it understands it. I want to know the operation of IN operation in where clause where in we can use ranges.
I'm asking this because I'm facing a problem using Native SQL.
Query is like this:
EXEC SQl.
OPEN C1 for
SELECT field1 from table@domain where field2 IN :ABAP_VAR.
ENDEXEC.
EXEC SQL.
FETCH C1 NEXT INTO :VAR1 , :VAR2
ENDEXEC.
Oracle usually recognises this statement IN ( '2222' , '3658' , '6895' )
But here this field that is build dynamically like this is not recognising them as seperate fileds but instead it is taking them as a single string and not selecting anything.
But if a single value is passed it is fetching the data into the cursor. And the code is working fine.
Any help in this is highly appreciable."if a in r_range" is is effectively: does the value held in 'a' comply with the values held in range 'r_range'. Ranges can hold NE, patterns etc so this can get quite complex.
You can see that it is very different from the SQL type IN.
If your range hold several values you could unstrip it into a string varaible so that it ended up having a value something like: ( '2222' , '3658' , '6895' ). Not sure if you need the '(' but it would be something like this:
eg,
assuming your range is simple and only holds 'I' and 'EQ' values:
data v_string type string.
loop at r_range.
concatenate v_string '@''' r_range-low '''@' into v_string.
endloop.
REPLACE
ALL OCCURRENCES OF '@'
IN v_string
WITH ' '.
Then you can use:
SELECT field1 from table@domain where field2 IN :v_string. -
SELECt query in UNiX environment
Iam using hp unix with oracle 11g
when i try to spool 26 lack records it is giving me error
" There is not enough memory available now.
O/S Message: Broken pipe"
is there is any other way SQL commands, we can limit the SELECT query to spool specific number of times other than using
FOR LOOP.. with LIMIT cluaselogdata=`${SQLPLUS} -S username/password<< EOF
SET ECHO OFF
SET LINESIZE 2000
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON
SET TAB OFF
set autoprint on
set serveroutput on
set spool on
spool ${SPOOL_FILE}
set termout off
WHENEVER SQLERROR EXIT SQL.SQLCODE
whenever oserror exit 1;
$GetQuery ==> there come's the SELECT statement which spool's 25 lakh records.
spool off
EXIT
END`
While spooling records it throws the error
There is not enough memory available now.
O/S Message: Broken pipe
i want u use spooling instead of using util_file to write each and every rows in a file
Edited by: user9080289 on Apr 29, 2010 5:04 AM -
Select query in materialized view with two dblinks
Hi All,
We have oracle 10g On windows.
We are trying to create materialized view. Scenario is we have base table on other database and we are creating mview on different database.
Basa database have two schema's and i am selecting records from that two schema's using two private db links.
But when i am tryin gto create mview its not getting created. After 15 hrs. its still showing creation command and not finished.
Query is :-
Is it good practice to have two db links in select query of materialized view.Billy Verreynne wrote:
Chanchal Wankhade wrote:
Is it good practice to have two db links in select query of materialized view.Same db link being used twice, or two different db links?
If the former, you ideally want the local Oracle db to send the join to the remote database, and for the remote database to drive the join between those 2 tables. There is a hint (<i>driving_site</i>) that can be used - or the join query can be defined on the remote database as a view, and the local materialised view can then use that remote view.
If you have 2 different db links and joining across these - usually a bad idea to perform distributed database joins. There are lots of limitations as to how the tables can be joined. Worse case, full table scans of both remote tables, pulling all the rows from the 2 remote database tables to the local database, and joining these on the local database.
I have seen some severe performance issues in the past as a result of distributed joins. I'll rather use 2 materialised views for pulling both distributed tables's data locally, and then do the join on local data (using indexes, partition pruning, etc)Hi Billy,
My scenario is i have two database database A and database B. Database A is having two schema's SCOTT AND HR. SCOTT schema have select privileges on HR schema.
DB LINK is between Database B to Database A. name is db.link.B.A.oracle.com.
What if i priovide while creating materialized view, the schema name before the table name in database B for this particuler table so it will pick up the table from that schema using same DB LINK(db.link.B.A.oracle.com.) that i am using to fetch records from SCOTT schema.
Above schnario is like two base schema's and one db link using two schema. -
Select query in MB51 failing only for posting date(BUDAT)02/02/2010
Hello Experts,
I am having below select query.
It is running perfectly fine for all the dates except 02/02/2010.On all other dates it is getting executed with in second.
For 02/02/2010 it keeps on running for more than 10 minutes and then fails with timeout error.
Please let me know if anyone know any solution for this.
select (g_t_fields)
into corresponding fields of table itab
from mkpf inner join mseg
on mkpfmandt = msegmandt
and mkpfmblnr = msegmblnr
and mkpfmjahr = msegmjahr
WHERE MKPF~BUDAT in BUDAT
and MSEG~BWART in BWART
and MSEG~CHARG in CHARG
and MKPF~FRBNR in FRBNR
and MSEG~KUNNR in KUNNR
and MSEG~LGORT in LGORT
and MSEG~LIFNR in LIFNR
and MSEG~MATNR in MATNR
and MSEG~SOBKZ in SOBKZ
and MKPF~USNAM in USNAM
and MKPF~VGART in VGART
and MSEG~WERKS in WERKS
and MKPF~XBLNR in XBLNR
%_HINTS
ORACLE '&SUBSTITUTE VALUES&'
Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting and please use code tags when posting code - post locked
Edited by: Rob Burbank on Feb 4, 2010 9:02 AMHi Sameer,
Please check on which date the production order has status as "completed".
It could be on 01.02.2015.
Thanks,
Vimal -
Hi!
Is it possible to modify a select query for a report in the following way:
I have created two fields where users input values and operators.
Operators selection is a static list consisting of: =, like , in
Value field is a text field.
The current query is:
SELECT
A,
B,
C
from TABLE
I would like to add:
WHERE
A : P1_OPERATOR : P1_VALUE
but it doesn't work; I get a notification that the operator is incorrect.
It has a defaulft value = and when I set let's say 5 in the value field the whole query should be:
SELECT
A,
B,
C
from TABLE
WHERE
A = 5
Regards!Hmm, I get the following error:
Updatable report parse error:
ORA-20001: Query must begin with SELECT or WITH
The only difference I see is that your type is SQL Query (PL/SQL function body returning SQL query) while I have SQL Query (updateable report) hardcoded.
I have APEX 4.2.2, I'm not quite sure how to change this...
This is my code:
begin
:P7_QUERY := 'select ROWID,BNK_ID,MSR_PRD_ID,SRC_STM_ID,ID,ID_RETKA,RSP,OZNAKA_RETKA,DATUM_STANJA,OZNAKA_IZVJESCA,OZNAKA_KOMITENTA,MBR_KOMITENTA,KOMITENT_NEREZ,ZUPANIJA,DRZAVA,SEKTOR_NEREZIDENTA,VRSTA_POVEZANOSTI,INSTRUMENT,ISIN,VALUTA,OTKAZNI_ROK,IZVORNO_DOSPIJECE,VRSTA_INDEKSACIJE,VALUTA_INDEKSACIJE,PORTFELJ,UTRZIVOST_KREDITA,ZNACAJKE_KAPITALA,RIZICNA_SKUPINA,UGRADJENI_DERIVAT,ODNOSNA_VARIJABLA,PREDZNAK,IZNOS,IZNOS_ACTUAL,VRSTA_IZNOSA,KOMITENT_PBR,UDJELI_POVEZ_C,AR_ID,AU_ID,ACT_AR_BAL_KN,ACT_AR_BAL,AR_BUSS_ID,MTI_CCY_TP_ID,REG_NO,REG_SFX,JMBG_ID_NO,IP_ID,NO_DYS_OO,TAX_ID_NO,INSTRUMENT_OLD,PREDZNAK_OLD,IZNOS_ACTUAL_OLD,ACT_AR_BAL_KN_OLD,ACT_AR_BAL_OLD,NAPOMENA,NOVI_POSAO_F,LISTA_SUMARNA,LISTA_REKAP,POSTOTAK1,POSTOTAK2,POSTOTAK3,DZS_IDY_CL_ID,HNB_IP_CL_ID,EXG_RT_CRD_RSK_F from DWP.IZV_SLOG_DET
where ' || :P7_X_FC1 || :P7_X_O1 || :P7_X_O1;
return :P7_QUERY;
end;
I have also set Use Generic Column Names (parse query at runtime only) nad P7_QUERY as page item to submit.
Regards,
Ivan -
Select query is working on oracle 10.1.0 but its not working in 10.2.0
select query is working and retrieving some data from oracle database server 10.1.0.2.0, but same query is not working in 10.2.0.1.0 database server, its throws(ORA-00942: table or view does not exist)
But schema related tables and relevant details are same in 10.2.0.1.0 database server, so don't think that table is missing on that schema.
Note: Query length is upto 480 line
I have validate all the things, everything is fine, i don't why that query is not executing in different version.
I am in helpless in this situation?, anybody faced this issue?
Thanks in advanceValidated means all the tables and and columns are verified, i just running in sqlprompt,
Say for example:
sql> select * from table1;
One thing i observed while executing the query its showed error in one location of select sql. i mean particular word in select sql.
After that i combined some three lines of huge select sql into single then i am getting error in different location i mean different word...
My question is how same query executing in Oracle 10g Release 1, same dump (its exported from Release1) imported into oracle 10g release 2 is not executing. its shows Table or view doesn't exit. -
In oracle rac, If user query a select query and in processing data is fetched but in the duration of fetching the particular node is evicted then how failover to another node internally?
The query is re-issued as a flashback query and the client process can continue to fetch from the cursor. This is described in the Net Services Administrators Guide, the section on Transparent Application Failover.
Maybe you are looking for
-
Final Cut Pro 6.0.2 - AJA IO HD conflict
Hi, I just got a problem opening Final Cut Pro. FCP can not open and send always the same message: "Final Cut Pro quit unexpectedly. Mac OS X and other applications are not affected." It seems, in the report (see below), that the conflict is with AJA
-
How do I fix this restrictions passcode problem?
It has been two days since I posted this discussion. I have gotten over 80 views but not a single reply. I am just wondering why. Is the discussion to long? Have I violated some rule? Some changes have been made to make things a little clearer. I am
-
I MOVIE won't let me finalise the project. I am getting an error message saying.. The project could not be prepared for publishing because an error occurred. (-50) Can anyone help please and thank you! :-)
-
Quicktime Updater should ONLY be used to push updates
From a user standpoint it enrages me that you use the quicktime update application to push the use of iTunes. It is not the role of an update mechanism to push the adoption of other software but purely to distribute updates to existing applications.
-
XI Demo Configuration - problems
Dear all, I have some problems running the XI Demo. 1. CheckFlightAvailibility: While checking availibility I get this error message: Unable to check flight availability. Error Type: XI system error Error Details: Die HTTP-Destinatio