Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Please Help !Query executing in oracle but not executing through code

Please Help !Query executing in oracle but not executing through code

Scheduled Pinned Locked Moved C#
databasehelpcsharporaclesysadmin
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ravindradonkada
    wrote on last edited by
    #1

    <>Hi, This is ravindra ,I created the following function and able to execute the followed query successfully in sql plus but when i try to execute the same query through code,getting error like Unspecified error Oracle error occurred, but error message could not be retrieved from Oracle. Data type is not supported. Create or Replace Function convert_time(datetime in timestamp, tz1 in varchar2, tz2 in varchar2) Return timestamp with time zone as retval timestamp with time zone; Begin retval := from_tz(datetime, tz1) at time zone tz2; return retval; End; select convert_time(to_timestamp('01/01/2006 23:45','mm/dd/yyyy hh24:mi'),'US/Eastern','Turkey') from dual; the .net code as follows string conn = "Provider=MSDAORA.1;Password=;User ID=;Data Source=naradaon;Extended Properties=Server=naradaon"; OleDbConnection con = new OleDbConnection(conn); con.Open(); DataSet ds = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter("select from_tz(to_timestamp('01/01/2006 23:45','mm/dd/yyyy hh24:mi'),'-05:00') as hio from dual", con); da.Fill(ds); Please help me thank you <>

    C Mircea PuiuM 2 Replies Last reply
    0
    • R ravindradonkada

      <>Hi, This is ravindra ,I created the following function and able to execute the followed query successfully in sql plus but when i try to execute the same query through code,getting error like Unspecified error Oracle error occurred, but error message could not be retrieved from Oracle. Data type is not supported. Create or Replace Function convert_time(datetime in timestamp, tz1 in varchar2, tz2 in varchar2) Return timestamp with time zone as retval timestamp with time zone; Begin retval := from_tz(datetime, tz1) at time zone tz2; return retval; End; select convert_time(to_timestamp('01/01/2006 23:45','mm/dd/yyyy hh24:mi'),'US/Eastern','Turkey') from dual; the .net code as follows string conn = "Provider=MSDAORA.1;Password=;User ID=;Data Source=naradaon;Extended Properties=Server=naradaon"; OleDbConnection con = new OleDbConnection(conn); con.Open(); DataSet ds = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter("select from_tz(to_timestamp('01/01/2006 23:45','mm/dd/yyyy hh24:mi'),'-05:00') as hio from dual", con); da.Fill(ds); Please help me thank you <>

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Try writing a parameterised query. I'm surprised this SQL works, I thought you needed select *, not just select. Could be an Oraclism tho.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • R ravindradonkada

        <>Hi, This is ravindra ,I created the following function and able to execute the followed query successfully in sql plus but when i try to execute the same query through code,getting error like Unspecified error Oracle error occurred, but error message could not be retrieved from Oracle. Data type is not supported. Create or Replace Function convert_time(datetime in timestamp, tz1 in varchar2, tz2 in varchar2) Return timestamp with time zone as retval timestamp with time zone; Begin retval := from_tz(datetime, tz1) at time zone tz2; return retval; End; select convert_time(to_timestamp('01/01/2006 23:45','mm/dd/yyyy hh24:mi'),'US/Eastern','Turkey') from dual; the .net code as follows string conn = "Provider=MSDAORA.1;Password=;User ID=;Data Source=naradaon;Extended Properties=Server=naradaon"; OleDbConnection con = new OleDbConnection(conn); con.Open(); DataSet ds = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter("select from_tz(to_timestamp('01/01/2006 23:45','mm/dd/yyyy hh24:mi'),'-05:00') as hio from dual", con); da.Fill(ds); Please help me thank you <>

        Mircea PuiuM Offline
        Mircea PuiuM Offline
        Mircea Puiu
        wrote on last edited by
        #3

        Use OracleDataAdapter instead. (using Oracle.DataAccess.Client) string conn = @"...."; // make sure you use the correct one string strSel = @"select from_tz(to_timestamp('01/01/2006 23:45','mm/dd/yyyy hh24:mi'),'-05:00') as hio from dual"; OracleDataAdapter da = new OracleDataAdapter(strSel, conn); DataSet ds = new DataSet(); da.Fill(ds);

        SkyWalker

        modified on Thursday, May 1, 2008 10:52 AM

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups