Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query in java 2

Status
Not open for further replies.

ksbrace

Programmer
May 13, 2000
501
US
Hello,
I'm having a bit of difficulty placing this query within my java. it works perfectly in sqlplus. Any help/advice would be greatly appreciated. Thanks in advance!

sqlplus:
Code:
SELECT student_course_subject(sfrstcr_term_code,sfrstcr_crn)||'-'|| student_course_number(sfrstcr_term_code,sfrstcr_crn)||'-'|| student_course_section(sfrstcr_term_code,sfrstcr_crn) "Class", student_course_title(sfrstcr_term_code,sfrstcr_crn) "Title", student_ssrmeet_days(sfrstcr_term_code,sfrstcr_crn) "Schedule" FROM sfrstcr s WHERE s.sfrstcr_term_code=1999 AND s.sfrstcr_pidm=22;

java:
Code:
private static final String selectCourseList = "SELECT student_course_subject(sfrstcr_term_code,sfrstcr_crn)||'-'|| " +
       "student_course_number(sfrstcr_term_code,sfrstcr_crn)||'-'|| " +
      "student_course_section(sfrstcr_term_code,sfrstcr_crn) \"Class\", " +
       "student_course_title(sfrstcr_term_code,sfrstcr_crn) \"Title\", " +
       "student_ssrmeet_days(sfrstcr_term_code,sfrstcr_crn) \"Schedule\" " +
	   "FROM sfrstcr s " +
	   "WHERE s.sfrstcr_term_code=1999 AND s.sfrstcr_pidm=22;";

 
Hi

Try this

Code:
String sqlQuery = "" +
                "SELECT student_course_subject(sfrstcr_term_code,sfrstcr_crn)||'-'|| " +
                "student_course_number(sfrstcr_term_code,sfrstcr_crn)||'-'|| " +
                "student_course_section(sfrstcr_term_code,sfrstcr_crn) \"Class\", " +
                "student_course_title(sfrstcr_term_code,sfrstcr_crn) \"Title\", " +
                "student_ssrmeet_days(sfrstcr_term_code,sfrstcr_crn) \"Schedule\" " +
                "FROM sfrstcr s WHERE s.sfrstcr_term_code=1999 AND s.sfrstcr_pidm=22";

Cheers
Venu
 
And even better readable, breakable, editable:
instead of:
Code:
     "student_course_section(sfrstcr_term_code,sfrstcr_crn) \"Class\", " +
Code:
     " student_course_section (sfrstcr_term_code, sfrstcr_crn) \"Class\", " +


seeking a job as java-programmer in Berlin:
 
I'd also recommend, to improve performance and keep things clearer, the use of append method of StringBuffer class.

Cheers,

Dian
 
Great, thanks for all of your help, it worked.
Kelly

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top