Menu

stored procs from within include files

2004-01-08
2004-01-26
  • Damon Torgerson

    Damon Torgerson - 2004-01-08

    Hello everyone,

    I've been using SQLUnit for a month or so and hats off to all the hard work...it's a great tool.

    I have a couple of questions.

    Is it possible to call stored procedures from within an include file? If someone could post an example I'd really appreciate it.

    Is it possible to call multiple include files from within setup and teardown?

    Thanks in advance for any help and thanks for all your hard work!

    Damon

     
    • Sujit Pal

      Sujit Pal - 2004-01-09

      Hi Damon,

      Thanks, and yes, it should work, but you have to hardcode the parameters, for example, suppose you were deleting all your test data for today, and your database had a built in function today() which gives you back today's date, then you could say either:

      delete * from table1 where timestamp = today()
      ;
      delete * from table2 where timestamp = today()
      ;

      or you could write a stored procedure that does this all for you and call it like so:
      deleteAllRecordsForToday(today())
      ;

      but you cannot do this:
      deleteAllRecordsForToday("2004-01-08")
      ;

      This is because the underlying abstraction used to execute the statements is the JDBC Statement object which does not allow parameters. I havent tried what you ask, but if all parameters are supplied then it should work to the best of my knowledge.

      I would just give it a try and let the forun know for sure :-).

      HTH
      Sujit

       
    • Sujit Pal

      Sujit Pal - 2004-01-09

      Hi Damon,

      Oh, and you can only call a single include file from within the setup and teardown tags. Not sure why you would want to have multiple include files, can you provide an example of why you would need this?

      Thanks
      Sujit

       
      • Damon Torgerson

        Damon Torgerson - 2004-01-09

        I would want to use multiple include files to keep a physical separation of certain data....it just makes it easier for me if I can search through the "employees" include file or the "departments" include file rather than having everything in one enormous file. Of course, there's no reason that I can't use ant to cat my files before running my tests....

        I think my real issue is that I would like "per test" setup and teardown, which has been discussed in the forum all ready.

        Thank you for your quick response. I'll give it a try and get back to you.

        Thanks for all your hard work on a great tool.

        Damon

         
    • Sujit Pal

      Sujit Pal - 2004-01-09

      Oh, for my first reply to you, please read this:
      deleteAllRecordsForToday(?)
      instead of
      deleteAllRecordsForToday("2004-01-08")

      -sujit

       
    • Sujit Pal

      Sujit Pal - 2004-01-09

      Actually, there is no "technical" (ie, the program cannot handle it) reason for having a single <include> element. I just thought that made more sense to have a single per testsuite include file. But your argument makes sense also, since you may want to mix-and-match different combinations of include files for different test suites. It will be fairly simple to do this, so I will bunch it up with the next release, which will contain external connection properties, and some fixes for Oracle CURSORs as outparams (provided we can finish testing these in time).

      -sujit

       
      • Damon Torgerson

        Damon Torgerson - 2004-01-26

        I just wanted to say thank you for including this feature in the new release. You are all doing an excellent job producing an excellent product.

         

Log in to post a comment.