Skip to main content
Question

SQL to run after write feature writer

  • April 12, 2019
  • 1 reply
  • 64 views

raaaju1990
Contributor
Forum|alt.badge.img+9

Hi,

I'm trying to create Index on attributes for a feature class inside FGDB. I'm using SQL to run after write option available in Feature writer. But i'm getting invalid sql statement. But it works fine when I tested in sql developer. Below is the sql,

 

FME_SQL_DELIMITER ;

DECLARE

strColumnNames VARCHAR(200);

P_COLUMN_NAME VARCHAR(200);

strStatement VARCHAR(2000);

P_INDEX_NAME VARCHAR(200);

P_TABLE_NAME VARCHAR(200);

ind NUMBER;

indexCount NUMBER;

BEGIN

strColumnNames := '@Value(idx)';

P_TABLE_NAME:= '@Value(processname)_WM';

ind := instr(strColumnNames,',');

indexCount:= 1;

WHILE ind > 0 LOOP

P_COLUMN_NAME := SUBSTR(strColumnNames,1,ind-1);

P_INDEX_NAME:= P_COLUMN_NAME || '_' || indexCount;

strStatement := 'CREATE INDEX ' || P_INDEX_NAME || ' ON ' || P_TABLE_NAME || '(' || P_COLUMN_NAME || ')';

dbms_output.put_line('Statement is : ' || strStatement);

strColumnNames := SUBSTR(strColumnNames,ind+1,LENGTH(strColumnNames)-ind);

ind := instr(strColumnNames,',');

indexCount := indexCount + 1;

END LOOP;

P_COLUMN_NAME := strColumnNames;

P_INDEX_NAME:= P_COLUMN_NAME || '_' || indexCount ;

strStatement := 'CREATE INDEX ' || P_INDEX_NAME || ' ON ' || P_TABLE_NAME || '(' || P_COLUMN_NAME || ')';

dbms_output.put_line('Statement is : ' || strStatement);

END;

 

Not sure where I'm going wrong and also is it right to run this sql on FGDB?

 

Thanks

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

itay
Supporter
Forum|alt.badge.img+18
  • Supporter
  • 1442 replies
  • April 12, 2019

HI @raaaju1990,

My guess is that the FME_SQL_DELIMITER character you are using (';') is causing the problems, try using another character, or if its one SQL statement dont use it at all all use the built in possibility to index the attributes on the feature writer.

Hope this helps,

Itay