Problem in select statement(urgent)
hi experts,
my ztable structure is,
year(key) customer(key) month(key) quan1 quan2 quan3
2006 britania 01 23 12 13
2006 britania 06 34 24 15
2006 britania 09 45 10 22
i want to select quan1 from the above ztable for the same customer in the same year but the maximum of month.how to do that.
in the above data i want to select 45 for britania in 2006.
please give me the solution.
thanks in advance
regards,
Ashok.
Hi Ashok
Please try with code similar to this:
select year customer max( month )
from <ztable>
into <itab>
where <cond>
group by year customer.
Kind Regards
Eswar
Similar Messages
-
Problem with Select Statements
Hi All,
I have a performance problem for my report because of the following statements.
How can i modify the select statements for improving the performance of the report.
DATA : shkzg1h LIKE bsad-shkzg,
shkzg1s LIKE bsad-shkzg,
shkzg2h LIKE bsad-shkzg,
shkzg2s LIKE bsad-shkzg,
shkzg1hu LIKE bsad-shkzg,
shkzg1su LIKE bsad-shkzg,
shkzg2hu LIKE bsad-shkzg,
shkzg2su LIKE bsad-shkzg,
kopbal1s LIKE bsad-dmbtr,
kopbal2s LIKE bsad-dmbtr,
kopbal1h LIKE bsad-dmbtr,
kopbal2h LIKE bsad-dmbtr,
kopbal1su LIKE bsad-dmbtr,
kopbal2su LIKE bsad-dmbtr,
kopbal1hu LIKE bsad-dmbtr,
kopbal2hu LIKE bsad-dmbtr.
*These statements are in LOOP.
SELECT shkzg SUM( dmbtr )
INTO (shkzg1s , kopbal1s)
FROM bsid
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'S'
AND umskz EQ ''
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg1su , kopbal1su)
FROM bsid
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'S'
AND umskz IN zspgl
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg1h , kopbal1h)
FROM bsid
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'H'
AND umskz EQ ''
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg1hu , kopbal1hu)
FROM bsid
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'H'
AND umskz IN zspgl
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg2s , kopbal2s)
FROM bsad
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'S'
AND umskz EQ ''
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg2su , kopbal2su)
FROM bsad
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'S'
AND umskz IN zspgl
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg2h , kopbal2h)
FROM bsad
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'H'
AND umskz EQ ''
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg2hu , kopbal2hu)
FROM bsad
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'H'
AND umskz IN zspgl
GROUP BY shkzg.
ENDSELECT.>
Siegfried Boes wrote:
> Please stop writing answers if you understrand nothing about database SELECTS!
> All above recommendations are pure nonsense!
>
> As always with such questions, you must do an analysis before you ask! The coding itself is perfectly o.k., a SELECT with an aggregate and a GROUP BY can not be changed into a SELECT SINGLE or whatever.
>
> But your SELECTS mustr be supported by indexes!
>
> Please run SQL Trace, and tell us the results:
>
> I see 8 statements, what is the duration and the number of records coming back for each statement?
> Maybe only one statement is slow.
>
> See
> SQL trace:
> /people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
>
>
> Siegfried
Nice point there Siegfried. Instead of giving constructive suggestion, people here give a very bad suggestion on using SELECT SINGLE combined with SUM and GROUP BY.
I hope the person already look at your reply before he try using select single and wondering why he has error.
Anyway, the most important thing is how many loop expected for those select statements?
If you have like thousands of loop, you can expect a poor performance.
So, you should also look at how many times the select statement is called and not only performance for each select statement when you're doing SQL trace.
Regards,
Abraham -
Problem with Select statement.
DATA: wa_usr05 TYPE usr05.
The select statement always gives sy-subrc = 0
even if there is no entry with parid = 'ZRD'.
On successful it fills the structure wa_usr05 as
MANDT C 3 ACC
BNAME C 12 SCL
PARID C 20 X
PARVA C 18
but mandt is 310.
USR05 is a pool table and has mandt field.
SELECT SINGLE bname
parid
parva
FROM usr05
INTO wa_usr05
WHERE bname = sy-uname AND
parid = 'ZRD' AND
parva = 'x' OR parva = 'X'.
Let me know the reason and solution to the problem.SELECT SINGLE * FROM usr05
INTO wa_usr05
WHERE bname = sy-uname AND
parid = 'ZRD' AND
parva = <b>'X'</b> .
Use single * as u have defined the wa+usr05 as usr05.
Else.
DATA: i_usr05 TYPE STANDARD TABLE of usr05.
SELECT * FROM USR05
INTO TABLE usr05
WHERE bname = sy-uname AND
parid = 'ZRD' AND
parva = <b>'X'</b> .
Then loop at itab and write data.
Hope this solves ur query.
Reward points if this helps.
Message was edited by:
Judith Jessie Selvi -
Hi Experts,
I am facing the problem in the select statement where it giving the short dump
DBIF_RSQL_INVALID_RSQL CX_SY_OPEN_S.
i have searched many forms, but i found that the select option s_matnr have the limitaion 2000 entreis, but i am passing same s_matnr to other select statement with more than 2000 entries but it is not giving me any short dump.
but i am facing problem with only one select statement where if i pass select option s_matnr more than 1500 entris also giving short dump.
my select statement is
SELECT * FROM bsim
INTO CORRESPONDING FIELDS OF TABLE g_t_bsim_lean
FOR ALL ENTRIES IN t_bwkey WHERE bwkey = t_bwkey-bwkey
AND matnr IN matnr
AND bwtar IN bwtar
AND budat >= datum-low.
in the internal table g_t_bsim_lean internal table contain all the fields of the table bsim with 2 fields from other table.
Please let me know whether i need to change the select statement or any other solution for this.
Regards,
udupimy select query is like this:
DATA: BEGIN OF t_bwkey OCCURS 0, "184465
bwkey LIKE bsim-bwkey, "184465
END OF t_bwkey. "184465
LOOP AT g_t_organ WHERE keytype = c_bwkey.
MOVE g_t_organ-bwkey TO t_bwkey-bwkey.
COLLECT t_bwkey. "184465
ENDLOOP. "184465
READ TABLE t_bwkey INDEX 1. "184465
CHECK sy-subrc = 0. "184465
SELECT * FROM bsim "n443935
INTO CORRESPONDING FIELDS OF TABLE g_t_bsim_lean "n443935
FOR ALL ENTRIES IN t_bwkey WHERE bwkey = t_bwkey-bwkey
AND matnr IN matnr
AND bwtar IN bwtar
AND budat >= datum-low. -
Problem with SELECT statement. What is wrong with it?
Why is this query....
<cfquery datasource="manna_premier" name="kit_report">
SELECT Orders.ID,
SaleDate,
Orders.UserID,
Distributor,
DealerID,
Variable,
TerritoryManager,
US_Dealers.ID,
DealerName,
DealerAddress,
DealerCity,
DealerState,
DealerZIPCode,
(SELECT SUM(Quantity)
FROM ProductOrders PO
WHERE PO.OrderID = Orders.ID) as totalProducts,
FROM Orders, US_Dealers
WHERE US_Dealers.ID = DealerID AND SaleDate BETWEEN #CreateODBCDate(FORM.Start)# AND #CreateODBCDate(FORM.End)# AND Variable = '#Variable#'
</cfquery>
giving me this error message...
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
The error occurred in D:\Inetpub\mannapremier\kit_report2.cfm: line 20
18 : WHERE PO.OrderID = Orders.ID) as totalProducts,
19 : FROM Orders, US_Dealers
20 : WHERE US_Dealers.ID = DealerID AND SaleDate BETWEEN #CreateODBCDate(FORM.Start)# AND #CreateODBCDate(FORM.End)# AND Variable = '#Variable#'
21 : </cfquery>
22 :
SQLSTATE
42000
SQL
SELECT Orders.ID, SaleDate, Orders.UserID, Distributor, DealerID, Variable, TerritoryManager, US_Dealers.ID, DealerName, DealerAddress, DealerCity, DealerState, DealerZIPCode, (SELECT SUM(Quantity) FROM ProductOrders PO WHERE PO.OrderID = Orders.ID) as totalProducts, FROM Orders, US_Dealers WHERE US_Dealers.ID = DealerID AND SaleDate BETWEEN {d '2009-10-01'} AND {d '2009-10-31'} AND Variable = 'Chick Days pre-book'
VENDORERRORCODE
-3504
DATASOURCE
manna_premier
Resources:
I copied it from a different template where it works without error...
<cfquery name="qZVPData" datasource="manna_premier">
SELECT UserID,
TMName,
UserZone,
(SELECT COUNT(*)
FROM Sales_Calls
WHERE Sales_Calls.UserID = u.UserID) as totalCalls,
(SELECT COUNT(*)
FROM Orders
WHERE Orders.UserID = u.UserID) as totalOrders,
(SELECT SUM(Quantity)
FROM ProductOrders PO
WHERE PO.UserID = u.UserID AND PO.NewExisting = 1) as newItems,
(SELECT SUM(NewExisting)
FROM ProductOrders PO_
WHERE PO_.UserID = u.UserID) as totalNew,
SUM(totalOrders)/(totalCalls) AS closePerc
FROM Users u
WHERE UserZone = 'Central'
GROUP BY UserZone, UserID, TMName
</cfquery>
What is the problem?It's hard to say: what's your request timeout set to?
700-odd records is not much of a fetch for a decent DB, and I would not expect that to case the problem. But then you're using Access which doesn't fit the description of "decent DB" (or "fit for purpose" or "intended for purpose"), so I guess all bets are off one that one. If this query is slow when ONE request is asking for it, what is going to happen when it goes live and multiple requests are asking for it, along with all the other queries your site will want to run? Access is not designed for this. It will really struggle, and cause your site to run like a dog. One that died serveral weeks ago.
What else is on the template? I presume you're doing something with the query once you fetch it, so could it be that code that's running slowly? Have you taken any steps to isolate which part of the code is taking so long?
How does the query perform if you take the subquery out of the select line? Is there any other way of getting that data? What subquery will be running once for every row of the result set... not very nice.
Adam -
Problem with select statement using Ranges
Hi Guys,
I have used Ranges and used a select statement for selecting those ranges but I am facing a problem.
RANGES: r_doctyp for EDIDC-DOCTYP.
r_doctyp-sign = 'I'.
r_doctyp-option = 'EQ'.
r_doctyp-low = 'DEBMAS'.
append r_doctyp.
r_doctyp-sign = 'I'.
r_doctyp-option = 'EQ'.
r_doctyp-low = 'MATMAS'.
append r_doctyp.
r_doctyp-sign = 'I'.
r_doctyp-option = 'EQ'.
r_doctyp-low = 'PRICAT'.
append r_doctyp.
r_doctyp-sign = 'I'.
r_doctyp-option = 'EQ'.
r_doctyp-low = 'ORDERS'.
append r_doctyp.
r_doctyp-sign = 'I'.
r_doctyp-option = 'EQ'.
r_doctyp-low = 'INVOIC'.
append r_doctyp.
Select DOCNUM " IDoc number
DOCTYP " IDoc Type
from EDIDC into table IT_ZEDIDC
where CREDAT EQ s_credat-low
and DOCTYP EQ r_doctyp " IDOC Types
and DIRECT EQ '1'.
Here my select statement is only taking INVOIC.
But my statement should take any document type.
Thanks,
Prasad.Hi...,
Your following select statement is correct.
Select DOCNUM " IDoc number
DOCTYP " IDoc Type
from EDIDC into table IT_ZEDIDC
where CREDAT IN s_credat
and DOCTYP IN r_doctyp " IDOC Types
and DIRECT EQ '1'.
Why you are not getting result..
1. structure of the IT_ZEDIDC is having two fields DOCNUM , DOCTYP with same data lengths. If not it should be...
2. Order in the database table is must be similer to the order you maintained in the select statement.
3. As you are hard coding the input ranges make sure about every letter.
4. take a look at other where condition fields too.
5. check the table of the ranges in debugging mode.
6. why can't you declare separate work area and table for ranges...?
like .... data: r_tab type range of <field>
data: wa_tab like line of r_tab.
7. Use clear work area statement after the append statment.
--Naveen Inuganti. -
Where condition problem in select statement.
Hi,
I am trying to write select statement as below
SELECT objectclas objectid FROM cdhdr INTO CORRESPONDING FIELDS OF TABLE ltab_chgdocu
WHERE objectclas IN ('STUE' , 'STUE_V')
AND ( TCODE eq 'CS01u2019 or tcode eq u2019CS02u2019 or tcode eq 'C201' or tcode eq 'C202' ) .
But I am getting the error like "literals that takes up more than one line or not permitted"
Please let me know whats wrong and correct me .
Thanks,
Vinay.Hi Vinay,
Declare constants
constants : c_stue type CDOBJECTCL value 'STUE',
c_stue_v type CDOBJECTCL value 'STUE_V',
c_cs01 type sy-tcode value 'CS01',
c_cs02 type sy-tcode value 'CS02',
c_C201 type sy-tcode value 'C201',
c_C202 type sy-tcode value 'C202'.
And replace your hardcoded values with these constants in your select query.
SELECT objectclas objectid FROM cdhdr INTO CORRESPONDING FIELDS OF TABLE it_tab
WHERE objectclas IN (c_STUE , c_STUE_V)
AND ( TCODE eq c_CS01
or tcode eq c_CS02
or tcode eq c_C201
or tcode eq c_C202 ).
Thanks & Regards
- Always Leaner -
Having Problem in select statement.
Dear gurus
im having an issue in select statement.
i have written a select statement which is fetching the result as i required but it takes to much time to execute.
how to make it work fast.
SELECT vbak~vkbur vbap~vbeln vbap~posnr vbak~audat
vbap~kwmeng vbap~meins vbak~kunnr vbak~vkorg
vbak~vtweg vbak~spart matnr matkl auart
vbap~abgru
INTO CORRESPONDING FIELDS OF TABLE so_tab
FROM vbak
JOIN vbap ON vbak~vbeln = vbap~vbeln
WHERE audat IN in_date
AND matnr IN matnr
AND ( auart = 'ZISO' OR auart = 'ZEXP' )
AND vbap~werks IN werks .
SELECT lips~vbeln lips~posnr likp~lfdat lips~lfimg
lips~meins likp~kunag matnr vgbel vgpos
lfart
INTO CORRESPONDING FIELDS OF TABLE del_tab
FROM likp
JOIN lips ON likp~vbeln = lips~vbeln
FOR ALL entries IN so_tab
WHERE vgbel = so_tab-vbeln
AND vgpos = so_tab-posnr
AND lfdat IN in_date
AND likp~werks IN werks.
Regards
Saad Nisar.Hi,
I agree with sabu.
Along with these you need to do following things -
SELECT vbak~vkbur vbap~vbeln vbap~posnr vbak~audat
vbap~kwmeng vbap~meins vbak~kunnr vbak~vkorg
vbak~vtweg vbak~spart matnr matkl auart
vbap~abgru
INTO CORRESPONDING FIELDS OF TABLE so_tab
FROM vbak
JOIN vbap ON vbak~vbeln = vbap~vbeln
WHERE audat IN in_date
AND matnr IN matnr
AND ( auart = 'ZISO' OR auart = 'ZEXP' )
AND vbap~werks IN werks .
{color:green}
*if sy-subrc eq 0.*
*so_tab_tmp[] = so_tab[].*
*sort so_tab_tmp by vbeln posnr.*
*delete adjacent duplicates from so_tab_tmp by vbeln posnr.*
*if so_tab_tmp[] is not initial.*
{color:green}
SELECT lips~vbeln lips~posnr likp~lfdat lips~lfimg
lips~meins likp~kunag matnr vgbel vgpos
lfart
INTO CORRESPONDING FIELDS OF TABLE del_tab
FROM likp
JOIN lips ON likp~vbeln = lips~vbeln
FOR ALL entries IN so_tab_tmp
WHERE vgbel = so_tab_tmp-vbeln
AND vgpos = so_tab_tmp-posnr
AND lfdat IN in_date
AND likp~werks IN werks.
{color:green}
*endif.*
*endif.*
{color:green} -
SELECT statement (urgent!)
Could you please help me with the following statement?
The FROM clause is incorrect but i don't know what i should write.
Thank you in advance.
Maria.
DECLARE
A NUMBER;
CURSOR C1 IS
SELECT TABLE_NAME, COLUMN_NAME
FROM USER_TAB_COLUMNS
WHERE NULLABLE='N' AND TABLE_NAME LIKE 'P_%';
BEGIN
FOR i IN C1
LOOP
SELECT COUNT(*) INTO A
FROM i.TABLE_NAME
WHERE i.COLUMN_NAME IS NOT NULL;
END LOOP;
END;
/FOR-LOOP
Whereas the number of iterations through a WHILE loop is unknown until the loop completes, the number of iterations through a FOR loop is known before the loop is entered. FOR loops iterate over a specified range of integers. The range is part of an iteration scheme, which is enclosed by the keywords FOR and LOOP. A double dot (..) serves as the range operator. The syntax follows:
FOR counter IN [REVERSE] lower_bound..higher_bound LOOP
sequence_of_statements
END LOOP;
The range is evaluated when the FOR loop is first entered and is never re-evaluated.
As the next example shows, the sequence of statements is executed once for each integer in the range. After each iteration, the loop counter is incremented.
FOR i IN 1..3 LOOP -- assign the values 1,2,3 to i
sequence_of_statements -- executes three times
END LOOP;
The following example shows that if the lower bound equals the higher bound, the sequence of statements is executed once:
FOR i IN 3..3 LOOP -- assign the value 3 to i
sequence_of_statements -- executes one time
END LOOP;
By default, iteration proceeds upward from the lower bound to the higher bound. However, as the example below shows, if you use the keyword REVERSE, iteration proceeds downward from the higher bound to the lower bound. After each iteration, the loop counter is decremented. Nevertheless, you write the range bounds in ascending (not descending) order.
FOR i IN REVERSE 1..3 LOOP -- assign the values 3,2,1 to i
sequence_of_statements -- executes three times
END LOOP;
Inside a FOR loop, the loop counter can be referenced like a constant but cannot be assigned values, as the following example shows:
FOR ctr IN 1..10 LOOP
IF NOT finished THEN
INSERT INTO ... VALUES (ctr, ...); -- legal
factor := ctr * 2; -- legal
ELSE
ctr := 10; -- not allowed
END IF;
END LOOP;
Iteration Schemes
The bounds of a loop range can be literals, variables, or expressions but must evaluate to numbers. Otherwise, PL/SQL raises the predefined exception VALUE_ERROR. The lower bound need not be 1, as the examples below show. However, the loop counter increment (or decrement) must be 1.
j IN -5..5
k IN REVERSE first..last
step IN 0..TRUNC(high/low) * 2
Internally, PL/SQL assigns the values of the bounds to temporary PLS_INTEGER variables, and, if necessary, rounds the values to the nearest integer. The magnitude range of a PLS_INTEGER is -2**31 .. 2**31. So, if a bound evaluates to a number outside that range, you get a numeric overflow error when PL/SQL attempts the assignment, as the following example shows:
DECLARE
hi NUMBER := 2**32;
BEGIN
FOR j IN 1..hi LOOP -- causes a 'numeric overflow' error
END LOOP;
END;
Some languages provide a STEP clause, which lets you specify a different increment (5 instead of 1 for example). PL/SQL has no such structure, but you can easily build one. Inside the FOR loop, simply multiply each reference to the loop counter by the new increment. In the following example, you assign today's date to elements 5, 10, and 15 of an index-by table:
DECLARE
TYPE DateList IS TABLE OF DATE INDEX BY BINARY_INTEGER;
dates DateList;
k CONSTANT INTEGER := 5; -- set new increment
BEGIN
FOR j IN 1..3 LOOP
dates(j*k) := SYSDATE; -- multiply loop counter by increment
END LOOP;
END;
Dynamic Ranges
PL/SQL lets you determine the loop range dynamically at run time, as the following example shows:
SELECT COUNT(empno) INTO emp_count FROM emp;
FOR i IN 1..emp_count LOOP
END LOOP;
The value of emp_count is unknown at compile time; the SELECT statement returns the value at run time.
What happens if the lower bound of a loop range evaluates to a larger integer than the upper bound? As the next example shows, the sequence of statements within the loop is not executed and control passes to the next statement:
-- limit becomes 1
FOR i IN 2..limit LOOP
sequence_of_statements -- executes zero times
END LOOP;
-- control passes here
Scope Rules
The loop counter is defined only within the loop. You cannot reference it outside the loop. After the loop is exited, the loop counter is undefined, as the following example shows:
FOR ctr IN 1..10 LOOP
END LOOP;
sum := ctr - 1; -- not allowed
You need not explicitly declare the loop counter because it is implicitly declared as a local variable of type INTEGER. The next example shows that the local declaration hides any global declaration:
DECLARE
ctr INTEGER;
BEGIN
FOR ctr IN 1..25 LOOP
IF ctr > 10 THEN ... -- refers to loop counter
END LOOP;
END;
To reference the global variable in this example, you must use a label and dot notation, as follows:
<<main>>
DECLARE
ctr INTEGER;
BEGIN
FOR ctr IN 1..25 LOOP
IF main.ctr > 10 THEN -- refers to global variable
END IF;
END LOOP;
END main;
The same scope rules apply to nested FOR loops. Consider the example below. Both loop counters have the same name. So, to reference the outer loop counter from the inner loop, you must use a label and dot notation, as follows:
<<outer>>
FOR step IN 1..25 LOOP
FOR step IN 1..10 LOOP
IF outer.step > 15 THEN ...
END LOOP;
END LOOP outer;
Using the EXIT Statement
The EXIT statement lets a FOR loop complete prematurely. For example, the following loop normally executes ten times, but as soon as the FETCH statement fails to return a row, the loop completes no matter how many times it has executed:
FOR j IN 1..10 LOOP
FETCH c1 INTO emp_rec;
EXIT WHEN c1%NOTFOUND;
END LOOP;
Suppose you must exit from a nested FOR loop prematurely. You can complete not only the current loop, but any enclosing loop. Simply label the enclosing loop that you want to complete. Then, use the label in an EXIT statement to specify which FOR loop to exit, as follows:
<<outer>>
FOR i IN 1..5 LOOP
FOR j IN 1..10 LOOP
FETCH c1 INTO emp_rec;
EXIT outer WHEN c1%NOTFOUND; -- exit both FOR loops
END LOOP;
END LOOP outer;
-- control passes here
Joel P�rez -
Problem executing SELECT statement due to st_spatial column type
I am using a CachedRowSet and cache.execute() will not run because it does not support the st_spatial column type. I have been told to use the column metadata to build a select statement of column names, and check the column's type before you add it to the select clause. But, I am unsure of what to do since I can't get column names without running a select statement first... I will attach some code for you to look at, but please give me suggestions!
try{
Class.forName("com.informix.jdbc.IfxDriver");
CachedRowSet cache = new CachedRowSet();
cache.setReadOnly(true);
cache.setUrl(dbname);
cache.setUsername(user);
cache.setPassword(password);
cache.setCommand("SELECT * FROM "+table);
try{
cache.execute();
}catch(Exception e){
out.print("Can't Display");
OTHER JSP CODE THAT WORKS WITH THE RESULTS FROM ABOVE
}catch(Exception exc){
out.println(exc.toString());
} // end try-catchI honestly don't have a clue. I have no idea what the st_spatial data type is, or where it is defined, and as a result, I don't know why Java would be complaining about it. I do know that java.sql.ResultSet doesn't care about it (it would internally recognize it as a plain old object type via the getObject() method and you would have to cast it to st_spatial).
What I would check:
Is the Informix driver up to date?
Does the CachedRowSet class extend ResultSet or otherwise use it as an internal data structure? If so, does it properly create the ResultSetMetaData object and no exceptions are being trapped?
Otherwise... when copying data from the ResultSet object into its own internal data structure, does it correctly realize that the st_spatial column should NOT be copied into a String or a slot in a String array?
Does a quick and dirty command line version of your program properly use CachedRowSet to retrieve at least one record from your database?
Basically, put the JSP aside and just test the CachedRowSet to make sure it is working correctly. I have no idea what's in that class since it is not a Java standard class, so I can't really give you any additional suggestions. -
Problems with select statement
Hi,
For some reason I cannot find the solution for the following problem.
I have an internal table.
Now I like to make an select over a database table, while only rows should be selected, where the key field occurs in the internal table and in case of identical key field only the row with the lowest value in another column is selcted.
Example:
- internal table:
col1 col2 col3
1 A AA
2 B AA
3 A AC
-database table:
col1 col2 col3
1 001 CD
1 002 CF
1 003 CG
2 001 CD
2 002 CF
2 003 CG
3 002 CF
3 003 CG
4 001 CD
4 002 CF
4 003 CG
- the selected database entries should be
1 001 CD
2 001 CD
3 002 CF
explication:
- entries with 4 in the first column do not occur in the internal table, so they do not appear in the selection
- in case of more than one entry in the database table only the one with the lowest value in column two will be selected
If you have any idea how this could be solved, I would really appreciate you help.
regards
TorstenHi,
1) u have to select based on internal table 1
2) u have to filter the internal table 2 for minimum value.
select col1 col2 col3
from <any table>
into table <Internal_table_final>
for all entries in <Internal_table_1>
where col1 = Internal_table_1-col1.
sort Internal_table_final by col1 col2.
loop at Internal_table_final.
at new col1.
continue.
endat.
delete Internal_table_final.
endloop.
<b>try this</b>
Regards
<b>Mark Helpful Answers</b>
Message was edited by: Manoj Gupta -
HI FRNDS ..
I AM HAVING SOME ERRORS IN THE WHERE CLAUSE PLZ CORRECT IT
select DOCNO into t_DOCNO from J_1IEXCHDR
where exnum = gf_text and
status ne ( 'd' and 'r' and 'b' ).
PLZ HELP ME TO COLLECT VALU OF THE STATUS FILED WHER IT IS NOT EQUAL TO D, R AND BRANGES: R_STAT FOR J_1IEXCHDR-STATUS.
R_STAT-LOW = 'D'.
R_STAT-SIGN = 'I'.
R_STAT-OPTION = 'EQ'.
APPEND R_STAT.
CLEAR R_STAT.
R_STAT-LOW = 'R'.
R_STAT-SIGN = 'I'.
R_STAT-OPTION = 'EQ'.
APPEND R_STAT.
CLEAR R_STAT.
R_STAT-LOW = 'B'.
R_STAT-SIGN = 'I'.
R_STAT-OPTION = 'EQ'.
APPEND R_STAT.
CLEAR R_STAT.
DATA: T_DOCNO LIKE J_1IEXCHDR-DOCNO OCCURS 0 WITH HEADER LINE.
DATA: GF_TEXT LIKE J_1IEXCHDR-EXNUM.
SELECT DOCNO INTO TABLE T_DOCNO FROM J_1IEXCHDR
WHERE EXNUM = GF_TEXT
AND
STATUS NOT IN R_STAT.
Try to use Ranges.
Regards
vijay -
Performance problem in SELECT statement
HI All,
How to improve the performance in given query?
Query is..
data : begin of tzdate OCCURS 0,
zdate like sy-datum,
end of tzdate.
data: p_adrnr like lfa1-lifnr.
SELECT single adrnr into p_adrnr
FROM lfa1
WHERE lifnr = ilifnr-lifnr
AND land1 IN s_land1.
CONCATENATE '%' p_adrnr '%' INTO email_objectid.
SELECT udate INTO table tzdate
FROM cdhdr
WHERE objectclas = 'ADRESSE'
AND objectid LIKE email_objectid
AND tcode IN r_tcode.
Regards,
-D.
Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting - post locked
Edited by: Rob Burbank on Sep 16, 2009 10:14 AMHI All,
How to improve the performance in given query?
Query is..
data : begin of tzdate OCCURS 0,
zdate like sy-datum,
end of tzdate.
data: p_adrnr like lfa1-lifnr.
SELECT single adrnr into p_adrnr
FROM lfa1
WHERE lifnr = ilifnr-lifnr
AND land1 IN s_land1.
CONCATENATE '%' p_adrnr '%' INTO email_objectid.
SELECT udate INTO table tzdate
FROM cdhdr
WHERE objectclas = 'ADRESSE'
AND objectid LIKE email_objectid
AND tcode IN r_tcode.
Regards,
-D.
Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting - post locked
Edited by: Rob Burbank on Sep 16, 2009 10:14 AM -
SELECT statement for VBKD - FAE in FPLT
HI,
For CS Report - Need to find the Conform Business (AMC is there But Invoice is Pending ).
For This -->
I need to take the table flow as - FPLT --> VBKD --> All (like VBAK, VBAP etc..)
Problem is -->
SELECT statement
INTO IT_VBKD
FOR ALL ENTRIES IN IT_FPLT
WHERE fplnr = gwa_fplt-fplnr
is taking too much time to execute.
1. All Entries are Pending for Invoice ( FPLT- FKSAF = 'A' )
2. No entry in VBFA table for this criteria.Thanks Vinod,
Yes, I check it.
But, In Client's system VBAK-rplnr is always Initial.
Actually, I have data like -->
AMC for duration - 01.07.2010 to 30.06.2011
For which I am taking Four Billing Cycles -
1. 01.07.2010 to 30.09.2010 - billed on 01.09.2010
2. 01.10.2010 to 31.12.2010 - billed on 01.12.2010
3. 01.01.2011 to 31.03.2011 - Unbilled - Projected billing date 01.03.2011 "
4. 01.04.2011 to 30.06.2011 - Unbilled - Projected billing date 01.06.2011 "
I have to consider Case 3 & 4 (unbilled). How can I calculate details for it?
Report is working Fine - if I select - Selection options from FPLT - But while taking it from Sales Order - It's going to TIME OUT at SELECT statement itself.
(Because table FPLT has more than 10Lac entries - and all are fetched )
Edited by: Priya.ABAP on Dec 6, 2010 11:47 AM -
String compare in select statement
Hi All,
i have a problem in select statement. i have a name field in my selection screen, i am using name field to comapre string in my select statement, but i am not getting the resule can anyone suggest me on this . please find my code below,s_name1 is my select option name.
IF s_name1-low IS NOT INITIAL.
LOOP AT S_NAME1.
CONCATENATE s_name1-low '%' INTO s_name1-low.
TRANSLATE s_name1-low TO UPPER CASE.
s_name1-option = 'CP'.
MODIFY s_name1.
ENDLOOP.
ENDIF.
SELECT lifnr land1 name1 ort01 ort02 pfach pstl2 pstlz regio stras
erdat ernam ktokk loevm sperr sperm sperz nodel
INTO (gs_vendor-vendor_num, gs_vendor-land1, gs_vendor-name,
gs_vendor-ort01, gs_vendor-ort02, gs_vendor-pfach,
gs_vendor-pstl2, gs_vendor-pstlz, gs_vendor-regio,
gs_vendor-stras, gs_vendor-created_on, gs_vendor-created_by,
gs_vendor-account_gp, gs_vendor-deletion_flag,
gs_vendor-central_post, gs_vendor-ctr_purch_block,
gs_vendor-payment_block, gs_vendor-central_deletion)
FROM lfa1
WHERE lifnr IN s_lifnr
AND name1 LIKE s_name1
Start of Change G9007789 03/12/2008 - D01K946651
Additional selection criteria added for City and Region
AND ort01 IN s_ort01
AND regio IN s_regio
End of Change G9007789 03/12/2008 - D01K946651
AND ktokk IN s_ktokk
AND ( ktokk NE 'ZHMT' AND ktokk NE 'ZTER' ).
APPEND gs_vendor TO gt_vendor.
CLEAR gs_vendor.
ENDSELECT.Hi,
Have you checked whether you have given proper events.
Check this code below.
AT selection screen output. "Change here
IF s_name1-low IS NOT INITIAL.
LOOP AT S_NAME1.
CONCATENATE s_name1-low '%' INTO s_name1-low.
TRANSLATE s_name1-low TO UPPER CASE.
s_name1-option = 'CP'.
MODIFY s_name1.
ENDLOOP.
ENDIF.
Start-of-Selection. " change here
SELECT lifnr land1 name1 ort01 ort02 pfach pstl2 pstlz regio stras
erdat ernam ktokk loevm sperr sperm sperz nodel
INTO (gs_vendor-vendor_num, gs_vendor-land1, gs_vendor-name,
gs_vendor-ort01, gs_vendor-ort02, gs_vendor-pfach,
gs_vendor-pstl2, gs_vendor-pstlz, gs_vendor-regio,
gs_vendor-stras, gs_vendor-created_on, gs_vendor-created_by,
gs_vendor-account_gp, gs_vendor-deletion_flag,
gs_vendor-central_post, gs_vendor-ctr_purch_block,
gs_vendor-payment_block, gs_vendor-central_deletion)
FROM lfa1
WHERE lifnr IN s_lifnr
AND name1 LIKE s_name1
Start of Change G9007789 03/12/2008 - D01K946651
Additional selection criteria added for City and Region
AND ort01 IN s_ort01
AND regio IN s_regio
End of Change G9007789 03/12/2008 - D01K946651
AND ktokk IN s_ktokk
AND ( ktokk NE 'ZHMT' AND ktokk NE 'ZTER' ).
APPEND gs_vendor TO gt_vendor.
CLEAR gs_vendor.
ENDSELECT.
Reward if helpful.
Regards.
Maybe you are looking for
-
Multiple accounts on one computer
How to set up multiple accounts in itunes
-
hi guys i recently downloaded the blackberry desktop software to upgrade my curve 9300 but everytime i try to open it it says "blackberry desktop software has encountered a error and must close. we are sorry for the inconvenience". i tried to downloa
-
Template having export to excel functionality with filter values in WAD
Hi, I need to create a template which has export to excel functionality with all the filter values that the user has selected in the selection screen. export to excel can be done but how can be the output excel sheet contain only those values which w
-
JPG color / contrast issues
I am exporting from a RAW file to JPG. I then decided to export to TIFF and png to see what difference there would be. The only changes applied to the RAW were from within Aperature. I was expecting no big difference when viewing the image at the red
-
"Flash9b.ocx failed to register" error message and problems caused
I didn't want to update my flash player but finally was "bullied' into doing so, because i kept receiving a screen message telling me to update it, without being given the option to say "No. Thank you anyway." After I updated my flash player to 11..