Frage

Ich halte die folgende errror bekommen, 'ORA-01008: nicht alle Variablen gebunden', im guessign seine alle basierend auf meinen pPostcode param aber im nicht sicher. Ich bin ein Anfänger das der ganze PLSQL secne und jede Hilfe wäre sehr apriciated

hier ist mein Verfahren:

 procedure all_customer_postcode(pPostcode in carer.postcode%type
                                ,pReport out SYS_REFCURSOR) is
  begin
    open pReport for
      select c.id, c.forename, c.surname,c.address_1,c.address_2,
             c.address_3,c.address_4, c.postcode, c.date_of_birth, cf.id    
        from customer c, customer_friend cf,customer_friend_for cff 
       where c.id = cff.customer_id AND cff.id = cff.customer_friend_id
       AND c.postcode = pPostcode;
  end;

Danke Jon

War es hilfreich?

Lösung

Ich habe Ihre Prozedur leichte geändert, wie der WHERE-Klausel nicht Sinn für mich veröffentlicht hat ...

SQL> create or replace procedure all_customer_postcode
  2          (pPostcode in customer.postcode%type
  3                                  ,pReport out SYS_REFCURSOR) is
  4  begin
  5      open pReport for
  6        select c.id
  7               , c.forename
  8               , c.surname
  9               ,c.address_1
 10               ,c.address_2
 11               ,c.postcode
 12               , c.date_of_birth
 13               , cf.id  as cf_id
 14          from customer c
 15              , customer_friend cf
 16              ,customer_friend_for cff
 17         where c.id = cff.customer_id
 18         AND cf.id = cff.customer_friend_id
 19         AND c.postcode = pPostcode;
 20  end;
 21  /

Procedure created.

SQL>

es in SQL * Plus mit Variablen Aufruf funktioniert ...

SQL> var rc refcursor
SQL> var pc varchar2(8)
SQL> exec :pc := 'ML1 4KJ'

PL/SQL procedure successfully completed.

SQL> exec all_customer_postcode(:pc, :rc)

PL/SQL procedure successfully completed.

SQL> print rc

        ID FORENAME   SURNAME    ADDRESS_1            ADDRESS_2            POSTCODE DATE_OF_B      CF_ID
---------- ---------- ---------- -------------------- -------------------- -------- --------- ----------
         1 Joe        Chip       1234 Telepath Drive  Milton Lumpky        ML1 4KJ  01-FEB-90         11
         4 Ray        Hollis     777 Telepath Drive   Milton Lumpky        ML1 4KJ  01-SEP-81         44
         5 Pat        Conley     1235 Telepath Drive  Milton Lumpky        ML1 4KJ  01-OCT-91         55

SQL>

Also, wie können wir bekommen sie einen ORA-1008 zu schleudern? Durch Drehen der Abfrage in einen String und die Änderung der Art und Weise der Parameter deklariert wird ...

SQL> create or replace procedure all_customer_postcode
  2          (pPostcode in customer.postcode%type
  3                                  ,pReport out SYS_REFCURSOR) is
  4  begin
  5      open pReport for
  6        'select c.id
  7               , c.forename
  8               , c.surname
  9               ,c.address_1
 10               ,c.address_2
 11               ,c.postcode
 12               , c.date_of_birth
 13               , cf.id  as cf_id
 14          from customer c
 15              , customer_friend cf
 16              ,customer_friend_for cff
 17         where c.id = cff.customer_id
 18         AND cf.id = cff.customer_friend_id
 19         AND c.postcode = :pPostcode';
 20  end;
 21  /

Procedure created.

SQL> exec all_customer_postcode(:pc, :rc)
BEGIN all_customer_postcode(:pc, :rc); END;

*
ERROR at line 1:
ORA-01008: not all variables bound
ORA-06512: at "APC.ALL_CUSTOMER_POSTCODE", line 5
ORA-06512: at line 1


SQL>

Lassen Sie uns so fix , die ...

SQL> create or replace procedure all_customer_postcode
  2          (pPostcode in customer.postcode%type
  3                                  ,pReport out SYS_REFCURSOR) is
  4  begin
  5      open pReport for
  6        'select c.id
  7               , c.forename
  8               , c.surname
  9               ,c.address_1
 10               ,c.address_2
 11               ,c.postcode
 12               , c.date_of_birth
 13               , cf.id  as cf_id
 14          from customer c
 15              , customer_friend cf
 16              ,customer_friend_for cff
 17         where c.id = cff.customer_id
 18         AND cf.id = cff.customer_friend_id
 19         AND c.postcode = :pPostcode' using pPostcode;
 20  end;
 21  /

Procedure created.

SQL> exec all_customer_postcode(:pc, :rc)

PL/SQL procedure successfully completed.

SQL> 

So habe ich es geschafft, eine ORA-1008 neu zu erstellen; Ich bin mir nicht sicher, ob es Ihre ORA-1008 Situation paßt. Ihre Intuition ist richtig, es ist etwas mit, wie der Wert in pPostcode zu tun ist, um die Abfrage übergeben. Es ist nur, dass der Code, den Sie tatsächlich geschrieben tut es richtig und so nicht ausfällt.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top