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 7864861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:54:47+00:00 2026-06-02T23:54:47+00:00

I must use PostgreSQL but I have a little problem when I try to

  • 0

I must use PostgreSQL but I have a little problem when I try to read a function in Java.

My function:

CREATE OR REPLACE FUNCTION tiena.RecursosData7(x text, OUT id text, OUT valor text)RETURNS SETOF record
AS
'
    SELECT recursodc.idrecursodc, recursodc.valorfonte
    FROM tiena.recursodc
    WHERE valorfonte=$1;
'
LANGUAGE 'sql';

Then in Java I’m trying to read the function this way:

try {
    if (AbrirConexao()) {
        conn.setAutoCommit(false);
        proc = conn.prepareCall("{ call tiena.recursosdata7(?,?, ?)}");
        proc.setString(1,"IG - SP");
        proc.registerOutParameter(2, Types.VARCHAR);
        proc.registerOutParameter(3, Types.VARCHAR);

        //proc.execute();
        //resSet = (ResultSet) proc.getObject(1);
        resSet = proc.executeQuery();
        while(resSet.next())
        {
            String id = resSet.getString(1);
            String fonte = resSet.getString(2);
            System.out.println("id : "+ id +", fonte: "+ fonte);
        }
        proc.close();
    }

But I always get the same error.

Erro : Nenhum resultado foi retornado pela consulta.
org.postgresql.util.PSQLException: Nenhum resultado foi retornado pela consulta.
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:274)
        at LerArquivos.ConexaoBD.RecuperarIDRecurso2(ConexaoBD.java:117)
        at upload_cg.Main.main(Main.java:24)

I tried to move the location of the parameters, the function and i search a lot but I don’t found the solution. Do you have any suggestions?

  • 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-02T23:54:48+00:00Added an answer on June 2, 2026 at 11:54 pm

    Bellninita, consider using a cursor instead. Here are example Java and SQL code that has components similar to what you appear to need. This is similar to the production code used for the same purpose:

    protected Fault getFault(Integer dataCode, Integer faultCode,
            GregorianCalendar downloadTime, IFilterEncoder filter, FaultType faultType, boolean verbose) {
        // verbose: flag to display logging statements.
        Fault fault = new Fault(faultCode, 0);
        try {
            // We must be inside a transaction for cursors to work.
            conn.setAutoCommit(false);
            // Procedure call: getFault(integer, text, timestamp, integer)
            proc = conn.prepareCall("{ ? = call getfaultCount(?, ?, ?, ?, ?) }");
            proc.registerOutParameter(1, Types.OTHER);
            proc.setInt(2, dataCode);
            proc.setInt(3, faultCode);
            Timestamp ts = new Timestamp(downloadTime.getTimeInMillis());
            cal.setTimeZone(downloadTime.getTimeZone());
            proc.setTimestamp(4, ts, cal);
            proc.setInt(5, filter.getEncodedFilter());
            proc.setString(6, faultType.toString());
            proc.execute();
            if(verbose) {
                log.logInfo(this.getClass().getName(), "SQL: " + proc.toString());
            }
            results = (ResultSet) proc.getObject(1);
            while (results.next()) {
                //Do something with the results here
            }
        } catch (SQLException e) {
            //Log or handle exceptions here
        }
        return fault;
    }
    

    Here is the SQL that is inside the function (aka, Stored Procedure):

    CREATE OR REPLACE FUNCTION getfaultcount(_dataCodeid integer, _faultcode integer, _downloadtime timestamp without time zone, _filterbitmap integer, _faulttype text)
      RETURNS refcursor AS
    $BODY$
    DECLARE mycurs refcursor;
    BEGIN 
        OPEN mycurs FOR
        SELECT count(*) as faultcount, _downloadtime as downloadtime
        FROM    fs_fault f
            JOIN download_time d ON f.downloadtimeid = d.id
        WHERE   f.faultcode = _faultcode
            AND f.statusid IN(2, 4)
            AND d.downloadtime = _downloadtime
            AND d.dataCodeid = _dataCodeid 
        GROUP BY f.faultcode
        ;
        RETURN mycurs;
    END;
    $BODY$
      LANGUAGE plpgsql VOLATILE
      COST 100;
    ALTER FUNCTION getfaultcount(integer, integer, timestamp without time zone, integer, text) OWNER TO postgres;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I must use pkzip in my java program to zip (since standard java zip
I am programming a c project which must use the pow function defined in
Before anyone comments, I must use HSQLDB RDBMS; it's for university java project. My
I have active_record setup to use a Postgresql database. One of the columns is
I must use jquery, but the site contains prototype elements, and jquery UI tabs
I have checked online that getting IMEI must use private methods and thus violate
I must use goto in Python. I found entrians goto but my Python implementation
I have a process that must create and close threads on demand. Each thread
When we must use DebuggerDisplay Attributes? What is the advantage of using this?
In my company I must use a Bll, Dal and model layer for creating

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.