Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. PostgreSQL code problem

PostgreSQL code problem

Scheduled Pinned Locked Moved Database
databasepostgresqlhelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    why this code returns all rows although I specified the condition? how to correct?

    CREATE OR REPLACE FUNCTION fn_get_resume_details2(resume_id integer)
    RETURNS SETOF record AS

    $$select resume_id, resume_title, objective_title, objective_text, summary_title, summary_text from resume_details where resume_id = resume_id;
    $$LANGUAGE sql;
    </pre>

    C 1 Reply Last reply
    0
    • J Jassim Rahma

      why this code returns all rows although I specified the condition? how to correct?

      CREATE OR REPLACE FUNCTION fn_get_resume_details2(resume_id integer)
      RETURNS SETOF record AS

      $$select resume_id, resume_title, objective_title, objective_text, summary_title, summary_text from resume_details where resume_id = resume_id;
      $$LANGUAGE sql;
      </pre>

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      In your where clause, resume_id = resume_id, that is the same as saying where 1 = 1. It will be true for all rows. I'd recommend changing the name of your parameter to be different from the column name.

      CREATE OR REPLACE FUNCTION fn_get_resume_details2(in_resume_id integer)
      RETURNS SETOF record AS
      $$select resume_id
      ,resume_title
      ,objective_title
      ,objective_text
      ,summary_title
      ,summary_text
      from resume_details
      where resume_id = in_resume_id;
      $$LANGUAGE sql;

      :)

      Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups