Gracias a tu aclaración logre solventar ese problema. acá les dejo la función:
Código SQL:
Ver originalCREATE OR REPLACE FUNCTION Consul_CBPartner(cbpartnerid1 INT, cbpartnerid2 INT) RETURNS INTEGER AS
$BODY$
DECLARE
reg_table record;
reg_tablename record;
COUNT INTEGER;
al text;
countsql text;
l_into text;
BEGIN
al := 'Select adt.tablename,adt.name,ac.name,ac.columnname From AD_Column ac Join AD_Table adt On ac.AD_Table_ID = adt.AD_Table_ID Join information_schema.Columns infc On infc.Table_Name = lower(adt.TableName) And lower(ac.ColumnName) = infc.Column_Name Where ac.ColumnName = ''C_BPartner_ID'' And adt.IsView <> ''Y'' And ac.ColumnSql is null And adt.TableName not in (''C_BPartner'',''C_Bp_Customer_Acct'') And ac.IsActive = ''Y''';
COUNT := 0;
FOR reg_table IN EXECUTE al
loop
countsql := 'Select Count(*) as TotalTabla From '|| reg_table.TableName ||' Where C_BPartner_ID = '|| cbpartnerid1 ||'';
FOR reg_tablename IN EXECUTE countsql
loop
--Raise Notice '% %', reg_table.TableName, reg_tablename.TotalTabla;
EXECUTE 'Update '|| reg_table.TableName ||' set C_BPartner_ID = '|| cbpartnerid2 ||' where C_BPartner_ID = '|| cbpartnerid1 ||'';
END loop;
COUNT := COUNT + 1;
END loop;
RETURN COUNT;
END;
$BODY$
LANGUAGE plpgsql
SELECT Consul_CBPartner(1004008,1003854)
aunque aun tengo un problemita menos grave, tengo un apostrofe de mas en esta parte:
Código SQL:
Ver original'Select adt.tablename,adt.name,ac.name,ac.columnname From AD_Column ac Join AD_Table adt On ac.AD_Table_ID = adt.AD_Table_ID Join information_schema.Columns infc On infc.Table_Name = lower(adt.TableName) And lower(ac.ColumnName) = infc.Column_Name Where ac.ColumnName = ''C_BPartner_ID'' And adt.IsView <> ''Y'' And ac.ColumnSql is null And adt.TableName not in (''C_BPartner'',''C_Bp_Customer_Acct'') And ac.IsActive = ''Y''';
no logro ver en donde es.. si puedes echarle un vistazo.!!