42809: (timestamp without time zone, timestamp without time zone) is a procedure POSITION: 15

55 views Asked by At

C# Application Project Entityframework 4.7.2 Npgsql version 7.0.1

I have provided below the C# code and PostgresSQL Schema. When the code executes the cmd, it failed with 42809: red.common$getreinsurers(timestamp without time zone, timestamp without time zone) is a procedure POSITION: 15. I don't know why it is not bringing back the "SELECT" records from the schema procedure. Don't understand position 15?

DataSet ds = new DataSet();
cmd.CommandText = "SELECT * FROM red.common$getreinsurers(@p_fromdate,@p_todate)";
cmd.CommandType = CommandType.StoredProcedure;
                    DateTime dateTime = DateTime.Now;
                    cmd.Parameters.AddWithValue("@p_fromdate", NpgsqlDbType.Timestamp, dateTime);
                    cmd.Parameters.AddWithValue("@p_todate", NpgsqlDbType.Timestamp, dateTime);
                    cmd.Parameters.AddWithValue("p_refcursorreinsurers", NpgsqlDbType.Refcursor);
                    cmd.Parameters[2].Direction = ParameterDirection.Output;
                    cmd.Parameters.AddWithValue("p_sqlcode", NpgsqlDbType.Double);
                    cmd.Parameters[3].Direction = ParameterDirection.Output;
                    cmd.Parameters.AddWithValue("p_sqlerrm", NpgsqlDbType.Text);
                    cmd.Parameters[4].Direction = ParameterDirection.Output;

                    NpgsqlDataAdapter da = new NpgsqlDataAdapter(cmd);
                    da.Fill(ds);

Schema

CREATE OR REPLACE PROCEDURE red.common$getreinsurers(IN p_fromdate timestamp without time zone, IN p_todate timestamp without time zone, OUT p_refcursorreinsurers refcursor, 
AS 
$BODY$timestamp without time zone, IN p_todate timestamp without time zone, OUT p_refcursorreinsurers refcursor, 
DECLARE
    p_refCursorReinsurers$ATTRIBUTES aws_oracle_data.TCursorAttributes;
BEGIN
    p_refCursorReinsurers := NULL;
    OPEN p_refCursorReinsurers FOR
    SELECT DISTINCT
        r.*, tg.name AS tg_name, tg.id AS treaty_group_id, tg.start_date AS tg_start_date, tg.minimum_incident_date AS tg_minimum_incident_date, tg.maximum_incident_date AS tg_maximum_incident_date, tgr.percentage_repayment, tgr.effective_from_date, tgr.effective_to_date
        FROM red.treaty_groups AS tg, red.treaty_group_reinsurers AS tgr, red.reinsurers AS r
        WHERE tg.id = tgr.treaty_group_id AND tgr.reinsurers_id = r.id AND tgr.effective_from_date <= p_fromdate AND tgr.effective_to_date >= p_todate;
    p_refCursorReinsurers$ATTRIBUTES := ROW (TRUE, 0, NULL, NULL);
    p_sqlcode := '';
    p_sqlerrm := '';
END;
$BODY$

1

There are 1 answers

2
Alexandr Kaltenberg On
  1. DateTime.Now uses time zone, without time zone you need to use DateTime.UtcNow.
  2. Or in the procedure change the input parameters to timestamp with time zone instead of without time zone (and in this case save DateTime.Now) if a time zone is needed