1 Reply Latest reply on Dec 4, 2002 5:18 PM by 82532

    oracle not returning correct datatype

    353921
      Hello, I am trying to create a web application on an Oracle Database. However, whenever I try and bring back a data type of type number it only comes back as strings. I have tried using ODBC as well as OO4O and both only return strings. I have been stuck for quite a while and was hoping someone might be able to help.

      The OO4O code I am using to access my Oracle Database is:

      <html>
      <head>
      <title>Oracle Objects For OLE (OO4O) 2.3 </title>
      </head>

      <body BGCOLOR="#FFFFFF">
      <font FACE="ARIAL,HELVETICA">

      <h2 align="center">Oracle Objects For OLE (OO4O) 2.3 </h2>

      <%
      SqlQuery = "Select * from food"
      %>
      <%
      If SqlQuery = "" Then
      %>
      <% Else %>

      <table BORDER="1">
      <%
      Set OraDatabase = OraSession.GetDatabaseFromPool(10)
      Set OraDynaset = OraDatabase.CreateDynaset(SqlQuery,0)
      Set Columns= OraDynaset.Fields
      %>
      <tr>
      <td><table BORDER="1">
      <tr>
      <% For i = 0 to Columns.Count - 1 %>
      <td><b><% = Columns(i).Name %></b></td>
      <% Next %>
      </tr>
      <% while NOT OraDynaset.EOF %>
      <tr>
      <% For col = 0 to Columns.Count - 1 %>
      <td><%
      temp2 = Columns(col)
      response.write(temp2)%>
      </td>
      <% Next %>
      </tr>
      <% OraDynaSet.MoveNext %>
      <% WEnd %>
      </table>
      <p></font><%End If%> </p>
      <hr>
      </td>
      </tr>
      </table>

      <br>
      <%= temp2 %>
      <br><br>
      <%Response.Write "<br> TypeName of temp is " & TypeName(temp2) & "<HR>"%>

      <%

      if (temp2 = 35) Then
           Response.Write "SUCCESS"
      end if
      %>
      </body>
      </html>

      Thank you for the help.

      THE ODBC VERSION IS THIS:

      <% Option Explicit %>
      <!--#INCLUDE FILE="inc_adovbs.asp"-->
      <!--#INCLUDE FILE="inc_sha256.asp"-->


      <HTML>

      <HEAD>
      <TITLE>Oracle Data Access</TITLE>
      </HEAD>

      <BODY>
      <CENTER>
      <H2> Oracle Testing<BR>
      temp2.asp<BR>
      WHY DOESNT IT BRING BACK NUMBERS??<BR>
      </H2>
      </CENTER>

      <%
      Dim objConnection
      Dim objRecordset
      Dim varSQL

      Set objConnection = Server.CreateObject("ADODB.Connection")

      With objConnection
      .ConnectionString = "Provider=MSDAORA; Data Source=Oracle; " & _
      "User ID=scott; Password=tiger;"
      .Open
      Response.Write "ADO Provider=" & .Provider & "<P>"

      varSQL = "SELECT * FROM food"
                     '& _
      '" emp.sal, emp.comm, dept.dname, dept.loc" & _
      '" FROM emp, dept" & _
      '" WHERE emp.deptno = dept.deptno" & _
      '" ORDER BY emp.ename"

      Set objRecordset = .Execute(varSQL)

      End With

      'Response.Write "<TABLE BORDER=1><TR>" & _
      ' " <TD>Number</TD>" & _
      ' " <TD>Employee</TD>" & _
      ' " <TD>Job</TD>" & _
      ' " <TD>Hire Date</TD>" & _
      ' " <TD>Salary</TD>" & _
      ' " <TD>Commission</TD>" & _
      ' " <TD>Department</TD>" & _
      ' " <TD>Location</TD>" & _
      ' "</TR>"


           do until objRecordset.EOF
      ' Do While Not objRecordset.EOF

      ' Response.Write "<TR>" & _
      ' " <TD>" & objRecordset("empno") & "</TD>" & _
      ' " <TD>" & objRecordset("ename") & "</TD>" & _
      ' " <TD>" & objRecordset("job") & "</TD>" & _
      ' " <TD>" & objRecordset("hiredate") & "</TD>" & _
      ' " <TD>" & objRecordset("sal") & "</TD>" & _
      '' " <TD>" & objRecordset("comm") & " </TD>" & _
      ' " <TD>" & objRecordset("dname") & "</TD>" & _
      ' " <TD>" & objRecordset("loc") & "</TD>" & _
      ' "</TR>"

      dim temp
      'temp = objRecordset("quantity")

           temp = 10
      Response.Write "Main Menu: " & objRecordset("main") & "<br>"
      Response.Write "Quantity: " & temp & "<br>"

      objRecordset.MoveNext

      Loop

      ' Response.Write "</TABLE>"

      Response.Write "<br><br><br>"


      Response.Write temp & "<br>"

      Response.Write "TypeName of temp is " & TypeName(temp) & "<br>"

      if (temp = 10) Then
           Response.Write "SUCCESS "
      end if

      Set objConnection = Nothing
      Set objRecordset = Nothing
      %>
      </BODY>
      </HTML>
        • 1. re:oracle not returning correct datatype
          82532
          A NUMBER coulumn, unless constrained, is a NUMBER(38). What Datatype on the PC would you be able to contain that large of a number? By default, anything larger than NUMBER(15) (ir 16, forget exactly) is translated to it's string representation to prevent loss of information.

          Mark Tomlinson