Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3508

SQL documenation, stored procedure example is confusing

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.2
    • 1.6.8
    • SQL processing
    • None

    Description

      I reference the stored procedure example at: http://groovy.codehaus.org/Database+features

      There is no description what the different elements in the example mean or do.
      You name a variable answer in the example that is not calling anything. Who answers what?
      You name a variable string but there is no string in the SQL code. You have to assume that a
      varchar maps to a string but it could also be the string representation of something.

      From what I understand how it works.
      You can define variables in the sql.call() parameter with ${Sql.INTEGER}, ${Sql.VARCHAR}.
      This is equivalent to the '?' used by JDBC except that it has additional type information.
      These variables are bound to the parameters of the closure.
      The first variable in the example "${Sql.INTEGER}" is bound to the first parameter of the closure "answer".
      The second parameter "${Sql.VARCHAR}" is bound to "string" and so on. Defining N parameters on your
      call string means you need N parameters for your closure.

      It would be much less confusing if you name the parameters parameter1 and parameter2,
      because you print out the type of the parameter later in the example. You don't have misleading
      associations and the number is a hint that the number of parameters matches the number of
      closure parameters.

      I found examples that use the JDBC calling conventions, probably because nobody managed to
      understand how it works. That makes it critical for me to update the current examples.

      Attachments

        Activity

          People

            paulk Paul King
            pinus Haug Bürger
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: