Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

anonymous function block and other SQL statements in one command

Florian LindnerSep 18 2024

Hi,

I have this snippet of SQL that runs perfectly well and as expected in SQL Developer interactive, but I cannot get it to run with Oracle.ManagedDataAccess.Client.

SQL:

DECLARE
  index_not_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT (index_not_exists, -1418);
BEGIN
  EXECUTE IMMEDIATE 'DROP INDEX PIMANRELATION_RRELATION_TYPEU_IDX_BMP';
EXCEPTION
  WHEN index_not_exists
  THEN
     NULL;
END;
/	
CREATE BITMAP INDEX PIMANRELATION_RRELATION_TYPEU_IDX_BMP ON TCBIGDATA.PIMANRELATION (RRELATION_TYPEU)

Output of SQL Developer:

PL/SQL-Prozedur erfolgreich abgeschlossen.
INDEX PIMANRELATION_RRELATION_TYPEU_IDX_BMP erstellt.

(sorry, German, both lines translate to "successful")

PowerShell Code:

$oracmd = $oracon.CreateCommand()
$oracmd.CommandType = "text"
$oracmd.CommandText = (Get-Content $_.FullName -Raw)
$oracmd.ExecuteNonQuery()

$oracon is a working connection, CommandText reads a text file with exactly the SQL contents above

error message:

Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "ORA-06550: Zeile 11, Spalte 1:
PLS-00103: Fand das Symbol "/" "

Is there a way to run my SQL snippet with PowerShell?

This post has been answered by Solomon Yakobson on Sep 18 2024
Jump to Answer
Comments
Post Details
Added on Sep 18 2024
3 comments
38 views