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

  • Home
  • SEARCH
  • 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 7967983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:00:22+00:00 2026-06-04T07:00:22+00:00

I an trying to create new stored procedures. Below is the code segment for

  • 0

I an trying to create new stored procedures.
Below is the code segment for sp.

CREATE PROCEDURE abs_eq (arg1 INTEGER, arg2 INTEGER)
    RETURNS BOOLEAN
    WITH (NOT VARIANT)
    DEFINE ret BOOLEAN;
    IF (arg1 < 0 THEN)
        LET arg1 = -arg1;
    END IF
    IF(arg1 = arg2) THEN
        LET ret = "t";
    ELSE
        LET ret = "f";
    END IF;
    RETURN ret;
END PROCEDURE;
EXECUTE PROCEDURE abs_eq (3, 5);

However, I don’t know where to put this code segment and how to compile at remote database.
I will call this functions in java like this:

public void callfunction() throws SQLException {

        CallableStatement proc = null;

        proc = conn.prepareCall("{ call abs_eq(?,?) }");
        proc.setInt(1, 3);
        proc.setInt(2, 5);
        boolean result = proc.execute();
        System.out.println(result);

    }

I need a clear explanation that describes what I need to do step by step

  • 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-04T07:00:23+00:00Added an answer on June 4, 2026 at 7:00 am

    You can “put” it on database using any tool that can run sql statements. This can be done by ISA (Informix Server Administrator), or SQL Editors working with ODBC or JDBC drivers. Of course you can use JDBC to this task:

    stmt = conn.createStatement()
    stmt.execute(FUN_BODY)
    

    I use it with Informix JDBC driver and Jython (so, no semicolons at line ends).

    You have some errors in procededure. It should be function, and if I understand its name it should compare two ints using their absolute values. I would write it that way:

    FUN_BODY = """CREATE FUNCTION abs_eq (arg1 INTEGER, arg2 INTEGER) RETURNING BOOLEAN;
        IF (arg1 == arg2) THEN
            RETURN 't';
        END IF;
        IF (arg1 == -arg2) THEN
            RETURN 't';
        END IF;
        IF (-arg1 == arg2) THEN
            RETURN 't';
        END IF;
        RETURN 'f';
    END FUNCTION;
    """
    

    I would also add some tests, there is Jython code with test routine and tests:

    def test_abs_eq(proc, arg1, arg2, expected):
        proc.setInt(1, arg1);
        proc.setInt(2, arg2);
        rs = proc.executeQuery();
        while (rs.next()):
            r = rs.getBoolean(1)
            ok = 'ok'
            if r != expected:
                ok = ' ERROR!!!'
            print('%d, %d: %s %s' % (arg1, arg2, r, ok))
    
    
    def test_multi(db_url, usr, passwd):
        try:
            db = DriverManager.getConnection(db_url, usr, passwd)
            conn = db.createStatement()
            conn.execute(FUN_BODY)
            proc = db.prepareCall("{ call abs_eq(?,?) }");
            test_abs_eq(proc, 0, 0, True)
            test_abs_eq(proc, 3, 4, False)
            test_abs_eq(proc, 3, 3, True)
            test_abs_eq(proc, 20, 0, False)
            test_abs_eq(proc, -20, -20, True)
            test_abs_eq(proc, 20, -20, True)
            test_abs_eq(proc, -20, 20, True)
            test_abs_eq(proc, 20, 20, True)
            db.close()
        except:
            print("there were errors!")
            s = traceback.format_exc()
            sys.stderr.write("%s\n" % (s))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to SQL Server Stored Procedures, I am trying to create
I am very new to stored procedures. I am trying to create a stored
I'm trying to write a stored procedure that will create a new FILEGROUP based
I am trying to create a new Element in my javascript code and append
I'm trying to create a new log file every hour with the following code
2 Hi! I am trying to create stored procedure that gone return varchar value,
I am trying to create a stored procedure that utilizes a variable number of
Am new to SPRING with JPA techniques. am trying to call the stored procedure
I am very new to stored procedures. I am trying to make a stored
I am trying to create a stored procedure that will take a row with

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.