Solved

SQL statement issues

Posted on 2003-11-19
4
377 Views
Last Modified: 2010-04-01
hi, i have this jsp page,

<input type="text" name="p_code" />
<input type="text" name="filterA" />
 <input type="text" name="ex_A" />

<input type="text" name="filterB" />
 <input type="text" name="ex_B" />

<input type="text" name="filterC" />
 <input type="text" name="ex_C" />

<input type="text" name="filterD" />
<input type="text" name="ex_D" />


<input type="submit" value="submit" />


and this is my DB schema,

P_code    Filter       Expired Date


And i wish to pump data into this table to make it like this,

P_code       Filter       Expired Date
A123          Filter A        12/2/2003
A123          Filter B        25/2/2003
.
.
.
.

How would be my sql statement? I only need the insert statement...

Thank You.
0
Comment
Question by:superman19
4 Comments
 
LVL 15

Expert Comment

by:dualsoul
ID: 9785094
i assume you get form parameters in your servlet to variables:
   pCode
    fileterA, filterB, fileterC
    ex_a, ex_b, ex_c
with request.getParameter(), like this one:
...............
    pCode=request.getParameter("p_code);
...............
and then just 3 SQL statements to update your DB:
.........................
insert into yourtable (P_code, Filter, ExpiredDate) values (pCode, filterA, ex_a)
insert into yourtable (P_code, Filter, ExpiredDate) values (pCode, filterB, ex_b)
insert into yourtable (P_code, Filter, ExpiredDate) values (pCode, filterC, ex_c)
..............................
0
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 250 total points
ID: 9786275
What dualsoul is saying will work perfectly but I would have done it like this...
<input type="text" name="p_code" />
<input type="text" name="filter" />
<input type="text" name="ex" />

<input type="text" name="filter" />
<input type="text" name="ex" />

<input type="text" name="filter" />
<input type="text" name="ex" />

<input type="text" name="filter" />
<input type="text" name="ex" />

Now in servlet
String[] filter=request.getParameterValues("filter");
String[] ex=request.getParameterValues("ex");
String p_code=request.getParameter("p_code');
for(int i=0; i<filter.length; i++)
insert into yourtable (P_code, Filter, ExpiredDate) values (p_code, filter[0], ex[0]);

This is less code and extensible to more than three inserts in the system..
Regards
0
 
LVL 3

Expert Comment

by:applekanna
ID: 9790486
Kuldeep ,
I have a doubt here , is the order of appreacnce of data on the form same as the way it appreas to the servlet
I mean if have

<input type="text" name="filter" value = "one"/>
<input type="text" name="filter" value = "two"/>

the at receiving end
filter[0] = one
filter[1] = two  ?

Thank you
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9793388
>> , is the order of appreacnce of data on the form same as the way it appreas to the servlet
I mean if have
YES!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
logging jar 1 106
eclipse problems view not showing all the time 4 87
constructor overloading 2 79
countXY challenge 28 142
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now