• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Oracle stored proc simple problem

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    Originally posted by eek View Post
    So having confirmed that the Bobs are treating you with the respect you seem to deserve here is the noddy code you need.

    Code:
    CREATE OR REPLACE PROCEDURE ADD_LOCATION (
    (sTEST_DATA IN NVARCHAR2, iTEST_ID OUT INTEGER) 
    AS
    BEGIN
    INSERT INTO TEST_DATA VALUES (seqTestData.nextval, sTEST_DATA );  
    
     SELECT seqTestData.CURRVAL INTO iTEST_ID FROM DUAL;
    
    END
    Personally, I'd do the fetch into the variable before the insert. Generally because I like to include audit and debug statements like "About to insert record ID x" before the insert.

    Code:
    CREATE OR REPLACE PROCEDURE sp_AddTestData (sTEST_DATA IN NVARCHAR2, iTEST_ID OUT INTEGER) AS
    BEGIN
      SELECT seqTestData.NEXTVAL INTO iTEST_ID FROM DUAL;
    
      INSERT INTO TEST_DATA VALUES (iTEST_ID, sTEST_DATA );  
    
    END;
    But the overall impact is the same
    Best Forum Advisor 2014
    Work in the public sector? You can read my FAQ here
    Click here to get 15% off your first year's IPSE membership

    Comment


      #12
      Originally posted by lilelvis2000 View Post
      What's the warning? TOAD, SQL Developer should provide a list of the warnings.

      Your script should be like

      DECLARE
      NewID integer;
      begin
      CALL sp_AddTestData('This is a test',NewID);
      end;
      Try it without "CALL" in there
      Best Forum Advisor 2014
      Work in the public sector? You can read my FAQ here
      Click here to get 15% off your first year's IPSE membership

      Comment


        #13
        Surely a bump in the right direction is better than giving the answer away?
        McCoy: "Medical men are trained in logic."
        Spock: "Trained? Judging from you, I would have guessed it was trial and error."

        Comment


          #14
          Originally posted by eek View Post
          So having confirmed that the Bobs are treating you with the respect you seem to deserve here is the noddy code you need.

          Code:
          CREATE OR REPLACE PROCEDURE ADD_LOCATION (
          (sTEST_DATA IN NVARCHAR2, iTEST_ID OUT INTEGER) 
          AS
          BEGIN
          INSERT INTO TEST_DATA VALUES (seqTestData.nextval, sTEST_DATA );  
          
           SELECT seqTestData.CURRVAL INTO iTEST_ID FROM DUAL;
          
          END
          A simple understanding that I would expect you people to make. I DESIGNED the system. Now I am helping them code it, despite protestations that I am to Oracle what MF is to Microsoft. Go figure.
          Knock first as I might be balancing my chakras.

          Comment


            #15
            Originally posted by lilelvis2000 View Post
            Surely a bump in the right direction is better than giving the answer away?
            Certainly the vendor feels this way, my weekly reports list the actual question that was asked, then the responses given from the vendor support team and the actual percentage progress that could be made on the problem given the response. (This is not Oracle related) but makes for interesting team meetings. Vendor support is more cards against the chest than it used to be. Perhaps a sign of the financial times.
            Knock first as I might be balancing my chakras.

            Comment


              #16
              Originally posted by suityou01 View Post
              Certainly the vendor feels this way, my weekly reports list the actual question that was asked, then the responses given from the vendor support team and the actual percentage progress that could be made on the problem given the response. (This is not Oracle related) but makes for interesting team meetings. Vendor support is more cards against the chest than it used to be. Perhaps a sign of the financial times.
              Is the end client in this meeting as you tell the vendor (and I guess your employer) how crap their staff are?

              Oh and the code above is noddy code. It took me 45 seconds to find it via google.
              merely at clientco for the entertainment

              Comment


                #17
                Who is the vendor? McCain?
                Last edited by doodab; 9 December 2011, 08:49.
                While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'

                Comment


                  #18
                  Originally posted by doodab View Post
                  Who is the vendor? McCain?
                  They sound cheap as chips

                  Best Forum Advisor 2014
                  Work in the public sector? You can read my FAQ here
                  Click here to get 15% off your first year's IPSE membership

                  Comment


                    #19
                    Originally posted by suityou01 View Post
                    A simple understanding that I would expect you people to make. I DESIGNED the system. Now I am helping them code it, despite protestations that I am to Oracle what MF is to Microsoft. Go figure.
                    It's great how you respond to people's help. Maybe keep your sense of aggrieved genius for General.
                    Originally posted by MaryPoppins
                    I'd still not breastfeed a nazi
                    Originally posted by vetran
                    Urine is quite nourishing

                    Comment


                      #20
                      Suity,

                      If you want more critique (if this is something that your off-shore team has produced and you want to try and look smart)....

                      1) Why isn't this a function rather than a procedure?

                      2) Why use INTEGER rather than PLS_INTEGER as the datatype?
                      Best Forum Advisor 2014
                      Work in the public sector? You can read my FAQ here
                      Click here to get 15% off your first year's IPSE membership

                      Comment

                      Working...
                      X