I have a PLSQL code: in which I get two values one numeric and another varchar.
Code:
create or replace FUNCTION hospitalTeste123(MatriculaMedico in number, nomeSchema in varchar2 ) return varchar is
type Tmedicos is record(
matMedico nomeSchema.Tmedico.matricula%type,
especialidade nomeSchema.Tmedico.especialidade%type,
cd_setor nomeSchema.Tmedico.cd_setor%type
);
medico Tmedicos;
begin
medico.matMedico := 123;
medico.especialidade := 'geral';
medico.cd_setor := 'urgencia';
RETURN medico.MatMedico;
end;
Tables Creation
create table TMedico(
matMedico number(10) NOT NULL,
especialidade varchar2(50) NOT NULL,
cd_setor varchar2(50) NOT NULL
);
insert into TMedico(matMedico,especialidade,cd_setor) Values (120,'clinico-geral','UTI');
insert into TMedico(matMedico,especialidade,cd_setor) Values (150,'cardiologista','UTI');
insert into TMedico(matMedico,especialidade,cd_setor) Values (180,'pediatria','UTI');
Error message:
PLS-00487: Invalid reference to variabel 'nomeSchema'
Error (3.3): PL / SQL: Item ignored Error (4.19): PLS-00487: Invalid reference to variable 'NOMESCHEMA' Error (13,3): PL / SQL: Statement ignored Error (13,10): PLS-00320: the declaration of the type of this expression is incomplete or malformed Error (14,3): PL / SQL: Statement ignored Error (14,10): PLS-00320: the declaration of the type of this expression is incomplete or malformed Error (15,3): PL / SQL: Statement ignored Error (15,10): PLS-00320: the declaration of the type of this expression is incomplete or malformed Error (17,2): PL / SQL: Statement ignored Error (17,16): PLS-00320: the declaration of the type of this expression is incomplete or malformed
The error is when I pass the name of the schema on which the table is stored. As each hospital has a different Schema.
Picture of the table with Schema
Callingthefunction
declarebeginDBMS_OUTPUT.PUT_LINE(hospitalTeste123(123,'dbamv'));end;
Errormessage:
ErrorReporting-ORA-06550:Line4,Column24:PLS-00905:Object DBAMV.HOSPITALTESTE123isinvalidORA-06550:line4,column3: PL/SQL:Statementignored 06550.00000-"line% s, column% s: \ n% s" * Cause: Usually a PL / SQL compilation error. * Action: