I am trying to execute this statement from
http://www.firebirdfaq.org/faq167/ but without success:

===============
set term !! ;

EXECUTE BLOCK AS
declare variable index_name VARCHAR(31);
BEGIN
for select RDB$INDEX_NAME from RDB$INDICES into :index_name do
execute statement 'SET statistics INDEX ' || :index_name || ';';
END!!

set term ; !!
===============

I tried both Data.Firebird and Data.Firebird.Isql

Method 1: isql (returns System.InvalidOperationException: There are no
commands for execution.)
             Dim sSQL As String = "set term !! ; " & ControlChars.NewLine &
_
            "EXECUTE BLOCK AS " & ControlChars.NewLine & _
            "declare variable index_name VARCHAR(31);" &
ControlChars.NewLine & _
            "BEGIN " & ControlChars.NewLine & _
            "for select RDB$INDEX_NAME from RDB$INDICES into :index_name do
" & ControlChars.NewLine & _
            "execute statement 'SET statistics INDEX ' || :index_name ||
';';" & ControlChars.NewLine & _
            "END!! " & ControlChars.NewLine & _
            "set term ; !!"

            Dim sreader As New IO.StringReader(sSQL)
            Dim fb_script As New FirebirdSql.Data.Isql.FbScript(sreader)
            Dim batch As New
FirebirdSql.Data.Isql.FbBatchExecution(MyConnection, fb_script)
            batch.Execute(True)



Method 2: ExecuteNonQuery
            Dim sSQL As String = "set term !! ; " & ControlChars.NewLine & _
            "EXECUTE BLOCK AS " & ControlChars.NewLine & _
            "declare variable index_name VARCHAR(31);" &
ControlChars.NewLine & _
            "BEGIN " & ControlChars.NewLine & _
            "for select RDB$INDEX_NAME from RDB$INDICES into :index_name do
" & ControlChars.NewLine & _
            "execute statement 'SET statistics INDEX ' || :index_name ||
';';" & ControlChars.NewLine & _
            "END!! " & ControlChars.NewLine & _
            "set term ; !!"
             ...............
            Cmd.CommandText = strSQL
            Cmd.ExecuteNonQuery()


I am getting this exception:

FirebirdSql.Data.FirebirdClient.FbException: Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 5
term ---> Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 5
term


I am using firebird 2.1.3
FirebirdSql.Data.FirebirdClient.dll 2.5.1
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to