Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

SQL Create Function

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

  • SQL Create Function

    Chip, Make sure that your library is in teh library list, prior to executing the SELECT. Have you double checked your parameter list to make sure its compatible with the parameter style you specified? When I have created function in RPGLE I used sub procedures, not modules. Do you know if COBOL has a similar concept? It will perform much faster than a module call, even if the module call is supported. Good luck, and have fun! Kevin

  • #2
    SQL Create Function

    I want to utilize some subprograms we've written in COBOL inside of SQL select statement. I had a cobol program named SUPLOW that I tried to change into a service program in order to make it easily definable as a function in SQL. Thus far I have converted the program in question (SUPLOW) to ILE cobol, and used the CRTCBLMOD (create cobol module) command followed by CRTSRVPGM (create service program) command. The end result is a service program named SUPLOWLE that contains this single module also named SUPLOWLE. In SQL, I do the following: > create function y (char(30)) RETURNS CHAR(30) EXTERNAL NAME 'OAKPGM/SUPLOWLE(SUPLOWLE)' LANGUAGE cobolLE DETERMINISTIC no SQL PARAMETER STYLE general CREATE FUNCTION statement complete. > SELECT OPOPERNO, Y(OPOPERNAME) FROM TFRANDTA/MCFD1OP WHERE OPOPERNO < 2000 SUPLOWLE in OAKPGM type *SRVPGM not found. What am I doing wrong??

    Comment


    • #3
      SQL Create Function

      Chip, I was lookingg into this again, and I think the problem is in how SQL perceives your character data. I belive SQL is treating it as variable length character data, and so it can't find a function with the right inputs. Try casting your argument as a 30 byte character field as shown below. If that fixes it, then try changing the program and function to pass the data as variable length character data. Good luck! Kevin
      Code

      Comment

      Working...
      X