Question

SQL to run after write feature writer

  • 12 April 2019
  • 1 reply
  • 8 views

Badge +5

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


1 reply

Badge +16

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

Reply