ASP Classic My company has a homegrown app that has issues since a move to Server 2008 - oracle

We have an intranet app that basically queries a bunch of databases and arranges the data. It is written in ASP(I KNOW) and upon a move to Windows Server 2008 we have one field that no longer populates. I know the database connection is good as everything else on that page loads just fine. This leads me to believe that it is a problem with the syntax of that particular query and that since it is using TO_DATE maybe there is some difference between Server 2003 and 2008 in regards to date format.
'SQL TO PULL PROCESS GROUP
pgsql = "SELECT DISTINCT subsystem_process_group.subsystem_id, subsystem_process_group.process_group_id, "
pgsql = pgsql & "process_group.process_group_name, oncall_group_day.employee_nbr "
pgsql = pgsql & " FROM eco_admin.process_group, eco_admin.subsystem_process_group, eco_admin.oncall_group_day "
pgsql = pgsql & "WHERE ((process_group.process_group_id = subsystem_process_group.process_group_id) "
pgsql = pgsql & "AND (process_group.process_group_id = oncall_group_day.process_group_id(+)) "
pgsql = pgsql & "AND (ONCALL_GROUP_DAY.CALENDAR_DATE(+) = TO_DATE(SYSDATE)) "
pgsql = pgsql & "AND (oncall_group_day.oncall_member_role_code(+) = 'P" & hour(now) & "') "
pgsql = pgsql & "AND (subsystem_process_group.subsystem_id = " & request("id") & ")) "
function get_name(emp_nbr)
sql3 = "select LTRIM(RTRIM(INITCAP(COMMON_NAME))) COMMON_NAME, LTRIM(RTRIM(INITCAP(LAST_NAME))) last_name from (select EMPLOYEE_NBR,COMMON_NAME, LAST_NAME from hrit_admin.employee union all select CONTRACT_RESOURCE_ID, COMMON_NAME, LAST_NAME from hrit_admin.contract_resource) a where employee_nbr = a.employee_nbr and employee_nbr = " & emp_nbr
rs3.open sql3,conn
get_name = rs3("COMMON_NAME") & " " & rs3("LAST_NAME")
rs3.close
end function

Related

MS Visual Studio (Reporting Services)

I've worked in SSRS for years but have never learned what this type of coding is actually named (which makes searching for solutions difficult), can anyone help please? Below is an example which allows the developer to have the code run as one continuous string. It also, if you're not familiar, allows for many powerful functions to be used that would otherwise (to my knowledge) not be available (e.g., IIF's, INSTR(JOIN()), SWITCH's, etc.).
=
" select distinct bn " &
" into #ST " &
" from frm_cr_2021 a " &
" join Md..nui_crssw b " &
" ON a.rc=b.cy"&MID(YEAR(Parameters!frm_dt.Value),3,2)&"_rc" &
" join nd_bs..dg_cv c " &
" on b.nd=c.nd " &
" where a.f_Dt<=#frm_dt and a.tr_dt>=#frmy_dt " &
"(select distinct c.ln,a.RC,A.Tr_Lv,a.P_Typ,a.P_Gp,a.Eff_Date,a.Term_Date from frm_"&YEAR(Parameters!frm_dt.Value)&" a "

Saving date to datetime throws Datetime field overflow

I am attempting to save a date and I get the error,
"[Microsoft][ODBC Driver 13 for SQL Server]Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding."
The column I am saving is a Datetime column in sql named rowUpdateDate.
The value I am setting to the row comes from the vb datetime method Now().
This code was working until an ODBC driver was updated on the server.
rs("rowUpdateDate") = now()
rs.ActiveConnection = cn
rs.UpdateBatch adAffectAll
Due to the driver update, updating the table by using the record set no longer works. This could be due to the addition of datetime2, but unsure.
What worked was changing the code to use a SQL update statement to update the table instead of the record.
updateSQL="UPDATE contractorApplicationProcess SET "
updateSQL=updateSQL & "DMID='" & Request("DMID") & "',"
updateSQL=updateSQL & "RecruitingID='" & Request("RecruiterMembership") & "',"
updateSQL=updateSQL & "contractorID='" & Request("contrID") & "',"
updateSQL=updateSQL & "rowUpdateDate='" & now() & "',"
updateSQL=updateSQL & "rowUpdateID='" & ResourceID & "'"
updateSQL=updateSQL & " WHERE contractorApplicationProcessID='" & clng(contrApplProcessID) & "'"
cn.Execute updateSQL

