Is there a better way of doing this? (multifileupload/forms/mysql)
Hi all.
I've managed to cobble together a page that will let me upload three files paths and three text boxes to a mysql database. the the files also go to specific directories depending on conditions.
what im looking for is to see if there is a more efficient way of doing this. im mainly looking at the value and name strings along with the preparedstatement insert. i'd like to see if i can make it more dynamic so i don't have to predefine an amount anywhere.
This code is working as is if anyone wants to use it in it's current state.
here is the form
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"/>
<TITLE>File Upload Page</TITLE>
</HEAD>
<BODY>Upload Files
<FORM name="filesForm" action="uploadTestProccess.jsp" method="POST" enctype="multipart/form-data">
File 1:<input type="file" name="file1"/><br/>
File 2:<input type="file" name="file2"/><br/>
File 3:<input type="file" name="file3"/><br/>
text4: <input type="text" name="textField4" value="this is a test4"><br>
text5: <input type="text" name="textField5" value="this is a test5"><br>
text6: <input type="text" name="textField6" value="this is a test6"><br>
<input type="submit" name="submit" value="Upload Files"/>
</FORM>
</BODY>
</HTML>and here is the insert
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="org.apache.commons.fileupload.DiskFileUpload"%>
<%@ page import="org.apache.commons.fileupload.FileItem"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.io.File"%>
<%@ page import="java.sql.*"%>
<%!
String value4;
String value5;
String value6;
String name1;
String name2;
String name3;
String dir;
Connection dbconn;
ResultSet result;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<%
//System.out.println("Content Type ="+request.getContentType());
DiskFileUpload fu = new DiskFileUpload();
// If file size exceeds, a FileUploadException will be thrown
fu.setSizeMax(10000000);
List fileItems = fu.parseRequest(request);
Iterator itr = fileItems.iterator();
for(int i=1; itr.hasNext(); i++){
FileItem fi = (FileItem)itr.next();
//Check if not form field so as to only handle the file inputs
//else condition handles the submit button input
if(!fi.isFormField()) {
out.print(i);
//out.println("\nNAME: "+fi.getName());
//out.println("SIZE: "+fi.getSize());
if(i==1){
name1 = fi.getName();
dir = "file1/";
} else if (i==2){
name2 = fi.getName();
dir = "file2/";
} else {
name3 = fi.getName();
dir = "file3/";
File fNew= new File(application.getRealPath("examples1/" + dir), fi.getName());
//out.println(fNew.getAbsolutePath());
fi.write(fNew);
out.print("success<br>" + fi.getName() + "<br>");
} else {
//gets field names and values
// out.println("Field ="+fi.getFieldName());
String name = fi.getFieldName();
if(i==4){
value4 = fi.getString();
} else if (i==5){
value5 = fi.getString();
} else if (i==6) {
value6 = fi.getString();
String value = fi.getString();
out.println("Found field with name <b>"+ name +"</b> and value <b>"+ value +"</b><br>");
Class.forName("org.gjt.mm.mysql.Driver");
dbconn = DriverManager.getConnection("jdbc:mysql://localhost:3306/xxx?user=root&password=xxx");
PreparedStatement sql = dbconn.prepareStatement("INSERT INTO uploadtest (file1, file2, file3, four, five, six) VALUES (?,?,?,?,?,?)");
sql.setString(1, name1);
sql.setString(2, name2);
sql.setString(3, name3);
sql.setString(4, value4);
sql.setString(5, value5);
sql.setString(6, value6);
int result = sql.executeUpdate();
%>
<body>
<!--Upload Successful!!-->
</body>
</html>
anyone?
Similar Messages
-
Is there a better way of doing this?
Finally managed to get navigation to work the way I want!!!
But not being an expert at Oracle PL/SQL i'm sure this code could be written a better way.
I'm currently looping through the sublinks twice, first time to get a count second time to display the actual links. the reason for this is the bottom link needs a different style. Anyway here is the code I am using:
<oracle>
declare
x number;
y number;
begin
x := 0;
y := 0;
for c1 in (
select id, display_name, name
from #owner#.WWSBR_ALL_FOLDERS
where parent_id = #PAGE.PAGEID# and caid=1917 and DISPLAY_IN_PARENT_FOLDER = 1
order by display_name
loop
x := x+1;
end loop;
htp.p('<tr><td id="sidenavtop"><strong>#TITLE#</strong></td></tr>');
for c1 in (
select id, display_name, name
from #owner#.WWSBR_ALL_FOLDERS
where parent_id = #PAGE.PAGEID# and caid=1917 and DISPLAY_IN_PARENT_FOLDER = 1
order by display_name
loop
y := y+1;
if x = y then
htp.p('<TR><TD id="sidenavbottom">'||c1.display_name||'</TD></TR>');
else
htp.p('<TR><TD id="sidenavitem">'||c1.display_name||'</TD></TR>');
end if;
end loop;
end;
</oracle>Well, you could fetch the count into a local variable, e.g.
SELECT count(*)
INTO x
FROM ...
WHERE ...;
and move on, but then you are doing two fetches. I'm really sleepy at the moment, so it's possible this is logically and syntactically fouled up, but another option may be:
DECLARE
CURSOR c1 IS
select id, display_name, name
from #owner#.WWSBR_ALL_FOLDERS
where parent_id = #PAGE.PAGEID# and caid=1917 and DISPLAY_IN_PARENT_FOLDER = 1
order by display_name;
r1 c1%ROWTYPE;
l_display_name wwsbr_all_folders.display_name%TYPE;
BEGIN
htp.p('<tr><td id="sidenavtop">#TITLE#</td></tr>');
OPEN c1;
FETCH c1 INTO r1;
l_display_name := r1.display_name;
--hang on to the display name
WHILE c1%FOUND LOOP
FETCH c1 INTO r1;
--see if there's another row...
IF c1%FOUND THEN
--if so, ouput the current value of l_display_name as sidenavitem
htp.p('<TR><TD id="sidenavitem">'|| l_display_name||'</TD></TR>');
l_display_name := r1.display_name;
ELSE
--if not, output the current value of l_display_name as sidenavbottom
htp.p('<TR><TD id="sidenavbottom">'|| l_display_name||'</TD></TR>');
END IF;
END LOOP;
CLOSE c1;
end;
Hope this helps!
-John
Message was edited by:
John Hopkins -
Hello everyone,
So I'm going to blurt out two classes of code. First is a plain entity bean and the second is a helper class with two static methods to help me to convert Object into byte[] and vice versa without much worrying.
Now the problem is, how to persist this entity bean and it's two Objects (two Lists) in a more "J2EE5 way". I just need to store these two Objects, or any Serializable Object, into persistent storage. So how to avoid this serialization by-hand that I'm doing... ?
Thank you for your interest - and help :),
Samuli
Maybe using a @Lob notation or such? I've tried, but I can't get it workign. @Lob itself is not enough since it results in casting problems when retrieveing the data back from the persistent storage.
And oh, I'm just using the simple CMP with this.. EJB using EntityManager's persist method to store and so on..
EntityBean class (imports and packages excluded)
@Entity
public class MessageHandlerChain implements java.io.Serializable {
@TableGenerator(
name="messageHandlerChainIDGenerator",
allocationSize=1,
initialValue=1
@GeneratedValue(
generator="messageHandlerChainIDGenerator",
strategy=GenerationType.TABLE
@Id
private Integer messageHandlerChainID;
@Lob
private byte[] messageHandlers;
@Lob
private byte[] messageHandlerProperties;
@Transient
private List<String> messageHandlersObj = new ArrayList<String>();
@Transient
private List<Map<String,String>> messageHandlerPropertiesObj = new ArrayList<Map<String,String>>();
* Constructs an empty instance of <code>MessageHandlerChain</code> without any properties.
public MessageHandlerChain() {
public Integer getMessageHandlerChainID() {
return messageHandlerChainID;
public void setMessageHandlerChainID(Integer messageHandlerChainID) {
this.messageHandlerChainID = messageHandlerChainID;
public List<String> getMessageHandlers() {
return messageHandlersObj;
public void setMessageHandlers(List<String> messageHandlersObj) {
if (messageHandlersObj == null) {
System.out.println("[MessageHandlerChain] setMessageHandlers() can't be given a null value.");
return;
this.messageHandlersObj = messageHandlersObj;
public List<Map<String,String>> getMessageHandlerProperties() {
return messageHandlerPropertiesObj;
public void setMessageHandlerProperties(List<Map<String,String>> messageHandlerPropertiesObj) {
if (messageHandlerPropertiesObj == null) {
System.out.println("[MessageHandlerChain] setMessageHandlerProperties() can't be given a null value.");
return;
this.messageHandlerPropertiesObj = messageHandlerPropertiesObj;
@PrePersist
* This method is invoked by the persistence provider prior to every persist operation.
* This is needed because we need to convert, serialize, our <code>@Transient</code> annotated objects into <code>byte[]</code> streams
* so that they can be written into the database.
public void prePersist() {
System.out.println("[MessageHandlerChain] prePersist()");
if (messageHandlerPropertiesObj != null)
messageHandlerProperties = BlobConverter.objectToBytes(messageHandlerPropertiesObj);
if (messageHandlersObj != null)
messageHandlers = BlobConverter.objectToBytes(messageHandlersObj);
@PostLoad
* This method is invoked by the persistence provider after every load operation.
* This is needed because we need to convert, deserialize, <code>byte[]</code> streams back to our <code>@Transient</code> annotated objects.
public void postLoad() {
System.out.println("[MessageHandlerChain] postLoad()");
try {
if (messageHandlerProperties != null)
messageHandlerPropertiesObj = (List<Map<String,String>>)BlobConverter.bytesToObject(messageHandlerProperties);
if (messageHandlers != null)
messageHandlersObj = (List<String>)BlobConverter.bytesToObject(messageHandlers);
} catch (ClassCastException e) {
System.out.println("[MessageHandlerChain] postLoad() Class Cast Exception: "+e);
public String toString() {
return "[MessageHandlerChain] messageHandlerChainID="+getMessageHandlerChainID()+", messageHandlers="+getMessageHandlers()+", messageHandlerProperties="+getMessageHandlerProperties();
The helper class
* <code>BlobConverter</code> is a simple helper class to encode and decode classes as byte[] so that they can be stored into persistent storage.
* @author Samuli Piela
public class BlobConverter {
public static byte[] objectToBytes(Object o) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
ObjectOutputStream oos = null;
try {
oos = new ObjectOutputStream(baos);
oos.writeObject(o);
return baos.toByteArray();
} catch (InvalidClassException e) {
System.out.println("objectToBytes("+o+"): Invalid Class: "+e);
} catch (NotSerializableException e) {
System.out.println("objectToByte("+o+"): Object not serializable: "+e);
} catch (Exception e) {
System.out.println("objectToBytes("+o+"): Exception: "+e);
} finally {
if (oos != null) {
try {
oos.close();
} catch (IOException e) {
System.out.println("objectToBytes(): Stream could not be closed: "+e);
if (baos != null) {
try {
baos.close();
} catch (IOException e) {
System.out.println("objectToBytes(): Stream could not be closed: "+e);
oos = null;
baos = null;
return null;
public static Object bytesToObject(byte[] byteArray) {
ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
ObjectInputStream ois = null;
try {
ois = new ObjectInputStream(bais);
Object o = ois.readObject();
return o;
} catch (ClassNotFoundException e) {
System.out.println("bytesToObject(): Class not found: "+e);
} catch (InvalidClassException e) {
System.out.println("bytesToObject(): Invalid Class: "+e);
} catch (IOException e) {
System.out.println("bytesToObject(): IOException: "+e);
} catch (Exception e) {
System.out.println("bytesToObject(): Exception: "+e);
} finally {
if (ois != null) {
try {
ois.close();
} catch (IOException e) {
System.out.println("bytesToObject(): Stream could not be closed: "+e);
if (bais != null) {
try {
bais.close();
} catch (IOException e) {
System.out.println("bytesToObject(): Stream could not be closed: "+e);
ois = null;
bais = null;
return null;
}anyone?
-
I am having trouble transferring files from an old MacBook (2007) to a MacBook Air over a wireless network. The connection was interrupted and the time was over 24 hours. Is there a better way to do this? I'm using Migration assistant. The lack of an ethernet port on MacBook air does not help.
William ..
Alternative data transfer methods suggested here > OS X: How to migrate data from another Mac using Mavericks -
Is there a better way to do this projection/aggregate query?
Hi,
Summary:
Can anyone offer advice on how best to use JDO to perform
projection/aggregate queries? Is there a better way of doing what is
described below?
Details:
The web application I'm developing includes a GUI for ad-hoc reports on
JDO's. Unlike 3rd party tools that go straight to the database we can
implement business rules that restrict access to objects (by adding extra
predicates) and provide extra calculated fields (by adding extra get methods
to our JDO's - no expression language yet). We're pleased with the results
so far.
Now I want to make it produce reports with aggregates and projections
without instantiating JDO instances. Here is an example of the sort of thing
I want it to be capable of doing:
Each asset has one associated t.description and zero or one associated
d.description.
For every distinct combination of t.description and d.description (skip
those for which there are no assets)
calculate some aggregates over all the assets with these values.
and here it is in SQL:
select t.description type, d.description description, count(*) count,
sum(a.purch_price) sumPurchPrice
from assets a
left outer join asset_descriptions d
on a.adesc_no = d.adesc_no,
asset_types t
where a.atype_no = t.atype_no
group by t.description, d.description
order by t.description, d.description
it takes <100ms to produce 5300 rows from 83000 assets.
The nearest I have managed with JDO is (pseodo code):
perform projection query to get t.description, d.description for every asset
loop on results
if this is first time we've had this combination of t.description,
d.description
perform aggregate query to get aggregates for this combination
The java code is below. It takes about 16000ms (with debug/trace logging
off, c.f. 100ms for SQL).
If the inner query is commented out it takes about 1600ms (so the inner
query is responsible for 9/10ths of the elapsed time).
Timings exclude startup overheads like PersistenceManagerFactory creation
and checking the meta data against the database (by looping 5 times and
averaging only the last 4) but include PersistenceManager creation (which
happens inside the loop).
It would be too big a job for us to directly generate SQL from our generic
ad-hoc report GUI, so that is not really an option.
KodoQuery q1 = (KodoQuery) pm.newQuery(Asset.class);
q1.setResult(
"assetType.description, assetDescription.description");
q1.setOrdering(
"assetType.description ascending,
assetDescription.description ascending");
KodoQuery q2 = (KodoQuery) pm.newQuery(Asset.class);
q2.setResult("count(purchPrice), sum(purchPrice)");
q2.declareParameters(
"String myAssetType, String myAssetDescription");
q2.setFilter(
"assetType.description == myAssetType &&
assetDescription.description == myAssetDescription");
q2.compile();
Collection results = (Collection) q1.execute();
Set distinct = new HashSet();
for (Iterator i = results.iterator(); i.hasNext();) {
Object[] cols = (Object[]) i.next();
String assetType = (String) cols[0];
String assetDescription = (String) cols[1];
String type_description =
assetDescription != null
? assetType + "~" + assetDescription
: assetType;
if (distinct.add(type_description)) {
Object[] cols2 =
(Object[]) q2.execute(assetType,
assetDescription);
// System.out.println(
// "type "
// + assetType
// + ", description "
// + assetDescription
// + ", count "
// + cols2[0]
// + ", sum "
// + cols2[1]);
q2.closeAll();
q1.closeAll();Neil,
It sounds like the problem that you're running into is that Kodo doesn't
yet support the JDO2 grouping constructs, so you're doing your own
grouping in the Java code. Is that accurate?
We do plan on adding direct grouping support to our aggregate/projection
capabilities in the near future, but as you've noticed, those
capabilities are not there yet.
-Patrick
Neil Bacon wrote:
Hi,
Summary:
Can anyone offer advice on how best to use JDO to perform
projection/aggregate queries? Is there a better way of doing what is
described below?
Details:
The web application I'm developing includes a GUI for ad-hoc reports on
JDO's. Unlike 3rd party tools that go straight to the database we can
implement business rules that restrict access to objects (by adding extra
predicates) and provide extra calculated fields (by adding extra get methods
to our JDO's - no expression language yet). We're pleased with the results
so far.
Now I want to make it produce reports with aggregates and projections
without instantiating JDO instances. Here is an example of the sort of thing
I want it to be capable of doing:
Each asset has one associated t.description and zero or one associated
d.description.
For every distinct combination of t.description and d.description (skip
those for which there are no assets)
calculate some aggregates over all the assets with these values.
and here it is in SQL:
select t.description type, d.description description, count(*) count,
sum(a.purch_price) sumPurchPrice
from assets a
left outer join asset_descriptions d
on a.adesc_no = d.adesc_no,
asset_types t
where a.atype_no = t.atype_no
group by t.description, d.description
order by t.description, d.description
it takes <100ms to produce 5300 rows from 83000 assets.
The nearest I have managed with JDO is (pseodo code):
perform projection query to get t.description, d.description for every asset
loop on results
if this is first time we've had this combination of t.description,
d.description
perform aggregate query to get aggregates for this combination
The java code is below. It takes about 16000ms (with debug/trace logging
off, c.f. 100ms for SQL).
If the inner query is commented out it takes about 1600ms (so the inner
query is responsible for 9/10ths of the elapsed time).
Timings exclude startup overheads like PersistenceManagerFactory creation
and checking the meta data against the database (by looping 5 times and
averaging only the last 4) but include PersistenceManager creation (which
happens inside the loop).
It would be too big a job for us to directly generate SQL from our generic
ad-hoc report GUI, so that is not really an option.
KodoQuery q1 = (KodoQuery) pm.newQuery(Asset.class);
q1.setResult(
"assetType.description, assetDescription.description");
q1.setOrdering(
"assetType.description ascending,
assetDescription.description ascending");
KodoQuery q2 = (KodoQuery) pm.newQuery(Asset.class);
q2.setResult("count(purchPrice), sum(purchPrice)");
q2.declareParameters(
"String myAssetType, String myAssetDescription");
q2.setFilter(
"assetType.description == myAssetType &&
assetDescription.description == myAssetDescription");
q2.compile();
Collection results = (Collection) q1.execute();
Set distinct = new HashSet();
for (Iterator i = results.iterator(); i.hasNext();) {
Object[] cols = (Object[]) i.next();
String assetType = (String) cols[0];
String assetDescription = (String) cols[1];
String type_description =
assetDescription != null
? assetType + "~" + assetDescription
: assetType;
if (distinct.add(type_description)) {
Object[] cols2 =
(Object[]) q2.execute(assetType,
assetDescription);
// System.out.println(
// "type "
// + assetType
// + ", description "
// + assetDescription
// + ", count "
// + cols2[0]
// + ", sum "
// + cols2[1]);
q2.closeAll();
q1.closeAll(); -
I have two apple accounts and one of which has my music on. I would like to move this music to the other account. Is there a simple way of doing this?
There is currently no way to merge accounts. The best option is to pick one, and use it consistantly.
HTH. -
I would like to duplicate the folders and apps that I have set up on my iPhone to my iPad. Is there a quick way of doing this without going through the whole process again manually?
You can restore your iPad with your iPhone backup but items that are iPhone only will not transfer. It should recreate all your folders. It can't hurt anything to try.
-
Is there a better way to do this function?
Hi,
I was just wondering if someone can suggest a better way of doing the function I have attached below. Basically, it is counting pulses (falling edges) over a 250ms time period and converting that to speed. There seems to be some cases where it counts lesser pulses for a longer period than 250ms which results in lower speeds, but physically the device doesnt run any slower. Or sometimes speed is higher. This code was written by someone else and I am trying to work it better.
V
P.S. There is an overall master While loop.
I may not be perfect, but I'm all I got!
Attachments:
counter_wait.JPG 87 KBVeeJay wrote:
@ yamaeda what do you mean by coercion dots? Can you explain in simpler terms.? Thanks!
V
coercion dots are those red dots on your arithmatic functions. That means you are dividing data of different types. For instance I32 and U8 would give you a coercion dot. What you will want to do is right click your constants, choose representation->[data type]. Either that, or you can go to the numeric-> conversion pallette (i think) thats where it is and convert numbers using the primitives there.
CLA, LabVIEW Versions 2010-2013 -
Is there a better way to do this with Flash?
I am new to Flash but am slowly teaching myself via Lynda.com etc
I have an image that I have added to a website via a content management system and want to make certain areas of that image into links to other sites.
I found this page that does the kind of thing I want to do, but it appears from looking at the source code that the person who has done this has cut the image up into several sections in order to fit it into a table: http://www3.imperial.ac.uk/staffdevelopment/postdocs1/guidance
Is there a better way to achieve the same kind of effect using Flash by making ares of an image into links and keeping the image as a whole?There are ways to keep the image whole and have portions of it linking to different places both in HTML and in Flash. In HTML you can use an image map. In Flash, you can just lay invisible buttons atop the image and use those to link.
-
Is there a better way to do this? Interactive graphics on a PDF
Hello
Part of a PDF form I am planning requires the user to place several marks on a series of dots.
I have partially achieved this using check boxes and many hidden objects.
http://www.hoodoomayhem.com/example/Example.pdf focus on the small dots in the upper right.
Is there a smarter way to achieve this without using thousands of hidden objects.
I am quite new to scripting and do appreciate any suggestions.
I look forward to some feedback
BonbeketThat update should only be a single statement - not within a loop. The basic structure here should be something like:
update central_printing_staging cps
set sent_for_printing_date = trim(sysdate)
where central_printing_staging_id in (select ...
from <variation of complex query>);
open p_centralprinting_refcursor
for <complex query snipped>;The only question I have is whether the ref cursor is supposed to reflect the updated values or not, or if the two are even related or not - can't tell without seeing the query. -
Why can't you print a cd jewel case listing of songs using iTunes. Is there some other way to do this without using iTunes?
Hi spider1950,
As long as you have the most recent update of iTunes (11.0.4), you should be able to print a jewel case insert directly from iTunes. You may find the following page useful:
Apple Support: Print CD Inserts
https://www.apple.com/findouthow/music/itunes.html#makecd-printinserts
Regards,
- Brenden -
I want to print from my iPad in my truck. Is there an easy way of doing this?
I want to print from my iPad from inside my truck. Is there an easy way to do this?
The bluetooth is generally meant for keyboards and speakers, no idea if it'd work with a printer.
I suppose you could shop for printers and look to see if one specifically mentions compantibility with iPads.
The iPad was created to be a consumption device. Used to consume data, watch movies, read books, listen to music. functionality like what you're wanting is beyond how the device was originally conceived, so it requires tweaking and fixing.
There are other devices out there that have more functionality, including some that might hardwire to a printer. The easy part would be power for the printer. A $25 inverter will give you that in your vehicle. -
I don't want to write too much code is there a different way of doing this
I am writing a precedure to check on the max test scores for different codes ('S01','S02'.S03') --there are more
then I need to insert the table if the record with the best score does not exists for example for b.sortest_tesc_code = 'BSV', I am writing a cursor
for each code (.sortest_tesc_code = 'S01') is there a way to do this different? so I cant do something like a.sortest_tesc_code in ('S01','S02'.S03') and store in a
variable then insert, the problem is that you can have a student that have only one test other that have two etc..etc.. is not consistent, also If the b.sortest_tesc_code = 'BSV') is already in the table I don't do an insert I will have to do an update if the sortest_test_score is greater since the student can submit scores more than once... In another words check if the record exists( b.sortest_tesc_code = 'BSV') if is there compare with the new max score and if the new max score is greater then update.. If the score (by code) is not in the table insert
Hope this is clear, this is what I have, I now it will work but it will be too much code..check for exists and not exists in two different precedures..
Thank you
CURSOR get_the_max_scores_S01_cur IS
SELECT
sortest_pidm, a.sortest_test_score, a.sortest_tesc_code,
a.sortest_test_date,a.sortest_equiv_ind
FROM
saturn.spriden, saturn.sortest a, saturn.stvtesc
WHERE
a.sortest_pidm = spriden_pidm
AND stvtesc_code = a.sortest_tesc_code
AND spriden_change_ind IS NULL
-----and a.sortest_tesc_code in ('S01','S02'.S03')
AND a.sortest_tesc_code = 'S01'
--and spriden_id = p_student_id --
---for test purposes
AND sortest_pidm = 133999 ----THE WILL BE A PARAMETER
AND a.sortest_test_score =
(SELECT MAX (b.sortest_test_score)
FROM saturn.sortest b
WHERE a.sortest_tesc_code = b.sortest_tesc_code
AND a.sortest_pidm = b.sortest_pidm)
AND NOT EXISTS
(SELECT 1 FROM saturn.sortest b
WHERE A.sortest_tesc_code = b.sortest_tesc_code
AND a.sortest_pidm = b.sortest_pidm
and b.sortest_tesc_code = 'BSV');
BEGIN
UTL_FILE.fclose_all;
v_file_handle := UTL_FILE.fopen (v_out_path, v_out_file, 'a');
UTL_FILE.put_line (v_file_handle,
CHR (10) || TO_CHAR (SYSDATE, 'DD-MON-YYYY HH:MI:SS'));
UTL_FILE.put_line (v_file_handle, 'sortest_best_sct_scorest');
--check for an open cursor before opening
IF get_the_max_scores_S01_cur%ISOPEN
THEN
CLOSE get_the_max_scores_S01_cur;
END IF;
OPEN get_the_max_scores_S01_cur;
LOOP
FETCH get_the_max_scores_S01_cur
INTO v_pidm, v_tscore, v_testcode,
v_test_date, v_equiv_ind;
EXIT WHEN get_the_max_scores_S01_cur%NOTFOUND;
IF get_the_max_scores_S01_cur%FOUND
THEN
INSERT INTO saturn.sortest
(sortest_pidm,sortest_tesc_code,sortest_test_date,sortest_test_score,
sortest_activity_date,sortest_equiv_ind,sortest_user_id,sortest_data_origin)
VALUES
v_pidm,
'BSV',
v_test_date,
v_tscore,
sysdate,
v_equiv_ind,
p_user,
'best_test_scores process'
END IF;
END LOOP;
COMMIT;
---Initialize variables
v_pidm := NULL;
v_test_date := NULL;
v_tscore := NULL;
v_equiv_ind := NULL;
v_testcode := NULL;
CLOSE get_the_max_scores_S01_cur;
----then another do the same for S02...S03Thank you, here is the code, I change the name of the tables, but it is the same concept.what I need is to extract the max score for each code (s01,s02,s03,s04)
then insert a record with a different code in the same table
BSM Best Math SAT (S01)
BSW Best writing SAT (S04)
BSC Best READING SAT (S03)
BSE Best READING SAT (S02)
I need to be able to check if the BS codes are already in the table (BSM...BSC..) IF they are not do an insert and if they are do an update get the maximun score
again (the students can submit more than one score form the same code and any date) and if the maximun is different(greater) of what is already in the database (with the BSM...BSC.. codes) do an update, IF NOT if is the same or less don't update...
I need the PERSON table because I need to use the ID as a parameter they (user) can run the process for one ID or all the records in the table TEST
Thank you, I hope is clear
create table TEST
TEST_PIDM NUMBER(8) NOT NULL,
TEST_TESC_CODE VARCHAR2(4 CHAR) NOT NULL,
TEST_TEST_DATE DATE NOT NULL,
TEST_TEST_SCORE VARCHAR2(5 CHAR) NOT NULL,
TEST_ACTIVITY_DATE DATE NOT NULL,
TEST_EQUIV_IND VARCHAR2(1 CHAR) NOT NULL
INSERT INTO TEST
( TEST_PIDM, TEST_TESC_CODE,TEST_TEST_DATE, TEST_TEST_SCORE, TEST_ACTIVITY_DATE,TEST_EQUIV_IND)
SELECT
128019,'EB' ,TO_DATE( '01-JUN-2004', 'DD-MON-YYYY'),'710',SYSDATE,'N'
FROM DUAL;
INSERT INTO TEST
( TEST_PIDM, TEST_TESC_CODE,TEST_TEST_DATE, TEST_TEST_SCORE, TEST_ACTIVITY_DATE,TEST_EQUIV_IND)
SELECT
128019,'M2' ,TO_DATE( '01-JUN-2005', 'DD-MON-YYYY'),'710',SYSDATE,'N'
FROM DUAL;
INSERT INTO TEST
( TEST_PIDM, TEST_TESC_CODE,TEST_TEST_DATE, TEST_TEST_SCORE, TEST_ACTIVITY_DATE,TEST_EQUIV_IND)
SELECT
128019,'S01' ,TO_DATE( '01-JUN-2005', 'DD-MON-YYYY'),'750',SYSDATE,'N'
FROM DUAL;
INSERT INTO TEST
( TEST_PIDM, TEST_TESC_CODE,TEST_TEST_DATE, TEST_TEST_SCORE, TEST_ACTIVITY_DATE,TEST_EQUIV_IND)
SELECT
128019,'S01' ,TO_DATE( '01-JUN-2005', 'DD-MON-YYYY'),'720',SYSDATE,'N'
FROM DUAL;
INSERT INTO TEST
( TEST_PIDM, TEST_TESC_CODE,TEST_TEST_DATE, TEST_TEST_SCORE, TEST_ACTIVITY_DATE,TEST_EQUIV_IND)
SELECT
128019,'S02' ,TO_DATE( '01-JUN-2005', 'DD-MON-YYYY'),'740',SYSDATE,'N'
FROM DUAL;
INSERT INTO TEST
( TEST_PIDM, TEST_TESC_CODE,TEST_TEST_DATE, TEST_TEST_SCORE, TEST_ACTIVITY_DATE,TEST_EQUIV_IND)
SELECT
128019,'S02' ,TO_DATE( '05-JUL-2005', 'DD-MON-YYYY'),'730',SYSDATE,'N'
FROM DUAL ;
INSERT INTO TEST
( TEST_PIDM, TEST_TESC_CODE,TEST_TEST_DATE, TEST_TEST_SCORE, TEST_ACTIVITY_DATE,TEST_EQUIV_IND)
SELECT
128019,'S03' ,TO_DATE( '01-JUN-2005', 'DD-MON-YYYY'),'780',SYSDATE,'N'
FROM DUAL;
INSERT INTO TEST
( TEST_PIDM, TEST_TESC_CODE,TEST_TEST_DATE, TEST_TEST_SCORE, TEST_ACTIVITY_DATE,TEST_EQUIV_IND)
SELECT
128019,'S03' ,TO_DATE( '05-JUL-2005', 'DD-MON-YYYY'),'740',SYSDATE,'N'
FROM DUAL;
INSERT INTO TEST
( TEST_PIDM, TEST_TESC_CODE,TEST_TEST_DATE, TEST_TEST_SCORE, TEST_ACTIVITY_DATE,TEST_EQUIV_IND)
SELECT
128019,'S04' ,TO_DATE( '01-JUN-2005', 'DD-MON-YYYY'),'770',SYSDATE,'N'
FROM DUAL;
INSERT INTO TEST
( TEST_PIDM, TEST_TESC_CODE,TEST_TEST_DATE, TEST_TEST_SCORE, TEST_ACTIVITY_DATE,TEST_EQUIV_IND)
SELECT
128019,'S04' ,TO_DATE( '05-JUL-2005', 'DD-MON-YYYY'),'740',SYSDATE,'N'
FROM DUAL;
CREATE TABLE PERSON
PERSON_PIDM NUMBER(8) NOT NULL,
PERSON_ID VARCHAR2(9 CHAR) NOT NULL
INSERT INTO PERSON
( PERSON_PIDM , PERSON_ID)
SELECT
128019,'003334556'
FROM DUAL ;
CREATE TABLE VALTSC
VALTSC_CODE VARCHAR2(4 CHAR) NOT NULL,
VALTSC_DESC VARCHAR2(30 CHAR)
INSERT INTO VALTSC
VALTSC_CODE,
VALTSC_DESC
SELECT
'S01' ,
'XXS01'
FROM DUAL;
INSERT INTO VALTSC
VALTSC_CODE,
VALTSC_DESC
SELECT
'S02' ,
'XXS02'
FROM DUAL
INSERT INTO VALTSC
VALTSC_CODE,
VALTSC_DESC
SELECT
'S03' ,
'XXS03'
FROM DUAL;
INSERT INTO VALTSC
VALTSC_CODE,
VALTSC_DESC
SELECT
'S04' ,
'XXS04'
FROM DUAL; -
Is there a better way to do this? CSS rules/Background image/tables
Hi,
I am designing a site and I have used a table for the banner. Everytime a different page is displayed, the banner image changes. I have created .html pages, and I have created a lot of css rules to change the background image. I think there must be a more efficiant way to do this?
http://www.taffyproductions.com/test/
ALSO... I need to figure out how to make the links (hover/active states) work on all the pages... I figured it out on the index page, but I'm sure there is a better css rule?Put a div in the head section? Surely you jest!
But you do hint at the easy solution - just have an embedded stylesheet in the head of each page that changed the background image only on that page. No need for any other complexities.
In other words on page1, change this -
<link href="outpost.css" rel="stylesheet" type="text/css" />
</head>
to this -
<link href="outpost.css" rel="stylesheet" type="text/css" />
<style type="text/css">
table#banner { background-image:url(images/banner1.jpg); }
</style>
</head>
and on page2 change it to this -
<link href="outpost.css" rel="stylesheet" type="text/css" />
<style type="text/css">
table#banner { background-image:url(images/banner2.jpg); }
</style>
</head>
etc. -
Using empty interface -- is there a better way to do this?
Hi,
I have a set of classes in different projects that I'd like to be referenced together, although they have different methods depending on which project they're from. To do so, I've created an empty interface for each of these classes to implement, so I can return a similar type and then cast it however I need to based on which project I'm using.
However, I feel the approach of creating an empty interface just isn't the best way to do this. I've looked into annotations, but I don't think they can solve my problem. I don't think I'm being too clear here, so let me give a brief example:
Here is one of the interfaces I use:
public interface IceClient {
public IceOperations operations();
}Here is the empty interface:
public interface IceOperations {
}I have a method which will return a type of IceOperations:
public static synchronized IceOperations getOperations(String clientName) {
if (clientMap.containsKey(clientName)) {
IceClient client = clientMap.get(clientName);
return client.operations();
} else {
System.out.println("No client of that name is currently running.");
return null;
}This is all fine and dandy. I need to instantiate a new IceOperations object in my client code as such, where operations is of type IceOperations:
operations = new DiagOperations();And finally return it like this, where client.operations() returns a type of IceOperations:
public DiagOperations operations() {
return (DiagOperations)client.operations();
}Anyway I hope that wasn't too confusing. I cannot think of a different way to do this. Is there some way I can do this with annotations? The only other thing I can think of is just returning Object, but that seems ... icky.
If I need to be clearer, please let me know.
ThanksJoachimSauer wrote:
I didn't understand them to be trick questions, but rather serious invitations to question and verify your assumptions.
It might be the fact that every current implementation implements Runnable for some reason (possibly because it starts a Thread on its own). But it's entirely possible that you can produce a completely different implementation that doesn't need the Runnable interface and still be conformant.
If every implementation of X needs to implement Runnable, then it could be a sign of a slight design smell. Could you give an example where you think it's necessary?Every implementation of my "X" interface is basically a class that acts as a communicator/listener of sorts until it's stopped by the user, similar to a server socket. Sometimes, it has to sit there and wait for events, in which case it obviously must be in its own Thread. Other times it doesn't have to do this; however if I do not start it in its own Thread, I will have to continually stop and restart the communication to invoke operations on the server, which is inefficient.
Maybe you are looking for
-
Excel 2002 with BEx Analyzer NW2004s
Hi, can I use Excel 2002 with BEx Analyzer NW2004s? I read somewhere, it is possible only with Office 2003. It's true? Thanks!
-
Only One Computer at a Time on Internet
I have a cable modem (motorola) and using airport as my wireless router connected to my iMac. I have a MacBook and an iMac. Unfortunately, only one of us can be accessing the internet at a time. This was not the case before. If one of us is already o
-
when I first bought my ipad 3 cellular + wi-fi, I did not get a micro-sim card. I only used my home wifi that is from an Optus broadband network. It worked perfectly without any issues, good strong signal and fast internet. no worries Then 3 days ago
-
I want to burn to DVD only a part of my 11GB iPhoto 8.1.2 library. Do I do this by going to iPhoto Library, opening the package, then selecting from " Originals " the year folders I want ?
-
Listing existing properties and refnums for a control
I'm relatively new to LabView programming and this is probably a basic question. I need to list the existing properties and corresponding refnums for a custom control that was created before I started maintaining an existing application. I would li