Results 1 to 6 of 6

Thread: psql function

  1. #1
    Join Date
    Feb 2015
    Posts
    5

    Unanswered: psql function

    Hi ,
    I want to pass a tablename as a parameter in psql function and fetch data . Any way to do that !!

  2. #2
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    Actually, a function cannot return a dataset. You might be able to return one specific value though.
    A stored procedure or a view can return a full data set, one of those might be a better option.

    What version of PSQL are you using?
    Also, what is your goal? What are you trying to accomplish with the function?
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  3. #3
    Join Date
    Feb 2015
    Posts
    5
    Thanks for the reply.
    Using PG_Version --> 9.2

    What I wanted is : to create a function that takes a tablename as a parameter (dynamic) and select * from that table and show result.

    so that user can pass anytable as argument and views the data from respective table..
    Can I do it through a psql function ?

  4. #4
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    Are you using Pervasive PSQL or PostgreSQL?
    As to your question, why add that layer? Why not have the user just issue the "select * from <table>" and execute that?
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  5. #5
    Join Date
    Feb 2015
    Posts
    5
    Using PostGre and the table name is dynamic thatswhy . Is it possible to achieve it via function ??

  6. #6
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    Okay, this is the Pervasive forum, not the PostgreSQL. That being said, a quick Google search found this post that should do what you want.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •