Exoskeletor Δημοσ. 22 Μαρτίου 2006 Δημοσ. 22 Μαρτίου 2006 guys na rotiso kati. exo mia antikimenostrafhs bash kai exo ftiaksh merika objects. Thelo mesa apo ena body na epistrefete ena select. me arithmo ksero na to kano ayto. opos px Create or replace type body test as member funtion test1 (variable number) return number is begin return round (variable - sysdate); end; end; / Tora gia na epistrefh ena olokliro select mipos ginete etsi? Create or replace type body test2 as member funtion test3 (variable2 number) return varchar2 is begin select * from akis_table where name='akis'; return akis_table; end; end; /
TAKE5 Δημοσ. 27 Μαρτίου 2006 Δημοσ. 27 Μαρτίου 2006 Δεν νομίζω ότι είναι σωστή καμμια απο τις 2 function που έχεις γραψει. Η πρώτη "αριθμός" (+-) "ημερομηνία" έχει ως αποτέλεσμα ημερομηνία άρα το return της function πρέπει να είναι date Ομοιως στην δευτερη to return της function πρεπει να είναι akis_table%rowtype και όχι varchar2 και βέβαια να υπάρχει και Into στο select. Τελος η variable2 δεν βλεπω γιατί υπάρχει
Exoskeletor Δημοσ. 27 Μαρτίου 2006 Μέλος Δημοσ. 27 Μαρτίου 2006 nai ayto me to into mou to bgazh kai h oracle, ti akribos diladi prepei na alakso sto select? nai thn variable2 xoris logo thn exo balei
TAKE5 Δημοσ. 27 Μαρτίου 2006 Δημοσ. 27 Μαρτίου 2006 Create or replace type body test2 as member function test3 return akis_table%rowtype is tmp_var akis_table%rowtype; begin select * into tmp_var from akis_table where name='akis'; return tmp_var; end; end; Κάπως έτσι δεν θα έχει errors. Το θέμα είναι ότι αντίστοιχη μεταβλητή όπως την tmp_var θα πρέπει να χρησιμοποιήσεις κάθε φορά που καλεις την function test3
Exoskeletor Δημοσ. 27 Μαρτίου 2006 Μέλος Δημοσ. 27 Μαρτίου 2006 ok eyxaristo, me boithas poly me ayto an kai to select prepei na ginei se nested table kai ekei sinanto problhmata alla tha do an mou bgazei kana error kai tha epaneltho
Exoskeletor Δημοσ. 30 Μαρτίου 2006 Μέλος Δημοσ. 30 Μαρτίου 2006 bro perno ayto to lathos omos otan pao na ftiakso to object mou SQL> create or replace type Compounds as object 2 (Compounds_ID numeric(5), 3 Compounds_specification varchar2(30), 4 Name varchar2(30), 5 Strength numeric(10), 6 7 member function Add_Distributor ( 8 new_Distr_id in numeric, 9 new_Distr_name in varchar2, 10 new_Distr_address in varchar2, 11 comp_id in numeric, 12 comp_spec in varchar2, 13 comp_name in varchar2, 14 comp_str in numeric) return Compounds_tbl%rowtype, 15 16 member procedure Find_Compound ( 17 Drug_ID in numeric, 18 Drug_name in varchar2, 19 Drug_form in varchar2, 20 Sec_Drug_ID in numeric, 21 Sec_Drug_name in varchar2, 22 Sec_Drug_form in varchar2)); 23 / Warning: Type created with compilation errors. SQL> show err Errors for TYPE COMPOUNDS: LINE/COL ERROR -------- ----------------------------------------------------------------- 0/0 PL/SQL: Compilation unit analysis terminated 14/29 PLS-00201: identifier 'COMPOUNDS_TBL' must be declared kai h function mou eine: Set serveroutput on; CREATE or REPLACE TYPE body Manufacturers AS member function find_all_comp (manu_id in numeric, manu_name in varchar2, manu_add in varchar2 ) return Compounds_tbl%rowtype IS tmp_var Compounds_tbl%rowtype; begin SELECT c.Compounds_object into tmp_var FROM Compounds_tbl c WHERE c.Manufacturer = Manufacturers(manu_id, manu_name, manu_add); return tmp_var; end; end; / To compounds_tbl ipotithete eine: CREATE TABLE Compounds_Tbl (Compounds_object Compounds, Distributor Distributors, manufacturer manufacturers); Entometaksi ego exo ftiaksh ayto edo pou den mou petaei lathi kai fenete sosto alla tha protimousa function: Set serveroutput on; CREATE or REPLACE TYPE body Manufacturers AS member procedure find_all_comp (manu_id in numeric, manu_name in varchar2, manu_add in varchar2 ) AS cursor c1 IS SELECT c.Compounds_object FROM Compounds_tbl c WHERE c.Manufacturer = Manufacturers(manu_id, manu_name, manu_add); C2 c1%ROWTYPE; begin open c1; loop FETCH c1 INTO c2; EXIT WHEN c1%NOTFOUND; dbms_output.put_line(c2.Compounds_object.Compounds_id); End loop; Close c1; End find_all_comp; end; /
TAKE5 Δημοσ. 31 Μαρτίου 2006 Δημοσ. 31 Μαρτίου 2006 Σου στελνω Pm αν μπορείς να διαβάσεις κάποια πραγματα γιατί αυτή την στιγμή δεν μπορώ να σε βοηθήσω. Το "λάθος" νομίζω είναι ότι ο πίνακας Compounds_Tbl είναι γονέας των types και παιδί ταυτόχρονα. Αυτό δεν ξέρω αν το υποστηρίζει η Oracle και με ποια δομή.
Προτεινόμενες αναρτήσεις
Αρχειοθετημένο
Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.