Kamil Kliczbor @ asptip.net

6Jul/100

Wywołanie funkcji z Oracle w NHibernate

Wywołanie funkcji w NHibernacie można zrealizować z poziomu SQLQuery w następującym bloku kodu:

public string DajAdres(string typAdresu)

        {
            var query = Session.CreateSQLQuery("select pakiet.FunkcjaZwracajacaAdres (:parametr) from dual")
                .SetString("parametr", typAdresu);
 
            string address = query.UniqueResult<string>();
            return address;
        }
6Jul/100

PLS-00201: identifier must be declared

Przyczyny powstania błędu o kodzie PLS-00201: identifier must be declared mogą być różne. Sprawdzenie następujących kroków może przyczynić się do znalezienia rozwiązania (http://www.dbforums.com/oracle/1207142-pls-00201-identifier-ordsys-ordimage-must-declared.html):

Cause:
An attempt was made to reference either an undeclared variable, exception, procedure, or other item, or an item to which no privilege was granted or an item to which privilege was granted only through a role.

Action:

Check your spelling and declaration of the referenced name.

Verify that the declaration for the referenced item is placed correctly in the block structure.

If the referenced item is indeed declared but you do not have privileges to refer to that item, for security reasons, you will be notified only that the item is not declared.

If the referenced item is indeed declared and you believe that you have privileges to refer to that item, check the privileges; if the privileges were granted only via a role, then this is expected and documented behavior.

Stored objects (packages, procedures, functions, triggers, views) run in the security domain of the object owner with no roles enabled except PUBLIC. Again, you will be notified only that the item was not declared.

Najczęściej pomaga zdefiniowanie (publicznego) synonimu przy użyciu magicznego zaklęcia:

create or replace public synonym nazwa for schemat.nazwa;