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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:23:57+00:00 2026-05-28T18:23:57+00:00

I am debugging a sql file in PostgreSQL’s pgAdminIII, and this statement creates a

  • 0

I am debugging a sql file in PostgreSQL’s pgAdminIII, and this statement creates a syntax error when executing:

ERROR:  syntax error at or near "v"
LINE 81384: ...n.oid = c.relnamespace  WHERE     c.relkind IN (\'v\') AND n...

The statement:

CREATE OR REPLACE FUNCTION getnextview()   
RETURNS name AS 
' DECLARE
   my_record RECORD;  viewName name; 
BEGIN
FOR my_record IN
  SELECT c.relname
  FROM pg_catalog.pg_class AS c
  LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace
  WHERE c.relkind IN (\'v\')
  AND n.nspname NOT IN (\'pg_catalog\', \'pg_toast\')
  AND pg_catalog.pg_table_is_visible(c.oid)
  LIMIT 1
LOOP
   viewName := my_record.relname;  
END LOOP;
RETURN (viewName);
END; '  LANGUAGE 'plpgsql' VOLATILE;

Note, the pg_catalog and pg_toast also error.

  • 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-28T18:23:58+00:00Added an answer on May 28, 2026 at 6:23 pm

    So the full statement does change the picture substantially.

    Your problem is the nesting of single quotes. If you use PostgreSQL’s “dollar quoting” everything is a lot easier:

    CREATE OR REPLACE FUNCTION getnextview() 
      RETURNS name 
    AS 
    $body$
    DECLARE 
        my_record RECORD; 
        viewName name; 
    BEGIN 
        FOR my_record IN 
                SELECT c.relname 
                FROM pg_catalog.pg_class AS c 
                  LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace 
                WHERE c.relkind IN ('v') 
                  AND n.nspname NOT IN ('pg_catalog', 'pg_toast') 
                  AND pg_catalog.pg_table_is_visible(c.oid) 
                LIMIT 1 
        LOOP 
            viewName := my_record.relname; 
        END LOOP; 
    
        RETURN (viewName); 
    END; 
    $body$
    LANGUAGE 'plpgsql' 
    VOLATILE;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently debugging an Ms SQL Function (SQL 2008). In this function, I have
I am debugging this error on my dataset table.I dunno what error is called.I
How do I go about debugging a SQL statement in SQuirrel-sql? I keep getting
Debugging some finance-related SQL code found a strange issue with numeric(24,8) mathematics precision. Running
I am debugging some code and have encountered the following SQL query (simplified version):
I have a problem when debugging stored procedure using SQL server Management Studio 2008.
Debugging experience http://www.dmhermitage.org/wtfborders.png This is making me want to kill myself. I have some
Any idea, why none of the debugging comments are printed once after executing the
I have SQL Server 2008 and SSMS 2008, and I'm debugging a script. I
How might I see the SQL query generated from LINQ to SQL when debugging

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.