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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:28:58+00:00 2026-05-30T02:28:58+00:00

Trying to get into PostgreSQL. I’m drawing an function that will check credentials Here

  • 0

Trying to get into PostgreSQL.
I’m drawing an function that will check credentials

Here is it:

CREATE or REPLACE  FUNCTION CkeckUser (Login varchar(50), Password varchar(50)) 
RETURNS TABLE(ID int, IDParent int, Text varchar(50), Image bytea, DLLName varchar(50), MethodName varchar(50), Parameters varchar(250) )
 AS $$
DECLARE
  idu INT;
BEGIN

idu := null;

 select idu = u."ID"
 FROM  "Users" u
 where (u."Login" = $1) and (u."Password" = $2);

  select 
utm."IDMenuItem" as ID,
utm."IDParentMenuItem" as IDParent,
m."Text",
m."Image",
m."DLLName",
m."MethodName",
m."Parameters"
    from        "Users" u
            join "UserTypes" ut on u."Type" = ut."ID"
            join "UserTypeMenu" utm on u."Type" = utm."IDUserType"
            join "Menu" m on utm."IDMenuItem" = m."ID";
where u."ID" = IDU;
order by m."ID";

END; $$
 LANGUAGE 'plpgsql';

Logics is pretty simple but on executing it

 select CkeckUser(N'admin', N'test');

or

  select * from CkeckUser(N'admin', N'test');

I got

  ERROR:  query has no destination for result data

where I’m wrong?

  • 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-05-30T02:28:59+00:00Added an answer on May 30, 2026 at 2:28 am

    In PL/pgSQL, you can’t just run a query; you have to put the results somewhere. I take it that you want the function to return the query result?

    You can put RETURN QUERY before the query, which will append its result-set to the function’s return-value, but in your case, if that’s the entirety of your stored procedure, it’s probably easier to just change your stored-procedure to be pure SQL rather than PL/pgSQL:

    CREATE or REPLACE FUNCTION CkeckUser (Login varchar(50), Password varchar(50)) 
    RETURNS TABLE(ID int, IDParent int, Text varchar(50), Image bytea, DLLName varchar(50), MethodName varchar(50), Parameters varchar(250) )
      AS
      $$
        SELECT utm."IDMenuItem" AS ID,
               utm."IDParentMenuItem" as IDParent,
               m."Text",
               m."Image",
               m."DLLName",
               m."MethodName",
               m."Parameters"
          FROM "Users" u
          JOIN "UserTypes" ut
            ON u."Type" = ut."ID"
          JOIN "UserTypeMenu" utm
            ON u."Type" = utm."IDUserType"
          JOIN "Menu" m
            ON utm."IDMenuItem" = m."ID"
         WHERE u."ID" = ( SELECT u."ID"
                            FROM "Users" u
                           WHERE u."Login" = $1
                             AND u."Password" = $2
                        )
         ORDER
            BY m."ID"
      $$
      LANGUAGE 'SQL'
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use a function with PostgreSQL to save some data. Here is
Sometimes when copying stuff into PostgreSQL I get errors that there's invalid byte sequences.
I'm trying to create a function which references a temporary table in PostgreSQL 8.4.
Im trying to get into some basic JavaFX game development and I'm getting confused
I'm currently trying to get into the Java EE development with the Spring framework.
I've been trying to get into F# on and off for a while but
I'm trying to get into java again (it's been a few years). I never
I'm trying to get into C++ programming, and I'm quite struggling against the little
I am just trying to get into python, but I've found it very difficult
I'm a long time C++/Java developer trying to get into Python and am looking

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.