0

I'm a BackEnd programmer, and I'm facing a challenge in testing my API methods effectively. Sometimes, the FrontEnd part of the application is not ready, which means I have to test my methods using tools like Postman, Talend, or similar ones. Some of the methods I've created expect to receive a list of objects as an argument. However, it can be quite difficult to manually write a JSON with a whole list to make a request to my API.

The good news is that I already have the desired list in my database. So, all I need to do is retrieve it and use it in the payload of my JSON request. However, I'm encountering unexpected difficulties, as my current approach isn't working, and I'm struggling to convert the list into a JSON format. Do you have any ideas or suggestions to help me with this issue?

  SELECT
      '[' || 
      LISTAGG(json_part, ',') WITHIN GROUP (ORDER BY 1) || 
      ']' AS json_payload
    FROM (
      SELECT 
        '{"CodigoEmpresa":' || IDEMPRESA ||
        ',"Id":' || IDMOVIMENTACAO ||
        ',"TipoPrevisao":"' || TIPO_PREVISAO ||
        '","EntraSai":"' || ENTRA_SAI ||
        '","Valor":' || VALOR ||
        ',"DataMovto":"' || TO_CHAR(DATA_MOVTO, 'YYYY-MM-DD') ||
        '","CodigoNaturezaFin":' || IDNATUREZA_FIN ||
        ',"Descricao":"' || REPLACE(DESCRICAO, '"', '\"') || '"}' AS json_part
      FROM Fc_Movimentacoes
      WHERE VALOR = 100
    ) subquery;

ORA-01489: Oracle - ORA-01489: result of string concatenation is too long

0 Answers0