ALTERNATIVE FOR 'SELECT TOP STATEMENT
HI FRIENDS
IF ANY ONE KNOWS HOW TO CONVERT THE SQL STATEMENT GIVEN BELOW PLEASE HELP ME
SELECT TOP 1 CardID FROM EasyRechargeMaster WHERE CardGroup = EasyRecharge.CardGroup
THANKS & REGARDS
Check this query. It should give you desired results....Are you sure about that? Does TOP 1 mean "whatever happens to be the first row fetched"?
Similar Messages
-
Alternative for select count('x') or count(*)
Hi Gurus,
I need to use select count(*) multiple times in a SP before and after deletion of rows from multiple tables. As this is an expensive method, do we have some alternative for Count(*), like selecting something from a system table or view instead?Hi
You can know the number of rows affected by the DELETE statement in PL/SQL (if you are using PL/SQL) using sql%rowcount. So you don't really need to count the rows again after the delete took place...
If you are deleting the same rows as selected by the second count condition (older than a particular date), in fact you only need to count rows once for each table.
Luis -
How to determine package size dynamically for select - endselect statement in ABAP
Hi All,
I was using select- edselect with package size but i have hard coding the package size. Can any one tell me the the process to determine dynamic package size so that i can use in parallel processing.Hi,
If you are looking to determine or set the value of package size dynamically then use below code for reference.
DATA: itab TYPE TABLE OF spfli,
wa like LINE OF itab,
n TYPE i.
n = 10.
SELECT carrid connid
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE itab
PACKAGE SIZE n.
LOOP AT itab INTO wa.
WRITE: / wa-carrid, wa-connid.
ENDLOOP.
ENDSELECT.
If you are concerned about the performance then either use SELECT with OPEN CURSOR and CLOSE CURSOR.
Let me know if it helped?
Regards,
Zuber -
Alternative For Select Queries
H All,
Is there a way to extract sales doc. number of corresponding billing doc. number with out using select query in a report?Ravi,
Is there a way to extract sales doc. number of corresponding billing doc. number with out using select query in a report?
I want to take shower without getting Wet?
Try with BAPI_SALESORDER_GETDETAILBOS,and see the details from BAPISDFLOW structure.
Amit. -
Alternative for selecting ISF file in FM12 Webhelp publishing
Hi
I am currently evaluating TCS5/ FM12 as an upgrade from TCS4/ FM11.
In TCS 4, I could create an ISF file that contains my FM-RH style mapping and use that file in FM to publish the WebHelp. Now in FM12, I don't see the option to assign the ISF file. Instead, I need to start all over, first pull up the CSS file that contains the custom styles I added in RH, and then create a STS file which stores my style mapping.
Is there any other way out? I have about 70+ styles, mapping and testing them again would be a crazy task!
Thanks in advance.
SreekanthSreekanth,
Perhaps you can create a custom HTML template [AFAIK, that's essentially what the RH master page is - I don't know if you can export this from RH, as I don' use it much] and use the option to import an HTML template:
Addendum: see Adobe FrameMaker 12 * Using HTML page templates -
Prepared Statement, executing SELECT TOP in Ms Access
I'm having the following problem. I built an application fetching data without any problem from MS SQL Server, this was using prepared statements. Now i'm having this strange problem with the following query:
SELECT TOP 1 *
FROM table
WHERE appliance_id = ?
AND ttimestamp_initpk <= ?
AND ((Type = ?) OR (Type = ?) OR (Type = ?) OR (Type = ?) OR (Type = ?) OR (Type = ?))
ORDER BY ttimestamp_initpk DESC
While on SQL Server this fetches just a record, on MS Access it fetches the whole set of records without worrying about TOP instruction.
That is, it acts like a SELECT * FROM, and this slows down runtime behaviour.
I'm using sun.jdbc.odbc.JdbcOdbcDriver, is it the problem?
Thanks, MirkoThanks for your answer, but i'm not sure this is the reason.
I made one more test: i wrote a .Net application connecting to a MS Access using an ODBC connection. SELECT TOP statement is working fine, so i think i'll try another JDBC driver. Any other solution??
Thanks,
Mirko -
Column Header for Select AS kind of query
Hi,
I wish to write a csv file by using the odisqlunload function. I have wrote the funtion as :
OdiSqlUnload "-FILE=#FILE_PATH/#FILE_NAME" "-DRIVER=<%=odiRef.getInfo("SRC_JAVA_DRIVER")%>" "-URL=<%=odiRef.getInfo("SRC_JAVA_URL")%>" "-USER=<%=odiRef.getInfo("SRC_USER_NAME")%>" "-PASS=<%=odiRef.getInfo("SRC_ENCODED_PASS")%>" "-FILE_FORMAT=VARIABLE" "-FIELD_SEP=," "-ROW_SEP=\r\n" "-DATE_FORMAT=yyyy/MM/dd HH:mm:ss" "-CHARSET_ENCODING=ISO8859_1" "-XML_CHARSET_ENCODING=ISO-8859-1" "-FETCH_SIZE=1000" "-QUERY=SELECT RPAD(CI_FT_GL.GL_ACCT, 31, ' '),LPAD(CASE WHEN CI_FT.CURRENCY_CD != CI_FT_GL_EXT.DIVISION_CURCY_CD THEN sum(CI_FT_GL_EXT.DIVISION_AMT) ELSE sum(CI_FT_GL.AMOUNT) END,17,' '),' ',RPAD(CI_DST_CD_CHAR.CHAR_VAL, 25, ' '),RPAD(CI_DST_CD_CHAR.DST_ID, 8, ' '),'RMB ',' ',RPAD(to_char(sysdate, 'YYYYMMDD'), 8, ' ') FROM CI_DST_CD_CHAR CI_DST_CD_CHAR,CI_FT CI_FT,CI_FT_GL CI_FT_GL,CI_FT_GL_EXT CI_FT_GL_EXT where (CI_FT.FT_ID = CI_FT_GL.FT_ID) AND (CI_FT_GL.FT_ID = CI_FT_GL_EXT.FT_ID(+)) AND CI_FT_GL.GL_SEQ_NBR = CI_FT_GL_EXT.GL_SEQ_NBR(+) AND (CI_FT_GL.DST_ID = CI_DST_CD_CHAR.DST_ID) AND (CI_DST_CD_CHAR.CHAR_TYPE_CD = 'DTLREF1') AND (trim(CI_FT_GL.GL_ACCT) is not null) AND (CI_FT.XFER_TO_GL_DT is null) AND (CI_FT.GL_DISTRIB_STATUS in ('G','M')) AND (trunc(CI_FT.SCHED_DISTRIB_DT) <= trunc(sysdate)) AND CI_FT.CIS_DIVISION = '#DIVISION' GROUP BY CI_FT_GL.GL_ACCT,CI_DST_CD_CHAR.CHAR_VAL,CI_DST_CD_CHAR.DST_ID,CI_FT.CURRENCY_CD,CI_FT_GL_EXT.DIVISION_CURCY_CD"
Then i used a jython code to generate headers. Bcoz the OdiSqlUnload does not generate headers. But the jython code is not useful when we have sql statements lik 'Select AS' :
SELECT RPAD(CI_FT_GL.GL_ACCT, 31, ' ') AS GL_ACCT,
LPAD(CASE WHEN CI_FT.CURRENCY_CD != CI_FT_GL_EXT.DIVISION_CURCY_CD THEN sum(CI_FT_GL_EXT.DIVISION_AMT) ELSE sum(CI_FT_GL.AMOUNT) END,17,' ') AS GL_AMOUNT,
My Jython code is:
import string
import java.sql as sql
import java.lang as lang
import re
sourceConnection = odiRef.getJDBCConnection("SRC")
output_write=open('d:/Bijal/output1.csv','r+')
myStmt = sourceConnection.createStatement()
my_query = "SELECT RPAD(CI_FT_GL.GL_ACCT, 31, ' ') AS GL_ACCT,
LPAD(CASE WHEN CI_FT.CURRENCY_CD != CI_FT_GL_EXT.DIVISION_CURCY_CD THEN sum(CI_FT_GL_EXT.DIVISION_AMT) ELSE sum(CI_FT_GL.AMOUNT) END,17,' ') AS GL_AMOUNT,
' ' AS BLANK1,
RPAD(CI_DST_CD_CHAR.CHAR_VAL, 25, ' ')AS DESCR,
RPAD(CI_DST_CD_CHAR.DST_ID, 8, ' ')AS DST_ID,
'RMB ' Currency_Cd,
' ' AS BLANK2,
RPAD(to_char(sysdate, 'YYYYMMDD'), 8, ' ') AS DT_OF_TXN
FROM CI_DST_CD_CHAR CI_DST_CD_CHAR,CI_FT CI_FT,CI_FT_GL CI_FT_GL,CI_FT_GL_EXT CI_FT_GL_EXT
where (CI_FT.FT_ID = CI_FT_GL.FT_ID) AND (CI_FT_GL.FT_ID = CI_FT_GL_EXT.FT_ID(+)) AND
CI_FT_GL.GL_SEQ_NBR = CI_FT_GL_EXT.GL_SEQ_NBR(+) AND (CI_FT_GL.DST_ID = CI_DST_CD_CHAR.DST_ID)
AND (CI_DST_CD_CHAR.CHAR_TYPE_CD = 'DTLREF1') AND (trim(CI_FT_GL.GL_ACCT) is not null)
AND (CI_FT.XFER_TO_GL_DT is null) AND (CI_FT.GL_DISTRIB_STATUS in ('G','M')) AND
(trunc(CI_FT.SCHED_DISTRIB_DT) <= trunc(sysdate)) AND CI_FT.CIS_DIVISION = 'MF'
GROUP BY CI_FT_GL.GL_ACCT,
CI_DST_CD_CHAR.CHAR_VAL,
CI_DST_CD_CHAR.DST_ID,
CI_FT.CURRENCY_CD,
CI_FT_GL_EXT.DIVISION_CURCY_CD"
my_query=my_query.upper()
if string.find(my_query, '*') > 0:
myRs = myStmt.executeQuery(my_query)
md=myRs.getMetaData()
collect=[]
i=1
while (i <= md.getColumnCount()):
collect.append(md.getColumnName(i))
i += 1
header=','.join(map(string.strip, collect))
elif string.find(my_query,'||') > 0:
header = my_query[7:string.find(my_query, 'FROM')].replace("||','||",',')
else:
header = my_query[7:string.find(my_query, 'FROM')]
print header
old=output_write.read()
output_write.seek(0)
output_write.write (header+'\n'+old)
sourceConnection.close()
output_write.close()
But it does not populate for Select As statements and throws error lik:
'mismatched character \'\\n\' expecting \'"\'', ('<string>', 8, 62, 'my_query = "SELECT RPAD(CI_FT_GL.GL_ACCT, 31, \' \') AS GL_ACCT,\n'))
Plz help me get headers in my output file :)Solution1:
Still you can achieve this by using sys_connect_by_path ( if you know the use of it) to generate header. below link can help with another approach.
http://www.business-intelligence-quotient.com/?p=546
Solution2:
You need to create one file (header= true )with interface as suggested by sutirtha. Then you can copy (odifilecopy) this file to another directory with dynamic name (inside variable) and dynamic path. In this interface keep the truncate option to true so that everytime data wont be appended to the end of file. After reversing the file change the column name Manually from C1 to your ACTUAL_COL_NAME in file. Because ODI always generate the column names using C1,C2,C3 ....
The only risk in second approach is that if someone will delete the file then you will get error. For this you need to create a temp table in ODI with all column-name (header in file). then using above jython code or sys_connect_by_path (select * from temp_table), you can generate the header easily. Now this file will be generated dynamically and can be used by the interface. So even if someone will delete the file you can generate it during run time.
Thanks. -
I don't know the correct terminology, so I don't think that I've posed my question very well. Employees will be using the form that I'm trying to make, and I want for them to be able to select a city from a large number of cities, and for that city to ultimately show up on the form (not merely in the data that is output.)
I thought that the clearest way for them to select a city would be for them to start by selecting the pertinent state first. That would allow the list of cities in that state to be shorter and more manageable. So I'd like for them to be able to select a state, and then by virtue of that selection, have a list of cities pop up. I sort of achieved that by using buttons for the states, and then under "actions", I chose "open a file". Then I set it up to open a file that contained the cities that are options,and set each city with a button.
The result is that it goes from my form to a second window, containing states and then to a third window, containing cities. (Actually, there are multiple "city" windows because there's a list of cities for each state.) But then I'd like for the city that they select to wind up being on my original form. Is there an "action" that I can choose that will make that happen?
Or is there a better way to accomplish what I'm trying to accomplish? Maybe I'm just going about this all wrong(?) Any suggestions would be very much appreciated Thank you!Yes, there is a much better way. I'd recommend using a combo box for the list of states. When the user selects a state, the list of associated cities would populate a second combo box, allowing the user to select a city. This type of functionality relies on JavaScript. If you are unfamiliar with with JavaScript in Acrobat, I'd suggest starting with the following article: http://acrobatusers.com/tutorials/2007/js_list_combo_livecycle/
Ignore anything to do with LiveCycle Designer. If you get stuck, post again. -
Alternative for field exit on select-option
Good afternoon,
I know that field exit doesn't work for select-option (SAP Note 29377, point 11) but i want to know if it exists an alternative (I use SAP 4.6, and an update to ECC6 is expected next month).
The field exit would be the best option because we must add exit in many transaction (approximately 100) in little time.
Thanks for your answers,
Best regards,
Anne.Hi
A) Are there any way for debbuging field exit?
The trick to debug the field-exit is to download the data to a file on application server;
B) How run the field exits on field no editable?
It can't do it, because a field-exit is triggered as soon as a value of the field is changed.
D) Is used the field exit on version >= 4.6C
SAP doesn't support the field-exit from realese 4.7: the field-exit still works on the realese 4.7 and, I suppose, 5 and 6.00: but it doesn't work for enjoy transactions.
Anyway I believe it's better to replace the field-exit with a new solution from realese 4.7
Max -
Alternative for VRF Source Select
We have "VRF Source Select" configuration alternative to Policy based Route-map in the Router Interfaces .Can anyone tell me if we have any alternative for "VRF Soure Select" . Unfortunately Cisco 7200 VXR NPE-G1 Routers doesn't this feature at all. NPE-G1 supports only VRF Forwading and VRF Site-maps!!!
Regards
SrikantI can't think of an alternative but 12.0(28)S, which is planned to be on CCO at the end of April, will support the NPE-G1. This should solve the issue.
Hope this helps, -
Need to Improve pefromance for select statement using MSEG table
Hi all,
We are using a select statement using MSEG table
which takes a very long time to run the program which is scheduled in back ground.
Please see the history below.;
1) Previously this program was using SELECT-ENDSELECT statement inside the loop i.e.
LOOP AT I_MCHB.
To get Material Doc. Details
SELECT MBLNR
MJAHR
ZEILE INTO (MSEG-MBLNR,MSEG-MJAHR,MSEG-ZEILE)
UP TO 1 ROWS
FROM MSEG
WHERE CHARG EQ I_MCHB-CHARG
AND MATNR EQ I_MCHB-MATNR
AND WERKS EQ I_MCHB-WERKS
AND LGORT EQ I_MCHB-LGORT.
ENDSELECT.
Endloop.
The program was taking 1 hr for 20 k data
2)The above statement was replaced by ALL ENTRIES to remove the SELECT-ENDSELECT from the loop.
***GET MATERIAL DOC NUMBER AND FINANCIAL YEAR DETAILS FROM MSEG TABLE
SELECT MBLNR
MJAHR
ZEILE
MATNR
CHARG
WERKS
LGORT
INTO TABLE I_MSEG
FROM MSEG
FOR ALL ENTRIES IN I_MCHB
WHERE CHARG EQ I_MCHB-CHARG
AND MATNR EQ I_MCHB-MATNR
AND WERKS EQ I_MCHB-WERKS
AND LGORT EQ I_MCHB-LGORT.
3)After getting the further technical analysis from BASIS team , And with the suggestion to optimize the program by changing the INDEX RANGE SCAN to
MSEG~M.
SELECT MBLNR
MJAHR
ZEILE
MATNR
CHARG
WERKS
LGORT
INTO TABLE I_MSEG
FROM MSEG
FOR ALL ENTRIES IN I_MCHB
WHERE MATNR EQ I_MCHB-MATNR
AND WERKS EQ I_MCHB-WERKS
AND LGORT EQ I_MCHB-LGORT.
At present the program is taking 3 to 4 hrs in back ground .
The table is complete table scan using index
MSEG~M.
Please suggest to improve the performance of this
many many thanks
deepakThe benchmark should be the join, and I can not see how any of your solutions can be faster than the join
SELECT .....
INTO TABLE ....
UP TO 1 ROWS
FROM mchb as a
INNER JOIN mseg as b
ON amatnr EQ bmatnr
AND awerks EQ bwerks
AND algort EQ blgort
And acharg EQ bcharg
WHERE a~ ....
The WHERE condition must come from the select on MCHB, the field list from the total results
you want.
If you want to compare, must compare your solutions plus the select to fill I_MCHB.
Siegfried
Edited by: Siegfried Boes on Dec 20, 2007 2:28 PM -
Looking for the oracle equivalent of T-SQL 'SELECT TOP n'
Hi,
I'm looking for the Oracle equivalent of T-SQL 'SELECT TOP n'
and can't find any. There is SAMPLE(n) function but it supposed
to pick up random values and I'm not sure if it's possible to
make it select top values. Please help 8-)
ThanxHi Marina.
Oracle does not have a functionality like SQL Server for TOP
selection. The ROWNUM option should be used with great care and
you may get unreliable results.
Try looking at Metalink
Doc ID: 291065.999
Doc ID: 267329.999
- They discuss this issue, and solutions. -
Select FOR ALL ENTRIES statement cannot get duplicates entries
Hi all,
t_yxapy_fields consist of
inty field
0001 kostl
0002 perid
0008 ansal
0008 preas
0008 trfst
The following is the code for me to transfer the contents of t_yxapy_fields into t_pa_fields.
SELECT dbtab
FROM t777d
INTO TABLE t_pa_fields
FOR ALL ENTRIES IN t_yxapy_fields
WHERE infty = t_yxapy_fields-infty.
And t_pa_fields just ended up with
field infty
pa0001
pa0002
pa0008
Question:The first table have 3 similar infotype 0008 but the result table only have one pa0008. I need to filled up acordingly as what table 1 have. I need another 2 pa0008 in my 2nd table. What is wrng with my Select for all entries statement here?
Edited by: Siong Chao on Mar 27, 2010 10:35 AMThis has nothing to do with duplicates in t777d.
Correct, I failed to recognize that table t777d has only infty as key as pointed out by Aby. Thus in your particular case my comment was misleading. In general though FOR ALL ENTRIES removes all duplicate rows from your result set.
If you want the other 2 values just loop t_yxapy_fields this table and read t_pa_fields and if record found add the other values to t_pa_fields table. --> will trigger performance tuning issue
I'm pretty sure if you'd code this, you won't run into any performance issues, so follow Aby's recipe. To be more concrete, here's what I'd do: Define a mapping table t777d_tab, which holds the translation from infty to dbtab:
types:
begin of T_T777D_VIEW,
INFTY type T777D-INFTY,
DBTAB type T777D-DBTAB,
end of T_T777D_VIEW.
data:
T777D_TAB type hashed table of T_T777D_VIEW with unique key INFTY.
Fill table t_pa_fields, typed using t_t777d_tab from above, from table t777d. Then loop over your table t_yxapy_fields (I'd use [LOOP AT ... ASSIGNING|http://help.sap.com/abapdocu_70/en/ABAPLOOP_AT_ITAB_RESULT.htm] instead of LOOP AT ... INTO) and for each entry get the corresponding DBTAB value from t777d_tab (again use the [READ TABLE ... ASSIGNING|http://help.sap.com/abapdocu_70/en/ABAPREAD_TABLE_OUTDESC.htm] variant) and build your result table t_pa_fields.
Anyhow, I suspect that even with less optimal coding (e.g. using just standard table for lookup of DBTAB values) you'd not see much of an performance impact, because it seems that your internal tables are most likely rather small...
Cheers, harald -
Regarding 'Select .... for all entries' statement
Hi experts,
Can anyone suggest me that whether we can use two internal tables in 'Select .... for all entries' statement?Hi,
You can use ranges instead of second for all entries.
Eg:
Say for example i need to write selec statement using fields from two int tables in where conidition namely itab1, itab2.
RANGES: r_vbeln FOR wa_tab1-vbeln.
LOOP AT itab1 INTO wa_tab1.
r_vbeln-sign = 'I'.
r_vbeln-option = 'EQ'.
r_vbeln-low = wa_tab1-vbeln.
APPEND r_vbeln.
ENDLOOP.
SELECT * FROM vbap INTO TABLE itab3
FOR ALL ENTRIES IN itab2
WHERE vbeln IN r_vbeln "range contains all vbeln from the table itab1
AND matwa = itab2-matwa.
Hope this helps you.
Regards,
Manoj Kumar P -
While creating an account from my iPad there is no option for selecting none in the payment options. It states I have to give my credit card details. What's the procedure to open a free account?
It's in the article. You must first sign-out your current account, then go to App store to purchase a Free App. It will ask you to either Sign in or create a new AppleID. That's when you start creating a new AppleaID and NONE will be available as a payment option.
Maybe you are looking for
-
Home Sharing - Can you share between two accounts on the same computer?
I haven't been able to find any info about this, but does home sharing allow you to share files between to different user accounts on the same computer? I have been struggling with trying to do this for years, and I'm really hoping this solves my pro
-
Scripting: Export just one slice at a time
I need to selectively export slices, not necessarily all of them. I've only found a method that corresponds to the File/Export menu (although, via script it doesnt seem to support the 'all pages/just this page' option...?) Is there a way to emulate t
-
can they look up old emails.. text messages..?
-
Alternative Reconcialtion account while doig the MIRO
Hi All, One of the cleint required alternative Reconcialtion accoutn while doign the MIRO. Scenario like this there is one Vendor 'A' used supplies Raw material and Serives to company. Business is not intrested to create new vendor. But they needs di
-
I'm running Oracle BI Enterprise Edition 10gR3 with BIP Integrated (version 10.1.3.2.1) When I invoke the Paint Demo Report under the Business Intelligence Folder, I get the following error: java.io.IOException: prepare query failed[nQSError: 27004]