![]() **Live simply **Love generously **Care deeply **Speak kindly. But to those who knew him well, he was a perfect gentleman (Hermione Gingold) ![]() With PL/pgSQL 's control structures, you can manipulate PostgreSQL data in a very flexible and powerful way. So judge less, love and forgive more.To call him a dog hardly seems to do him justice though in as much as he had four legs, a tail, and barked, I admit he was, to all outward appearances. Estoy elaborando un script en postgresql para la creación de tablas temporales dinámicas, tanto para el nombre de la tabla como para la condición where a.estado. Obtaining Execution Location Information Control structures are probably the most useful (and important) part of PL/pgSQL. ![]() If you avoid people for their mistakes you will be alone. No one in this world is pure and perfect. Would you please tell me what is wrong where?ĬREATE OR REPLACE FUNCTION "CIDRDBA"."CIDRDBA_CONSTRAINTS" ( val in varchar(4000) ) RETURNS VOIDas $$begin if val = 'DISABLE' then raise notice '%', 'CIDRDBA Constarints are being disabled' for c in ( select table_name, constraint_name from information_schema.table_constraints where constraint_type = 'R' ) loop raise notice '%', 'Processing table: ' || c.table_name || ' - constraint' || c.constraint_name execute immediate 'alter table ' || c.table_name ||' ' || val || ' constraint ' || c.constraint_name end loop for c in ( select table_name, constraint_name from information_schema.table_constraints where constraint_type = 'P' ) loop raise notice '%', 'Processing table: ' || c.table_name || ' - constraint' || c.constraint_name execute immediate 'alter table ' || c.table_name || ' ' || val || ' constraint ' || c.constraint_name end loop elsif val = 'ENABLE' then raise notice '%', 'CIDRDBA Constarints are being enabled' for c in ( select table_name, constraint_name from information_schema.table_constraints where constraint_type = 'P' ) loop raise notice '%', 'Processing table: ' || c.table_name || ' - constraint' || c.constraint_name execute immediate 'alter table ' || c.table_name ||' ' || val || ' constraint ' || c.constraint_name end loop for c in ( select table_name, constraint_name from information_schema.table_constraints where constraint_type = 'R' ) loop raise notice '%', 'Processing table: ' || c.table_name || ' - constraint' || c.constraint_name execute immediate 'alter table ' || c.table_name || ' ' || val || ' constraint ' || c.constraint_name end loop else raise notice '%', 'CIDRDBA nothing to do' end if end $$ LANGUAGE plpgsql ĮRROR: loop variable of loop over rows must be a record or row variable or list of scalar variablesLINE 6: for c in ( select table_name, constraint_nam. I have checked online and don't see anything wrong on for. CREATE TABLE balances ( userid INT, balance INT, asofdate DATE ) INSERT INTO balances (userid, balance, asofdate) VALUES (1, 100, ''), (1, 50, ''), (1, 10, ''), (2, 200, ''), (3, 30, '') It only contains balances for dates that a user has made a transaction. I have a script migrating from oracle to Postgres. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |