0

I tried using the LISTAGG function before, but since there is a likelihood that the output would be pretty long, maybe even more than 4000 bytes.. I kept getting the error that the result of string concatenation is too long. I followed AskTom page that Tim references about the implementation of a string aggregation function that returns a CLOB.

           CREATE TABLE FINAL_LOG AS
           SELECT SESSION_DT, C_IP, CS_USER_AGENT,
           concat_all_ot(WEB_LINK, ' ')
           WITHIN GROUP(ORDER BY C_IP, CS_USER_AGENT) AS "WEBLINKS"
               FROM weblog_views
               GROUP BY C_IP, CS_USER_AGENT, SESSION_DT
               ORDER BY SESSION_DT

For this I get the following error,

SQL Error: ORA-00923: FROM keyword not found where expected

Can anyone tell me where I'm going wrong with this?

1
  • you don't need the WITHIN GROUP clause. it's ok only the function and its parameters. Dec 10, 2012 at 11:57

1 Answer 1

5

If you're using a user-defined aggregate function, you probably need to omit the WITHIN GROUP clause. It also doesn't make sense to specify an ORDER BY clause in a CREATE TABLE statement since the data in a heap-organized table is inherently unordered. Also, if you are using the code in that link, the name of the aggregate function is concat_all. concat_all_ot is the object type. So you'd want something like

CREATE TABLE FINAL_LOG  AS   
  SELECT SESSION_DT, 
         C_IP, 
         CS_USER_AGENT,
         concat_all( concat_expr(WEB_LINK, ' ') ) AS "WEBLINKS"
    FROM weblog_views    
   GROUP BY C_IP, 
            CS_USER_AGENT, 
            SESSION_DT
4
  • Thanks for your reply but I get the error "not a GROUP BY expression". Dec 10, 2012 at 12:07
  • @user1874311 - I edited my answer. The name of the aggregate function on the link you provided is concat_all not concat_all_ot. Dec 10, 2012 at 12:11
  • I did what you suggested, I get the following error, SQL Error: ORA-06553: PLS-306: wrong number or types of arguments in call to 'CONCAT_ALL' Dec 10, 2012 at 14:39
  • @user1874311 - Yup. Missed a wrinkle. Edited my answer. Dec 10, 2012 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.