Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

Testing banner

Can a query result be stored in vector and later those values be used in another query?

3303426Mar 2 2017 — edited Mar 4 2017

I have a situation where I have to use two database servers 1-Oracle and 2-SQLServer and I do not have any link between those, also do not have rights to create one.

Using the following oracle query I have fetched the holiday_date from admin_holiday table of a particular month/year

(QUERY-1)

select to_char(holiday_date,'DD-MON-YYYY') holiday from admin_holiday where to_char(holiday_date,'DD-MON-YYYY') like '%-' || '"+currentMonth1+"' || '-' || '"+currentYear+"' || '%' and holiday_type_id=1 and to_char(holiday_date,'Day') not like 'Sun%' and to_char(holiday_date,'Day') not like 'Sat%'**

where currentMonth1 and currentYear are variables and their values are passed from outside. And

I have another **SQLServer** query

(QUERY-2)

select ISNULL(count(WORKHOUR),'-') AS present from "+currMonthVal+" m,"+currYearVal+" e WHERE E.EMPID=M.EMPID AND E.LOCATION=M.LOCATION AND M.EMPID = ? and DATENAME(WEEKDAY, attdate) not IN ('Saturday', 'Sunday') and attdate not IN ('"+holidayDate+"')

where currMonthVal and currYearVal values are passed from outside.

My question is:

If I store the result of QUERY-1 in a vector as in holidayDate variable, can I use the same variable in QUERY-2 as attdate not IN ('"+holidayDate+"') and will all the date values obtained in the vector be replaced in place of holidayDate variable?

If not how can get all the holiday_dates in above condition from a table that is on different server without creating any database link and may be using JAVA code

Comments
Post Details
Added on Mar 2 2017
1 comment
284 views