[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL statement issues

Posted on 2003-11-19
4
Medium Priority
?
399 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

With the evolution of technology, we have finally reached a point where it is possible to have home automation features like having your thermostat turn up and door lock itself when you leave, as well as a complete home security system. This is a st…
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

649 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