Query returns only 4 out of 12 values of my table. Why is this happening?

I have created a script which I am using on 2 different system. One is Windows 10 with SQL Server Express 2019 and the other is on Windows 7 (32bit) with SQL Server Express 2014. The db I am using has the same structure. The code I am using in ASP Classic is exactly the same on both machines! But in the win7 machine does not work as it should!
I am having a query to my db and the problem is that SOME of the values I am getting are empty. The code I am using is the following:
<%
Set rs21 = Server.CreateObject("ADODB.Recordset")
strSQL21 = "SELECT * FROM otherfiles WHERE animalid LIKE '" & lngRecordNo & "'
AND historyid LIKE '" & historyid & "' order by datedone DESC"
rs21.Open strSQL21, adoCon
%>
BLAH BLAH BLAH
<%
Do While not rs21.EOF
historyid = rs21("historyid")
if not historyid = "" then
Set rshis = Server.CreateObject("ADODB.Recordset")
strSQLhis = "SELECT * FROM history WHERE id_no LIKE '" & historyid & "' order by id_no DESC"
rshis.Open strSQLhis, adoCon
'------------------- if I remove the following line (Set rscol) it works fine ---------------------------
Set rscol = Server.CreateObject("ADODB.Recordset")
strcol = "SELECT * FROM hospitals WHERE id_no = "& rsGuestbook21("hosid") &" order by id_no DESC"
rscol.Open strcol, adocon
color = rscol("color")
%>
BLAH BLAH BLAH
<%=rs21("datedone")%> ---> empty value
<%=rs21("id_no")%> ---> works fine!!!
I am 100% sure that my table has its values. In fact as I mention above only but setting the rscol = Server.CreateObject("ADODB.Recordset") then the values becomes ??empty??. Commenting this line works fine.
I just figured out my ??mistake??...
Not really sure if it is a mistake thou... but the problem solved when I placed a field that had a DATA TYPE of "nvarchar(MAX)" at the end of my of my table! Weird stuff??? Do you think that there is something more than that in which I should investigate?

Passing a MS Access Form date into an Oracle SQL

