Reg select query
Hi Guys,
I got a problem with select query...could you polease help me out...plz check the second select query statement
when i open tstcp table i gave Ztable and then when I exceute i am able to get the list when i do it programatically it is not working .....
any suggestions...points will be rewarded..
select tabname
from dd02l into table i_dd02l where tabname like 'Z%' and
( tabclass = 'VIEW'
or
tabclass = 'TRANSP' ) and
( mainflag = 'X'
or
mainflag = '' ).
if not i_dd02l[] is initial.
loop at i_dd02l.
v_tabna = i_dd02l-tabname.
select single tcode
param into (v_tcode , v_param)
from tstcp where param like '%v_tabna%'.
i_tstcp-tcode = v_tcode.
i_tstcp-param = v_param.
append i_tstcp.
clear i_tstcp.
endloop.
endif.
Regards,
Ravi Ganji
Hi ,
The statement will not work because it will try to find all records which has v_tabna in its field.
So what you need to do is concatenate % before and after the value of the varaible v_tabna and store it in some varaible say v_value and use it in the where clause.
so your code will look like this
*v_tabna = i_dd02l-tabname.
concatenate '%' i_dd02l-tabname '%' into v_tabna
select single tcode
param into (v_tcode , v_param)
from tstcp where param like tabna.
Regards
Arun
Similar Messages
-
hi all,
hope all r doing fine?
anyway i have a query which is mentioned below:-
select field1,.....fieldn
from <dbtable1>
into corresponding fields of table itab
where <condition>.
select field1,...fieldn
from <dbtable2>
appending corresponding fields of table itab
where <condition>.
the above two select stmts retrieve same set of fields from two different database tables into same internal table itab..
now my question is ...........is any other way to change 2nd select statement without using appending correspondin fields
but the functionality should remain the same as it is after changing..................
bcos appending corresponding is causing performance problem in data retrieval.
thanx alot in advance.
for sure points will be given for all the helpful answers
JackHi,
You can use like that:
select field1,.....fieldn
from <dbtable1>
into corresponding fields of table itab1
where <condition>.
select field1,...fieldn
from <dbtable2>
appending corresponding fields of table itab2
where <condition>.
now u use:
loop at itab2 into w_itab2.
read table itab1 into w_itab1 with key w_itab1-<primary field> = w_itab2-<Primary field>.
if sy-subrc = 0.
append w_final into i_final.
else continue.
endif.
endloop.
*i_final table having all data ( i.e itab2 & itab1 data) -
Reg: SQL select Query in BPEL process flow
<p>
Hi,
I am suppose to execute a SQL select query (in BPEL Process flow) as mention below in JDeveloper using Database adapter.
</p>
<p>
SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
</p>
<p>
LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
</p>
<p>
FROM CUBE
</p>
<p>
WHERE ITEM= <xyz>
</p>
<p>
AND OBJECT= (SELECT CASE_NAME FROM CUBE_SUPPLIER WHERE ITEM=<xyz> AND SUPP_IND = ‘Y')
<strong>Now my question is:
1.</strong> What does this "*" refer to in the query and how can I retrieve the value of LENGTH*WIDTH* HEIGHT from the query where LENGTH,WIDTH and HEIGHT are the individual field in the table.
2.What does this " AS" refer to? If " ITEM_CUBE " is the alies for the table name "ITEM" to retrieve the value, then query shoud be evaluated as
</p>
<p>
SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
</p>
<p>
LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
</p>
<p>
FROM CUBE
</p>
<p>
WHERE <strong>ITEM_CUBE.ITEM</strong>= <xyz>
</p>
<p>
AND <strong>ITEM_CUBE.OBJECT</strong>= (SELECT CASE_NAME FROM CUBE_SUPPLIER WHERE ITEM=<xyz> AND SUPP_IND = ‘Y')
Is my assumption correct?
Please suggest asap.
Thanks...
</p>
<p>
</p>Hi
Thank for your reply!
I have a nested select query which performs on two different table as shown below:
<p>
SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
</p>
<p>
LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
</p>
<p>
FROM CUBE
</p>
<p>
WHERE ITEM= <abc>
</p>
<p>
AND OBJECT= (SELECT NAME FROM SUPPLIER WHERE ITEM=<Item> AND SUPP_IND = ‘Y')
I am using DB adapter of Oracle JDeveloper in BPEL process flow, where I can able to select only one master table in DB adapter say SUPPLIER and its attributes at a time.But as per my requirment I need to select both the table (CUBE and SUPPLIER) in a single adapter to execute my query.
It can be achievable by using two DB adapter , One to execute the nested query and another to execute the main qyery considering value of nested query as a parameter.But I want to achieve it by using a single one.
Am I correct with my concept?
Please suggest how to get it ?
</p>
Edited by: user10259700 on Oct 23, 2008 12:17 AM -
Reg: Problem in select query..
Hi all,
I want to write a select query for table COEP. Like if you open SE16 and give KSTAR with S5* we will get full data related to S5xxxxx. Same like I am trying to write for select.
TYPES: BEGIN OF T_COEP,
BELNR TYPE CO_BELNR, " PLANT
PERIO TYPE CO_PERIO, " Period
KSTAR TYPE KSTAR, " Cost Element
WERKS TYPE WERKS_D, " PLANT
MATNR TYPE MATNR, " Material Number
END OF T_COEP.
data: I_COEP TYPE STANDARD TABLE OF T_COEP,
W_COEP TYPE T_COEP.
SELECT BELNR " DOCUMENT NO
PERIO " Period
KSTAR " Cost Element
WERKS " PLANT
MATNR " Material Number
FROM COEP
INTO CORRESPONDING FIELDS OF TABLE I_COEP
WHERE KSTAR = C_S5.(HERE want I need give)*
LOOP AT I_COEP INTO W_COEP.
WRITE:/ W_COEP-BELNR, W_COEP-PERIO, W_COEP-KSTAR,
W_COEP-WERKS, W_COEP-MATNR.
ENDLOOP.
Moderator message - Please search before asking - post locked
Edited by: Rob Burbank on May 15, 2009 1:34 PMHi,
write the code like this..
SELECT BELNR " DOCUMENT NO
PERIO " Period
KSTAR " Cost Element
WERKS " PLANT
MATNR " Material Number
FROM COEP
INTO CORRESPONDING FIELDS OF TABLE I_COEP
*WHERE KSTAR = C_S5*.(HERE want I need give)*
where kstar in 'c_s%'. "write % it will acts like *
Regards,
Prabhudas -
Problem in the "select" query....Just check out and help me
Hi there !!
I am getting the following errors while trying to execute the "select" query from JSP page:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
My code is :
String reg_no=(String)session.getAttribute("reg_no");
ResultSet rs=stmt.executeQuery("SELECT * FROM reg WHERE regno = "+reg_no);
(Note: the "regno" in the database is of numeric datatype)
Try to help me...
Thanx,
Ram.Just so everyone knows:
Ram Mohan joined the forum on 7-Sep-2003 and received
his 25 Dukes for joining.
Since then, he's posted three questions, each one
promising 5-10 Dukes, and never once awarded them.
His strategy seems to be to wave Dukes, ask his
hit-and-run question, and then bolt.
Answer his questions if you wish, but don't do it
expecting Dukes. - MODDuffy, you're getting just as cranky as I have. See what hanging around these forums does to oneself? :) -
Call the Function against a select query in 500 procedures...
Hello Gurus,
I have a scenario, where i had made one function(UDF Function) to calculate something and in every procedure i call that function and calculate my requirement.
Yesterday, i made a select query using reg exp for the same calculation..
So my question is, what should be the proper approach..
I need to implement this on 500 procedures...
And the UDF function is
CREATE OR REPLACE FUNCTION "UDF_TEXTSPLIT" (
p_list VARCHAR2,
p_del VARCHAR2 := ','
) RETURN split_tbl pipelined
IS
l_idx PLS_INTEGER;
l_list VARCHAR2(7999) ;
l_value VARCHAR2(7999);
BEGIN
l_list := p_list;
LOOP
l_idx := INSTR(l_list,p_del);
IF l_idx > 0 THEN
pipe ROW(SUBSTR(l_list,1,l_idx-1));
l_list := SUBSTR(l_list,l_idx+LENGTH(p_del));
ELSE
pipe ROW(l_list);
EXIT;
END IF;
END LOOP;
RETURN;
END Udf_Textsplit;
I have made this query:
SELECT a.b,z. b1 FROM
(SELECT ROWNUM d,REGEXP_SUBSTR(str1, '[^> ]+', 1, LEVEL) b
FROM (SELECT 'xxx>zzz>gg' str1 FROM dual)
CONNECT BY REGEXP_SUBSTR(str1, '[^> ]+', 1, LEVEL) IS NOT NULL)a,
(SELECT ROWNUM d,REGEXP_SUBSTR(str1, '[^> ]+', 1, LEVEL) b1
FROM (SELECT '100>500>20' str1 FROM dual)
CONNECT BY REGEXP_SUBSTR(str1, '[^> ]+', 1, LEVEL) IS NOT NULL)z
WHERE a.d=z.d
Do i use the same select query in all 500 procedures or call the (UDF Function) in every procedure..
So which will be faster...
Your approach would be very much appreciated...
Thanks,
Haraprasad...Hmm, do I edit 500 procedures to replace a function call with a SQL statement, or edit 1 function to use a sql statement instead of the current algorithm?
This is why we use code modules that do one thing and do it well. As long as the new version of the function takes the same arguments and returns the same results as the old, then the callers will never know that the way the function works has changed.
Whenther you put the select statement in 500 procedures, or 1 function, there will still be a context switch every time you use it. The tiny additional overhead of calling a function before the context switch would be unnoticeable.
John -
How to : SELECT MAX(EmpID) / count(*) in SELECT Query
Hi,
I like to find out the Maximum of the EmpID that is in the DB table.
So I need to perform a select Query:
Select MAX(EmpID) from EmpTable
or Select Count(*) from EmpTable
<StatementName>
<dbTableName action=SELECT>
<table>realDbTableName</table>
<access>
<??? />
</access>
</dbTableName>
</StatementName>
I cannot type MAX(EmpID) or count(*) as access element
So what should I mention in the Access?
Thanks & regards,
Siva Maranani.if 0CALDAY is used as a characteristic then you have to convert that as a key figure using a replacement path variable.
Please see the below link for changing 0CALDAY as a key figure using Replacement path
http://www.sd-solutions.com/documents/SDS_BW_Replacement%20Path%20Variables.html
https://websmp106.sap-ag.de/~sapdownload/011000358700001963972003E/HowToCalcWithAttr.pdf
Now you have to create an exception "Top N Rows" based on the replacement path variable created above.
This will solve your problem.
Regs
Gopi.
Award points if it helps ... -
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
Maybe you are looking for
-
ok, maybe somebody can help me with this... cause as much as I doubt it, it could be a software issue... I went to update with the nifty Ipod Updater app. last night and it said that the was a "disk read error, cannot read or write to disk." then my
-
Downloading file from a server
Hi guys. I am attempting to allow a user to download or open a file in their browser via a servlet. I can successfully do this, providing the user has configured their browser image to viewer - so they can choose "Open" to view in the browser window,
-
UNKNOWN_ERROR while logging in Portal
Dear All, While login in Portal I am getting unknow error. Please help. I am using NW2004s. Regards ~Ankush
-
Can pages spell check in Spanish?
My daughter is doing a paper for her Spanish class, and would like to spell check the document, Does Pages have the capability to spell check in languages other than English? Thanks for any and all helpful info.
-
Image compression & Image Quality
Hi, I have a site that has a Swf Background where it fills the window completely, so the image isn't static. My only problem is, as it stretches obviously the quality degrades, and i would like it to be quite smooth however it's viewed, but also i ne