473,327 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Not doing the execute of the return query from a cursor

1
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE function  user_drop (p_user   in   text)
  2. returns setof record  AS $BODY$ 
  3. DECLARE
  4.    sql_new_statement text;
  5.     cur_user_roles CURSOR(p_user  text)
  6.       for    select 'revoke '||c.rolname||' from '||a.rolname||';'
  7.               from pg_catalog.pg_roles a
  8.               inner join pg_auth_members b on a.oid=b.member
  9.               inner join pg_roles c on b.roleid=c.oid 
  10.               where a.rolname = p_user;
  11.     BEGIN
  12.        open  cur_user_roles(p_user);
  13.        loop
  14.        FETCH cur_user_roles into  sql_new_statement;
  15.         raise notice 'Value: %', sql_new_statement;
  16.         return query execute ''''||sql_new_statement||'''';
  17.         raise notice 'Value: %', return_query;
  18.        EXIT WHEN NOT FOUND;
  19.        raise notice 'Value: %', sql_new_statement;
  20.          commit;
  21.     END LOOP;
  22.    CLOSE cur_user_roles;
  23. return;
  24. exception
  25.    when others then
  26.     null;
  27. END;
  28. $BODY$ LANGUAGE plpgsql;


The return query execute ''''||sql_new_statement||''''; is not executing the sql showing in sql_new_statement.
Feb 27 '20 #1
0 2088

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: JT | last post by:
i hope no one is getting sick of my server.execute/transfer questions.. does server.execute return a value? im wondering what happens if an error occurs in the .asp file that i'm calling with...
3
by: D-Zyl | last post by:
I wanna execute a query with one parameter from MS VBA. the trouble is that the parameter is a control in a form. and I still don't know what is the code I need...
0
by: Charliechau | last post by:
Hi, Could someone tell me if I can execute a query of MS Access database if I buy the "MS visual studio for MS Office System" Thanks, /CC.
1
by: Marcelo Moreira | last post by:
Hi all, I want to execute a query making use of the index service provided with windows. How can I make this? It would also be great to know how I can manage (which class to use) my catalogs. ...
9
by: sohan | last post by:
Hi, I want to know how to connect and execute a db2 query from inside a UNIX shell script. Details: We have a unix shell script. We need to execute multiple db2 sql queries from this shell...
2
by: kentek | last post by:
Greetings, Please be gentle as I have never touched SQL Server other that to configure it for Sharepoint MOSS 2007 on Server 2003. I understand some of the SQL Query language but I am at a total...
1
by: rvmohan123 | last post by:
Hi i am new to java script i have select a list box the listbox column name select after condition is checked then i click add button after execute sql query in another list box this is my...
1
by: FEILynn | last post by:
I am trying to write a query that will provide the average of 5 columns. Here is my query, but each time I try to run it I get this error: You tried to execute a query that does not include the...
3
by: inte | last post by:
Hi everyone I get this error when every I try to execute a particular query in my db. ""You tried to execute a query that does not include the specified expression 'salesID' as part of an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.