SQL script, to insert emails into a table, and then change them

3

I have a script, which makes random insertions of emails into a table, after these inserts, I need to find a way to recheck those inserted emails, and change them

This is a part of Script, I give him a lot of emails (for example 5), and he will create 5 email ([email protected] .... kaue5 @ email. com), what I'm not getting is after these inserts, replace those emails in an UPDATE. I need to replace these same emails by other email, such as ([email protected] .... [email protected])

FOR i IN 1..V_QTD_EMAILS LOOP
INSERT INTO G_CADASTRO.PX_EMAIL
  (
  ID,
  CD_DADOS_XXX_XXX_XXX,
  EMAIL,
  DT_INCLUSAO,
  CD_USUARIO
  )
VALUES
  (
    (SELECT MAX(ID) + 1
    FROM G_CADASTRO.PPX_EMAIL),
    V_CD_DADOS_PX_ESTAB,
    'KAUE' || i || '@EMAIL.COM.BR',
    SYSDATE,

    4993
  );
END LOOP;

COMMIT;

I tried to include this block, but it did not work:

FOR i IN 5..V_QTD_EMAILS loop
  UPDATE G_CADASTRO.PX_EMAIL
     SET EMAIL = 'MATHEUS_' || i || '@EMAIL.COM.BR'
    WHERE CD_DADOS_PX_ESTAB = V_CD_DADOS_PX_ESTAB
END LOOP;

Could you help me?

    
asked by anonymous 12.06.2018 / 15:02

1 answer

1

Person, I resolved with the following SCRIPT:

FOR i IN 1..V_QTD_EMAILS loop
  UPDATE G_CADASTRO.PX_EMAIL
      SET EMAIL = 'TSTALTERACAO_' || i || '@EMAIL.COM.BR'
      WHERE EMAIL = 'KAUE' || i || '@EMAIL.COM.BR'
      AND CD_USUARIO = 4993;
END LOOP;

Thanks for everyone's help

    
12.06.2018 / 15:30