I need help with a SELECT query - help!
Hello, I need help with a select statement.
I have a table with 2 fields as shown below
Name | Type
John | 1
John | 2
John | 3
Paul | 1
Paul | 2
Paul | 3
Mark | 1
Mark | 2
I need a query that returns everything where the name has type 1 or 2 but not type 3. So in the example above the qery should bring back all the "Mark" records.
Thanks,
Ian
Or, if the types are sequential from 1 upwards you could simply do:-
SQL> create table t as
2 select 'John' as name, 1 as type from dual union
3 select 'John',2 from dual union
4 select 'John',3 from dual union
5 select 'Paul',1 from dual union
6 select 'Paul',2 from dual union
7 select 'Paul',3 from dual union
8 select 'Paul',4 from dual union
9 select 'Mark',1 from dual union
10 select 'Mark',2 from dual;
Table created.
SQL> select name
2 from t
3 group by name
4 having count(*) <= 2;
NAME
Mark
SQL>Or another alternative if they aren't sequential:
SQL> ed
Wrote file afiedt.buf
1 select name from (
2 select name, max(type) t
3 from t
4 group by name
5 )
6* where t < 3
SQL> /
NAME
Mark
SQL>Message was edited by:
blushadow
Similar Messages
-
Need some help with the Select query.
Need some help with the Select query.
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
select single vkorg abgru from ZADS into it_rej.
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
This is causing performance issue. They are asking me to include the where condition for this select query.
What should be my select query here?
Please suggest....
Any suggestion will be apprecaiated!
Regards,
DeveloperHello Everybody!
Thank you for all your response!
I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table
select vkorg abgru from ZADS into it_rej.
Earlier :
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
Now :
DATA : BEGIN OF IT_REJ occurs 0,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
I guess this will fix the issue correct?
PLease suggest!
Regards,
Developer. -
Performance issue after Upgrade from 4.7 to ECC 6.0 with a select query
Hi All,
There is a Performance issue after Upgrade from 4.7 to ECC 6.0 with a select query in a report painter.
This query is working fine when executed in 4.7 system where as it is running for more time in ECC6.0.
Select query is on the table COSP.
SELECT (FIELD_LIST)
INTO CORRESPONDING FIELDS OF TABLE I_COSP PACKAGE SIZE 1000
FROM COSP CLIENT SPECIFIED
WHERE GJAHR IN SELR_GJAHR
AND KSTAR IN SELR_KSTAR
AND LEDNR EQ '00'
AND OBJNR IN SELR_OBJNR
AND PERBL IN SELR_PERBL
AND VERSN IN SELR_VERSN
AND WRTTP IN SELR_WRTTP
AND MANDT IN MANDTTAB
GROUP BY (GROUP_LIST).
LOOP AT I_COSP .
COSP = I_COSP .
PERFORM PCOSP USING I_COSP-_COUNTER.
CLEAR: $RWTAB, COSP .
CLEAR CCR1S .
ENDLOOP.
ENDSELECT.
I have checked with the table indexes, they were same as in 4.7 system.
What can be the reson for the difference in execution time. How can this be reduced without adjusting the select query.
Thanks in advance for the responses.
Regards,
Dedeepya.Hi,
ohhhhh....... lots of problems in select query......this is not the way you should write it.
Some generic comments:
1. never use SELECT
endselect.
SELECT
into table
for all entries in table
where.
use perform statment after this selection.
2. Do not use into corresponding fields. use exact structure type.
3. use proper sequence of fields in the where condition so that it helps table go according to indexes.
e.g in your case
sequence should be
LEDNR
OBJNR
GJAHR
WRTTP
VERSN
KSTAR
HRKFT
VRGNG
VBUND
PARGB
BEKNZ
TWAER
PERBL
sequence should be same as defined in table.
Always keep select query as simple as possible and perform all other calculations etc. afterwords.
I hope it helps.
Regards,
Pranaya -
What is the wrong with my select query
HI All,
TYPES: BEGIN OF t_equi,
equnr TYPE equi-equnr,
aedat TYPE equi-aedat,
matnr TYPE equi-matnr,
sernr TYPE equi-sernr,
kunde TYPE equi-kunde,
zzreg_date TYPE equi-zzreg_date,
zzin_indic TYPE equi-zzin_indic,
zzinvoice_num TYPE equi-zzinvoice_num,
zzinvoice_date TYPE equi-zzinvoice_date,
kund1 TYPE equz-kund1,
END OF t_equi,
DATA: it_equi TYPE TABLE OF t_equi,
SELECT equnr
aedat
matnr
sernr
kunde "Ship to
zzreg_date
zzin_indic
zzinvoice_num
zzinvoice_date
kund1 "Sold to
INTO TABLE it_equi
FROM equi AS a
INNER JOIN equz AS b
ON a~equnr = b~equnr
WHERE a~equnr IN s_equnr AND
* aedat GE gv_rdate AND
a~matnr IN s_matnr AND
a~sernr IN s_sernr AND
a~kunde IN r_shpbr_kunde AND
a~zzin_indic IN s_indic AND
b~datbi EQ c_datbi AND
b~kund1 IN r_sldbr_kund1 .
what is the wrong with this select query.. ?
its giving me error "The column name "EQUNR" is unclear ."
ThanksHi ,
write tablename or alias in select also
SELECT a~equnr and check.
Regards -
Daily morning 8 o clock , we need to execute a select query
Hi,
daily morning 8 o clock , we need to execute a select query.
How we can do this using dbms_scheduler? or any other ways?
db version : 10g
Thanks,
Kumar.
Message was edited by:
user548258Use daily and byhour parameters as shown in below link.
http://www.dba-oracle.com/t_dbms_scheduler_examples.htm -
Performance issue with the Select query
Hi,
I have an issue with the performance with a seclet query.
In table AFRU - AUFNR is not a key field.
So i had selected the low and high values into s_reuck and used it in Where condition.
Still i have an issue with the Performance.
SELECT SINGLE RUECK
RMZHL
IEDD
AUFNR
STOKZ
STZHL
FROM AFRU INTO table t_AFRU
FOR ALL ENTRIES IN T_ZSCPRT100
WHERE RUECK IN S_RUECK AND
AUFNR = T_ZSCPRT100-AUFNR AND
STOKZ = SPACE AND
STZHL = 0.
I had also cheked by createing an index for AUFNR in the table AFRU...it does not help.
Is there anyway that we can declare Key field while declaring the Internal table....?
ANy suggestions to fix the performance issue is apprecaited!
Regards,
KittuHi,
Thank you for your quick response!
Rui dantas, i have lill confusion...this is my code below :
data : t_zscprt type standard table of ty_zscprt,
wa_zscprt type ty_zscprt.
types : BEGIN OF ty_zscprt100,
aufnr type zscprt100-aufnr,
posnr type zscprt100-posnr,
ezclose type zscprt100-ezclose,
serialnr type zscprt100-serialnr,
lgort type zscprt100-lgort,
END OF ty_zscprt100.
data : t_zscprt100 type standard table of ty_zscprt100,
wa_zscprt100 type ty_zscprt100.
Types: begin of ty_afru,
rueck type CO_RUECK,
rmzhl type CO_RMZHL,
iedd type RU_IEDD,
aufnr type AUFNR,
stokz type CO_STOKZ,
stzhl type CO_STZHL,
end of ty_afru.
data : t_afru type STANDARD TABLE OF ty_afru,
WA_AFRU TYPE TY_AFRU.
SELECT AUFNR
POSNR
EZCLOSE
SERIALNR
LGORT
FROM ZSCPRT100 INTO TABLE T_ZSCPRT100
FOR ALL ENTRIES IN T_ZSCPRT
WHERE AUFNR = T_ZSCPRT-PRTNUM
AND SERIALNR IN S_SERIAL
AND LGORT IN S_LGORT.
IF sy-subrc <> 0.
MESSAGE ID 'Z2' TYPE 'I' NUMBER '41'. "BDCG87
stop."BDCG87
ENDIF.
ENDIF.
SELECT RUECK
RMZHL
IEDD
AUFNR
STOKZ
STZHL
FROM AFRU INTO TABLE T_AFRU
FOR ALL ENTRIES IN T_ZSCPRT100
WHERE RUECK IN S_RUECK AND
AUFNR = T_ZSCPRT100-AUFNR AND
STOKZ = SPACE AND
STZHL = 0.
Using AUFNR, get AUFPL from AFKO
Using AUFPL, get RUECK from AFVC
Using RUEKC, read AFRU
In other words, one select joining AFKO <-> AFVC <-> AFRU should get what you want.
This is my select query, would you want me to write another select query to meet this criteria..
From AUFNR> I will get AUFPL from AFKO> BAsed on AUFPL I will get RUECK, based on RUEKC i need to read AFRU..but i need to select few field from AFRu based on AUFNR....
ANy suggestions wil be appreciated!
Regards
Kittu -
How can i use index in select query.. facing problem with the select query.
Hi Friends,
I am facing a serious problem in one of the select query. It is taking a lot of time to fetch data in Production Scenario.
Here is the query:
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelat LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelatrprctr
WHERE rldnr = c_telstra_accounting
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
And rzzlstar in r_lstar
AND rpmax = c_max_period.
There are 5 indices present for Table ZTFTELAT.
Indices of ZTFTELAT:
Name Description
0 Primary key( RCLNT,RLDNR,RRCTY,RVERS,RYEAR,ROBJNR,SOBJNR,RTCUR,RUNIT,DRCRK,RPMAX)
005 Profit (RCLNT,RPRCTR)
1 Ledger, company code, account (RLDNR,RBUKRS, RACCT)
2 Ledger, company code, cost center (RLDNR, RBUKRS,RCNTR)
3 Account, cost center (RACCT,RCNTR)
4 RCLNT/RLDNR/RRCTY/RVERS/RYEAR/RZZAUFNR
Z01 Activity Type, Account (RZZLSTAR,RACCT)
Z02 RYEAR-RBUKRS- RZZZBER-RLDNR
Can anyone help me out why it is taking so much time and how we can reduce it ? and also tell me if I want to use index number 1 then how can I use?
Thanks in advance.Hi Shiva,
I am using two more select queries with the same manner ....
here are the other two select query :
***************1************************
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelpt LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelptrprctr
WHERE rldnr = c_telstra_projects
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
and rzzlstar in r_lstar
AND rpmax = c_max_period.
and the second one is
*************************2************************
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelnt LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelntrprctr
WHERE rldnr = c_telstra_networks
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
and rzzlstar in r_lstar
AND rpmax = c_max_period.
for both the above table program is taking very less time .... although both the table used in above queries have similar amount of data. And i can not remove the APPENDING CORRESPONDING. because i have to append the data after fetching from the tables. if i will not use it will delete all the data fetched earlier.
Thanks on advanced......
Sourabh -
How to create a triangle view with a select query?
I need help to build a select query that will create a triangle view.
Below is the table I have to query
*{color:#ff0000}INITIAL TABLE{color}*
*{color:#008000}AMOUNT | TRANSACTION_DATE | OPEN_DATE | TYPE{color}*
5 | 30-JAN-09 | 10-JAN-09 | A
10 | 12-JAN - 09 | 30-NOV-08 | A
20 | 30 - DEC - 08 | 15-OCT-08 | A
10 | 30 - DEC - 08 | 8 - OCT - 08 | A
*{color:#ff0000}THE FINAL TABLE I HAVE TO CREATE:{color}*
DEV_PERIOD - TO_CHAR(TRUNC(TRANSACTION_DATE,'Q'),'YYYY-Q') AS DEV_PERIOD
OPEN PERIOD - TO_CHAR(TRUNC(OPEN_DATE,'Q'),'YYYY-Q') AS OPEN_PERIOD
{color:#008000}*SUM of AMOUNT | DEV_PERIOD | OPEN_PERIOD | TYPE*{color}
5 | 2009 - 1 | 2009 - 1 | A
40 | 2009 - 1 | 2008 - 4 | A
30 | 2008 - 4 | 2008 - 4 | A
{color:#ff0000}*This is another view of the table (The triangle view)*{color}
| Dev_Period 2008- 1 | 2008 - 2| 2008 -3 | 2008 - 4 | 2009 -1 |
Open_Period |
2008 - 1..................... 0.......... 0............ 0........... 0.......... 0
2008 - 2 ..................................0............ 0........... 0.......... 0
2008 - 3................................................. 0........... 0.......... 0
2008 - 4 ..............................................................30......... 40
2009 - 1 .............................................................................5
Any ideas will be appreaciated.
Thank you!I think the first thing you need to do is look up "pivot query" in this newsgroup. And how complicated your query gets to be will depend on your database version (11 natively supports pivot queries). You have a variable number of columns in your result set (depending on how many quarters you have in your data.
I think once you get the columns sorted out, working out the numbers to put in each column will be relatively easy.
Jon -
How to create a Type Object with Dynamic select query columns in a Function
Hi Every One,
I'm trying to figure out how to write a piplined function that executes a dynamic select query and construct a Type Object in order to assigned it to the pipe row.
I have tried by
SELECT a.DB_QUERY INTO actual_query FROM mytable a WHERE a.country_code = 'US';
c :=DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c,actual_query,DBMS_SQL.NATIVE);
l_status := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt LOOP
DBMS_SQL.DEFINE_COLUMN(c,j,v_val,2000);
END LOOP;
FOR j in 1..col_cnt LOOP
DBMS_SQL.COLUMN_VALUE(c,j,v_val);
END LOOP;
But got stuck, how to iterate the values and assign to a Type Object from the cursor. Can any one guide me how to do the process.
Thanks,
mallikj2Hi Justin,
First of thanks for your reply, and coming to my requirement, I need to report the list of items which are there in the dynamic select statement what am getting from the DB. The select statement number of columns may vary in my example for different countries the select item columns count is different. For US its '15', for UK it may be 10 ...like so, and some of the column value might be a combination or calculation part of other table columns (The select query contains more than one table in the from clause).
In order to execute the dynamic select statement and return the result i choose to write a function which will parse the cursor for dynamic query and then iterate the values and construct a Type Object and append it to the pipe row.
Am relatively very new for these sort of things, welcome in case of any suggestions to make it simple (Instead of the function what i thought to work with) also a sample narrating the new procedure will be appreciated.
Thanks in Advance,
mallikj2. -
How to use Field-symbol with dynamic select query
Can anybody tell me, how to use field-symbols in the dynamic select query.
FIELD-SYMBOLS <fs> { typing | STRUCTURE struc DEFAULT dobj }.
1. ... typing
2. ... STRUCTURE struc DEFAULT dobj
The FIELD-SYMBOLS statement declares a field symbol <fs>. The name conventions apply to the name fs. The angle brackets of the field symbols indicate the difference to data objects and are obligatory. You can declare field symbols in any procedure and in the global declaration section of an ABAP program, but not in the declaration section of a class or an interface. You can use a field symbol in any operand position in which it is visible and which match the typing defined using typing.
After its declaration, a field symbol is initial - that is, it does not reference a memory area. You have to assign a memory area to it (normally using the ASSIGN statement) before you can use it as an operand. Otherwise an exception will be triggered.
eg.
FIELD-SYMBOLS <fs> TYPE ANY.
DATA: BEGIN OF line,
string1(10) VALUE '0123456789',
string2(10) VALUE 'abcdefghij',
END OF line.
WRITE / line-string1+5.
ASSIGN line-string1+5(*) TO <fs>.
WRITE / <fs>.
output:
56789
56789
reward if helpful
anju -
Issue with one Select Query in PBS Archive Translation Tool
Hi All,
Iam having X mark symbol against the select query from EKET table
This is the select query in my actual program and when i convert this using PBS Archive Translation Tool i have a X mark against this select query
SELECT SINGLE BANFN FROM EKET INTO V_BANFN WHERE EBELN = BSEG-EBELN AND
EBELP = BSEG-EBELP AND
ETENR = '0001'.
I guess i have to modify this select query because EKET table has transaction data and we cannot ignore this X mark.
Let me know if iam wrong
ALso , iam confused whether a select query with X needs to fixed or can be ignored
ThanksHi ,
Any Suggestions
Thanks -
How to reduce functions with simple select query?
I have a function to identify the root parent of a particular id. I use this in function in select query,which invokes function for every row in table.I need to merge the function inside the query itself.Please suggest me.
Function
CREATE OR REPLACE FUNCTION fnroot(v_id int ) return int as
v_left int;
v_right int;
v-result int;
begin
select left,right into v_left,v_right from sam where id=v_id;
select id into v_result from sam
where id in (select id from mst m where m.depth=2 )
and left < v_left and right > v_right;
return v_result;
end
query:
select fnroot(s.id) from master s;Hi,
Ramin's idea is very good. You must use joins in function as below
CREATE OR REPLACE FUNCTION fnroot(v_id int ) return int as
v_result int;
Begin
select s.id into v_result
from sam s on s.id = v_id
left join sam s2 on (s2.id in (select id from mst m where m.depth = 2) and s2.left < s.left and s2.right > s.right)
return v_result;
End;
Regards
Mahir M. Quluzade -
Here is my code , i dont have any experience with writing the nested sql , i got the below code , which needs to be modified adding a case statement which will show util_rate for 2 conditions
1. given in where condition ( to_char(time_stamp,'HH24') >= '09' and to_char(time_stamp,'HH24') <= '19')
2.Apposite to the condition above (to_char(time_stamp,'HH24') < '09'and to_char(time_stamp,'HH24') > '19')
could anybody please help me in adding the 2nd condition to the below query , please share any documentation you have for learning how to write nested sql,
Thank you
select device,time_stamp,
sum(ActiveHRS)/sum(AvailHRS) as RATE
from
select device,time_stamp,
case when usage >0 then 1
else 0 end as ActiveHRS,
'1' as AvailHRS
from
select device,time_stamp,
sum(case
when state = 9 then 0
when state = 0 then 0
else 1 end) as usage
from A
where to_char(time_stamp,'HH24') >= '09'
and to_char(time_stamp,'HH24') <= '19'
and to_char(time_stamp, 'D') in (2,3,4,5,6)
group by device, time_stamp
group by device,time_stampHere is the DDL :
desc rumi_all
Name Null Type
RUMI_DEVICE VARCHAR2(20)
STATE NUMBER(38)
TIME_STAMP DATE
LOCATION VARCHAR2(50) Here is some sample data :
RUMI_DEVICE STATE TIME_STAMP LOCATION
10.45.28.86 0 15-JUN-10 WA-102
10.45.28.51 0 15-JUN-10 WA-102
10.45.28.63 0 15-JUN-10 WA-102
10.45.29.47 9 15-JUN-10 WA-120I used the below query to get the util for the hours 9am - 7pm
select rumi_device,time_stamp,
sum(ActiveHRS)/sum(AvailHRS) as RATE
from
select rumi_device,time_stamp,
case when usage >0 then 1
else 0 end as ActiveHRS,
'1' as AvailHRS
from
select rumi_device,time_stamp,
sum(case
when state = 9 then 0
when state = 0 then 0
else 1 end) as usage
from rumi_all
where to_char(time_stamp,'HH24') >= '09'
and to_char(time_stamp,'HH24') <= '19'
and to_char(time_stamp, 'D') in (2,3,4,5,6)
group by rumi_device, time_stamp
group by rumi_device,time_stamp
Acquired Out for the above query :
RUMI_DEVICE TIME_STAMP UTIL_RATE
10.45.29.47 15-JUN-10 0.234
10.45.28.63 15-JUN-10 0.123
10.45.29.47 15-JUN-10 0.987
10.45.29.47 16-JUN-10 0.23Desired output :I want 2 extra columns which shows util rate for the above condition i.e 9am - 7pm(core hours) and also opposite to that condition after 7pm - before 9am(say, non core hours)
Desired out put :
RUMI_DEVICE TIME_STAMP Core_Util_Rate Non_Core_UtilRate
10.45.29.4 15-JUN-10 0.234 0.003
10.45.28.63 15-JUN-10 0.123 0.001
10.45.29.47 15-JUN-10 0.987 0.023
10.45.29.47 16-JUN-10 0.23 0Hope this helps in answering my question , and also could you please share some document to learn writing nested sql's , i always had tough time in understanding this :-( -
Hi Guys,
For example I have 2 tables:
I wish to list out the owner, table_name, total count of chain row of the table, num rows by joining the below 2 tables.
Can advise how can i do it?
Currently i'm doing it by executing this statement but very slow:
select a.owner_name, a.table_name, count(*), b.num_Rows
from system.chained_rows a, dba_tables b
where a.owner_name=b.owner
and a.table_name=b.table_name
and b.num_Rows>0
group by a.owner_name, a.table_name, b.num_Rows
having count(*)*100/b.num_Rows>10;
TABLE INFORMATION:
1. CHAINED_ROWS (one table name can have multiple chain row id records)
column:
1. owner
2. table_name
3. chain row id
2. DBA_TABLES (one table name only one record)
column:
1. owner
2. table_name
3. num_rows
thanksHi,
I think u mis-inteprete my question.
My question is more on how to formulate a sql to get the output i hope so.. and not how to get chain counts.
I wish to list out the owner, table_name, total count of chain row of the table, num rows by joining the below 2 tables.
Can advise how can i do it?
Currently i'm doing it by executing this statement but very slow:
select a.owner_name, a.table_name, count(*), b.num_Rows
from system.chained_rows a, dba_tables b
where a.owner_name=b.owner
and a.table_name=b.table_name
and b.num_Rows>0
group by a.owner_name, a.table_name, b.num_Rows
having count(*)*100/b.num_Rows>10;
TABLE INFORMATION:
1. CHAINED_ROWS (one table name can have multiple chain row id records)
column:
1. owner
2. table_name
3. chain row id
2. DBA_TABLES (one table name only one record)
column:
1. owner
2. table_name
3. num_rows
thanks -
I need to do a select query against a mysql db in my java project
Hey guys!
I hope you can help me! I have a column "date" in my table of my MySQL DataBase. Well, when I prepare my statement in my java program, I can't compare a date to get all the rows where the date is the one that I'm trying to compare.
I'm trying to do something like this:
ResultSet rs = statement.executeQuery("select * from table where datecolumn=' "+ new java.sql.date(mydate.getTime()) + ' ");
But I have not been succesful yet. Can anyone, please, help me? How do I write the select if I have a variable of the kind java.util.Date and I want to compare it with the one in my DB?
Cheers!!!!If there are too many fields to have pre-generated SQL for every possible subset, build the query at runtime. Here's some code. The array dates holds null for date fields that shouldn't be used to filter the data.
import java.sql.*;
public class Example {
String[] dateColumns = {
"date1",
"date2",
"date3",
void f(Connection c, Date[] dates) throws SQLException {
StringBuilder b = new StringBuilder("SELECT * FROM tableX WHERE 0=0 ");
for(int i=0; i<dates.length; ++i) {
if (dates[i] != null) {
b.append("AND ").append(dateColumns).append(" = ? ");
String SQL = b.toString();
System.out.println("SQL = " + SQL);
PreparedStatement ps = c.prepareStatement(SQL);
for(int i=0, offset=1; i<dates.length; ++i) {
if (dates[i] != null) {
ps.setDate(offset, dates[i]);
offset++;
//use ps
}There's nothing tricky going on, the code just generates the obvious SQL.
Maybe you are looking for
-
Ipod not syncing correctly and songs skipping on ipod but not itunes/wmp
My old ipod was having this same issue(so I presumed it was broken) and I wanted to get a new one as the old one was an 8 gig and didnt really have enough size for me so I bought a new 32 gig ipod. Unfortunately this new one is having the exact same
-
When exporting from lightroom 3 I want to export the largest possible photo my camera will allow. I am using a Sony Nex 3, 14 megapixel camera. I am shooting in raw format. In the photo sizing section I choose 1200 pixels, thinking this will creat
-
What amplifier, speaker, other do I need to connect my iMac to a 5.1 speakers? The iMac is the TV, home theater, sound system, ... of the family. All I have is the iMac right now, but I saw decent 5.1 speakers from Klipsh and I am now wondering what
-
Cannot keep an internet connection
I did not have the problem with my last computer, but with this new Gateway I bought, I can keep an internet connection for about 5-10 minutes, then I will lose it for 3-6 minutes. Other two computers in the house work fine when this one is out. We
-
Hi, I am sailaja, I am developing an application, to that application for authentication/authorization I am using JAAS. But my problem is, in my application I am using 3rd party tool for document processing, for that tool I need to access a servlet f