Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8728101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:33:33+00:00 2026-06-13T08:33:33+00:00

I use db2 9.7.6 full edition for windows. I need develop functions which can

  • 0

I use db2 9.7.6 full edition for windows. I need develop functions which can be use on sql select expression.
Functions must contain modifying sql data and handling runtime exceptions. There are two variants, but I have problems of implementations all requirments in ever variants.
The first variant is implementation of sql table function, e.g.

 CREATE FUNCTION func1 (val CHAR(20))
    RETURNS table(result varchar(1000))
    LANGUAGE SQL
    MODIFIES SQL DATA
   BEGIN atomic
    insert into a values(val);
        return (select result from a);
    END 

It works, but I can’t implement handling exception how in sql procedures. When I tried to use block “declare exit handler”, I got a syntax errors.
The second variant is implementation of pl/sql function, e.g.

CREATE OR REPLACE FUNCTION bb
RETURN varchar2
MODIFIES SQL DATA
AS
BEGIN
    insert into st values ('a');
    return 0;
END bb;

But when I tried to execute this function, I got error “SQLCODE=-740, SQLSTATE=51034 is defined with the MODIFIES SQL DATA option, which is not valid in the context where the routine is invoked”. Help me please.
best regards, Turkin Andrew.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:33:34+00:00Added an answer on June 13, 2026 at 8:33 am

    It just doesn’t work.

    List of maximum access levels

    Routine type    Default SQL access level    Maximum allowed SQL access level
    SQL procedures  MODIFIES SQL DATA   MODIFIES SQL DATA
    SQL functions (scalar functions)    READS SQL DATA  READS SQL DATA
    SQL functions (table functions)     READS SQL DATA  MODIFIES SQL DATA
    External procedures     MODIFIES SQL DATA   MODIFIES SQL DATA
    External functions (scalar functions)   READS SQL DATA  READS SQL DATA
    External functions (table functions)    READS SQL DATA  READS SQL DATA
    

    For scalar functions the maximum level is “READS SQL DATA”. There is probably now way around that, so you have to reconsider your coding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In DB2, you can name a column ORDER and write SQL like SELECT ORDER
Can I use DML in from clause in DB2? thank you
We use a back-office accounting system with an SQL db2 database. Our sales, service
I need to access DB2 database in plain standalone Java project. I cannot use
I use DB2 and writing a trigger count version works but I can't convert
Here is the code I use: DELETE FROM db1.table1 WHERE db1.table1.Timestamp = db2.table2.Timestamp; Can't
I'm writing a DB2 user-defined function for which I need an array of non-negative
I've seen both versions around. On iSeries DB2 you can use either and as
How do I use DB2's Explain function? -- both to run it, and to
Can someone please tell me how to get the DB2 provider to show up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.