cancel
Showing results for 
Search instead for 
Did you mean: 

Inexplicable syntax error in function declaration (SA17)

reimer_pods
Participant
4,004

Some skripts we've used for year with SA11 up to SA16 start throwing errors when used with SA17, complaining about Transact Syntax in a Watcom function.

Example: alt text

I'd suppose SA would be able to differentiate between a Watcom FUNCTION and the TRANSACT style (which doesn't support the IN keyword in the parameter list, according to the docs, but uses AS before the statement block).

What can I do to fix this? Have I overlooked anything?

  • E D I T -

    I've stripped down one of the functions down to a few lines.
    create or replace function FuncTest (@charVal char(30), @intVal integer= null)
    returns integer
    begin
      return @intVal;
    end
    

which throws the (german) error message:
Anweisung konnte nicht ausgeführt werden. Syntaxfehler bei ';' in Zeile 5 (Transact-SQL) SQLCODE=-131, ODBC 3-Status="42000" Zeile 1, Spalte 1

That exposed the actual source of the problem: because the function contains nearly no code, the parser must be tripping over the assignment of a default value via the operator "=" instead of using DEFAULT (as defined by the syntax description).

We got a pack of SPs defined that way, since we started using default values for procedures / functions starting IIRC with ASA9. Ever since no one bothered to write DEFAULT, if "=" would do the trick.

I'v checked that the sample above is accepted and works correctly with ASA9, SA11, SA12 and SA16.

So the question should rather be converted to an Enhancement Request :
Extend the syntax for the parameter definition part [ DEFAULT expression ] to [ {DEFAULT | = } expression ] (or sth. like that).

Former Member
0 Kudos

Is this happening if the action is a REPLACE and not a CREATE? If so, it may be picking it's que up from the pre-existing function language type.

Former Member
0 Kudos

Nope ... doesn't seem to be that ... maybe if we had a full function definition that fails ...

Former Member
0 Kudos

Sometimes (historically) a later usage of a declared variable will confuse the parser and it will flag a syntax error on the declare for that variable. Try looking for uses of @vorposID lower down.

Otherwise I would need to see this happening ... ?test case?

Accepted Solutions (0)

Answers (0)