Packages

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
  

Poston Thu, 03 Jun 2004 3:47 pm

I am starting my studies about packages and was wondering if I can use an SQL statement in a procedure that is in the body of this package because when I create this package it gives me errors and when using the command SHO ERR to display the errors he found siz the select when other symbols were expected: follows the package
Code: Select all
Create PACKAGE OURPACK is
             TYPE t_testtype IS TABLE OF NUMBER  INDEX BY BINARY_INTEGER;
             procedure TestProc(p_TestArray t_testtype);
             end;

create PACKAGE BODY OURPACK as
   procedure TestProc(p_TestArray t_testtype) is
              v_variavel_local OurPack.testproc(p_testarray);
              QT_REG  number(10)    := 15;
              L_CDEMP CHAR(2)       := '01';
              L_CDFIL CHAR(4)       := '0001';
              L_NUSEQMOV CHAR(6)    := '000003';
              L_NUMERO  CHAR(10);
              j number(10) := 1;
              i number(10) := 0;
              begin
                while i < (QT_REG - 1) loop
                begin
                  v_variavel_local(i) := (
                                           select nuseqite
                                           from drvicv
                                           where
                                           cdemp = L_CDEMP and
                                           cdfil = L_CDFIL and
                                           nuseqmov = L_NUSECMOV
                                           );
                  i := (i + 1);
                  while j <> QT_REG loop
                  begin
                    j := (j + 1);
                      if v_variavel_local(i + 1) <> v_variavel_local(j) then
                        L_NUMERO := (to_char(v_variavel_local(j)));
                  end;
                end;
              end;
if anyone has a good material or tutorial, I appreciate ... falou
MuLtAnI
Location: Videira - SC


Poston Thu, 03 Jun 2004 10:32 pm

Hello MuLtAnI First, I took the liberty of editing your post-I put the tags CODE to better show the code ... OK?

About your question:
Code: Select all
v_variavel_local(i) := (
  select nuseqite
  from drvicv
  where
  cdemp = L_CDEMP and
  cdfil = L_CDFIL and
  nuseqmov = L_NUSECMOV );
that's something that can't be done in PL/SQL. When using a SELECT within the PL/SQL you must use the INTO clause to receive the value.

Code: Select all
select nuseqite
INTO v_variavel_local(i)
from drvicv
where cdemp = L_CDEMP and
cdfil = L_CDFIL and
nuseqmov = L_NUSECMOV;
Try this mod!
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered



Return to PL/SQL

Who is online

Users browsing this forum: No registered users and 1 guest