I'm using MS Access to pull some data from an Oracle server via a pass-through query. The user is presented with a form in which they can input some variables (such as a date range). I would like the Oracle SQL to be able to pick up the two date fields from the form.
The current SQL (which doesn't work) is as follows:
SELECT a.I_LOAN_NUM, a.I_LOAN_SUB_ALLOC, c.N_EXCLV, e.I_GSL_SPNSR, e.N_GSL_SPNSR, b.D_CAL, b.C_LOAN_STAT, g.N_CNTRY
FROM SLD_LOAN_MSTR a
JOIN SLD_LOAN_CDL b on b.I_LOAN_ID = a.I_LOAN_ID
JOIN SLD_EXCLV c on c.I_EXCLV_ID = b.I_EXCLV_ID
JOIN SLD_AC d on d.I_AC_ID = b.I_AC_ID
JOIN SLD_CUST e on e.I_CUST_ID = d.I_CUST_ID
JOIN SLD_DPT_CNTRY f on f.I_DPT_ID = b.I_DPT_ID
JOIN SLD_CNTRY g on g.I_CNTRY_ID = f.I_CNTRY_ID
WHERE (b.C_LOAN_STAT = 'SETTLED' and b.D_CAL between [Forms]![Cost Allocation Form]![Start_Date] and [Forms]![Cost Allocation Form]![End_Date])
ORDER BY b.D_CAL
The above SQL works if I replace the form references with hard coded dates, so I know the SQL is generally good. Example:
WHERE (b.C_LOAN_STAT = 'SETTLED' and b.D_CAL between '01JAN2019' and '01FEB2019')
The error message being generated by the SQL states "ODBC--call failed. [Oracle][ODBC][Ora]ORA-00936: missing expression (#936)"
Both of the date fields in the Form are using the Short Date format.
I'm not sure if this makes any difference or not, but the Form has multiple tabs. From what I've seen from other examples, the Form reference doesn't need to take the tab labels into account.
Thanks
Pass-through queries are executed at the server. In your case the Oracle server doesn't recognize the [Forms]![Cost Allocation Form]![Start_Date] and [Forms]![Cost Allocation Form]![End_Date] attributes.
You could use VBA to dynamically update the query definition of the query to include the form control values. Then execute the query.
Dim strSQL As String
Dim qdf As QueryDef
strSQL = "SELECT a.I_LOAN_NUM, a.I_LOAN_SUB_ALLOC, c.N_EXCLV, e.I_GSL_SPNSR, e.N_GSL_SPNSR, b.D_CAL, b.C_LOAN_STAT, g.N_CNTRY " & _
"FROM SLD_LOAN_MSTR a " & _
"JOIN SLD_LOAN_CDL b on b.I_LOAN_ID = a.I_LOAN_ID " & _
"JOIN SLD_EXCLV c on c.I_EXCLV_ID = b.I_EXCLV_ID " & _
"JOIN SLD_AC d on d.I_AC_ID = b.I_AC_ID " & _
"JOIN SLD_CUST e on e.I_CUST_ID = d.I_CUST_ID " & _
"JOIN SLD_DPT_CNTRY f on f.I_DPT_ID = b.I_DPT_ID " & _
"JOIN SLD_CNTRY g on g.I_CNTRY_ID = f.I_CNTRY_ID " & _
"WHERE (b.C_LOAN_STAT = 'SETTLED' and b.D_CAL between '" & _
[Forms]![Cost Allocation Form]![Start_Date] & "' and '" & [Forms]![Cost Allocation Form]![End_Date] & _
"' ORDER BY b.D_CAL"
Set qdf = CurrentDb.QueryDefs("PassThroughQueryName")
qdf.SQL = strSQL
Also since your using dates, I would suggest you format your dates to the ISO format yyyy-mm-dd
in this case formatting the controls like
Format([Forms]![Cost Allocation Form]![Start_Date], "yyyy-mm-dd") & "' and '" & Format([Forms]![Cost Allocation Form]![End_Date], "yyyy-mm-dd")
Another way would be to just use VBA ADO to access the Oracle Server and retrieve the data. You would still need to build up your SQL string as mentioned here.

Issue using Oracle date function with Spring's NamedParamenterJdbcTemplate

I'm having an issue trying to get my SQL query which works fine in SQL Developer (Oracles free database tool) to also work using Spring's NamedParameterJdbcTemplate class.
My query is:
String sql = " SELECT COUNT(*) FROM ( " +
" SELECT FE.USR_ID, MAX(FE.DATE_FIRST_SUB) AS SUB_DATE " +
" FROM FC, FE " +
" WHERE FC_STATUS = 'MEMBER' " +
" AND FC.FC_SPC_ID = :spcId " +
" AND FE.FE_USR_ID = FC.FC_USR_ID " +
" AND FE.DATE_FIRST_SUB IS NOT NULL " +
" GROUP BY FE_USR_ID " +
" ) " +
" WHERE SUB_DATE BETWEEN TO_DATE('01-JUN-2011', 'DD-MON-YYYY') AND TO_DATE('01-JUL-2011', 'DD-MON-YYYY') ";
It has something to do with my dates, formatting perhaps? When I don't use the WHERE clause in the outer select it works, when it's included 0 is returned from the count - as I mentioned running the SQL directly returns expected results.
Any advice?
Thanks.
Oh my, I was in fact looking at the wrong database!!

Resources