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. Other Discussions
  3. The Weird and The Wonderful
  4. Oracle stored procs

Oracle stored procs

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharporacle
2 Posts 2 Posters 28 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    When I started at my current company I was given a c# / oracle project and asked to rewrite it from scratch. I was told the guy who wrote it had been fired and everyone who had attempted to maintain the code had given up. I reakon I could have provided six months of content for the WTF web site from this single project. By far my favorite part was how he returned values from oracle stored procs to the application. Every stored proc returned a var of type VARCHAR2_32_ARRAY, and looked something like this

    CURSOR CUR_PARAMETERS IS
    SELECT
    CAST (
    MULTISET (
    SELECT
    COLUMN_NAME_1 || ':' || COLUMN_NAME_2 || ':' || COLUMN_NAME_3
    FROM
    SOME_TABLE_NAME
    WHERE
    SOME_FIELD = SOME_VAL
    ) AS VARCHAR2_32_ARRAY
    )
    FROM
    DUAL;

    RESULT_VAR VARCHAR2_32_ARRAY;
    BEGIN

    OPEN CUR_PARAMETERS;
    FETCH CUR_PARAMETERS INTO RESULT_VAR;
    CLOSE CUR_PARAMETERS;

    RETURN RESULT_VAR;

    END;

    then in the c# code we had things like this

    private void ParseResults ( IDataReader p_reader)
    {
    while ( p_reader.Read () )
    {
    string _encoded_record = ( string ) p_reader [ 0 ];
    string[] _fields = _encoded_record.Split ( new char[] {':' } );

    double var1 = Double.Parse( \_fields \[ 0 \] );
    etc etc etc
    

    }
    }

    Interesting way of doing things to say the least

    System.IO.Path.IsPathRooted() does not behave as I would expect

    P 1 Reply Last reply
    0
    • L Lost User

      When I started at my current company I was given a c# / oracle project and asked to rewrite it from scratch. I was told the guy who wrote it had been fired and everyone who had attempted to maintain the code had given up. I reakon I could have provided six months of content for the WTF web site from this single project. By far my favorite part was how he returned values from oracle stored procs to the application. Every stored proc returned a var of type VARCHAR2_32_ARRAY, and looked something like this

      CURSOR CUR_PARAMETERS IS
      SELECT
      CAST (
      MULTISET (
      SELECT
      COLUMN_NAME_1 || ':' || COLUMN_NAME_2 || ':' || COLUMN_NAME_3
      FROM
      SOME_TABLE_NAME
      WHERE
      SOME_FIELD = SOME_VAL
      ) AS VARCHAR2_32_ARRAY
      )
      FROM
      DUAL;

      RESULT_VAR VARCHAR2_32_ARRAY;
      BEGIN

      OPEN CUR_PARAMETERS;
      FETCH CUR_PARAMETERS INTO RESULT_VAR;
      CLOSE CUR_PARAMETERS;

      RETURN RESULT_VAR;

      END;

      then in the c# code we had things like this

      private void ParseResults ( IDataReader p_reader)
      {
      while ( p_reader.Read () )
      {
      string _encoded_record = ( string ) p_reader [ 0 ];
      string[] _fields = _encoded_record.Split ( new char[] {':' } );

      double var1 = Double.Parse( \_fields \[ 0 \] );
      etc etc etc
      

      }
      }

      Interesting way of doing things to say the least

      System.IO.Path.IsPathRooted() does not behave as I would expect

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Old habits die hard. It reminds me of: At a job I had ten years ago, we were just switching from Oracle using PRO*C to Sql Server (6 I think) using ODBC. No one in the company knew anything about ODBC so a "consultant" was brought in and, as the story went, given two days to write us a library of functions we could use. What he did, as the story continued, was copy examples from the floppy that came with an ODBC book. The functions returned the values as CSV strings! Management thought this was a perfectly usable solution. When I started using it after others had been for six months or so I said something that can't be repeated in the Lounge. There was absolutely no way I was going to stand for it, but I didn't have much time to fix it, so I made it only marginally better... my versions of the functions returned the values as arrays of strings. I left the company soon after, but had I stayed I was to be tasked with completely rewriting the library, I wish I had.

      --| "Every tool is a hammer." |--

      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