package and table functions
Hi I created a package like this.create or replace
PACKAGE Package_x is
TYPE collect_tablex IS TABLE OF THE ASAP.tablex%RowType;
/ * TODO type (types, exceptions, methods etc.) package declarations here * /.
function f_tablefunc (arg_1 in number)
Return collect_tablex;
END Package_x;
Select * from table (cast (Package_x.f_tablefunc (54115,54114) as Package_x.collect_tablex))
------------------------
I wrote the human body function that works well when I debug.
but when I used above, choose giving
ORA-00902: invalid data type
00902 00000 - "invalid data type".
* Cause:
* Action:
Error on line: column 15: 76
Why this statement does not apply to channeled functions of table with nested tables?
Because oracle internally generates the sql types: see for example Re: type as a column of database record ;)
Tags: Database
Similar Questions
-
Integrate the Table function in the package
Hey everybody,
I had a problem with my table function. I don't have it created in a package as a function table on the database. Now I have to integrate it in my package,
but it does not work. What I have to put the type and Assembly in the package_spec? I always get the error: "each cursor or subprogramm in the package_spec statement must have a corresponding definition in the package body.
But I already joined the funtion in the body. Maybe someone can help me? I would be very grateful!
It's my spec package: (sorry, I don't know how to insert the code in this forum, maybe you can tell me)
The search_type is declared, but so far not in the package:
----------------------------------------
create or replace package test is
TYPE search_set IS TABLE OF THE schema.search_type;
function search (.)
Return search_set;
end test;
----------------------------------------
create or replace package test body is
function search (.)
return search_set
pipelined is
..
search for late;
----------------------------------------
create or repplace type search_type as object
(..);
---------------------------------------
If I lump the search_type package specifications, it will not accecpt the 'object '.
It would be great if you can help me! I would also like to update my post I have someone tell me how to integrate the code correctly in this post.
Many thanks!
In your message the definition of function in the SPECIFICATION does not PIPELINED keyword, but your BODY plan has it.
-
Help with packages and functions that it
Hello, I need help with the package.
I have two tables of the employee base (id, firstname, lastname, etc..) T1 and T2.
What I need, it's a package and two features inside. First function reads the data from T1 and passes to the second function, where second function reads data from T2 and concatenates the data just read with data from function1 and data T1 + T2 function2 goes on the main program that displays this data.
So far, I have:
- get_T1_emp function seems to be quite beautiful. At least it works separatelycreate or replace type emp_type as object (id number, firstname varchar(20), lastname varchar(20), salary number(9,2)); create or replace type emp_type_table as table of emp_type; create or replace package my_package is emp_table emp_type_table:= emp_type_table(); -- *not sure if this line is correct* function get_T1_emp return emp_type_table; function get_T2_emp (T1_emp in emp_type_table) return emp_type_table; end my_package; -- *confusion begins* create or replace package body my_package as function get_T1_emp return emp_type_table as emp_table emp_type_table:= emp_type_table(); begin for i in (select * from T1) loop emp_table.extend; emp_table(emp_table.count):= (emp_type(i.id, i.firstname, i.lastname, i.salary)); end loop; return emp_table; end get_T1_emp;
So basically I don't know about my tax package.function get_T2_emp (T1_emp in emp_type_table) return emp_type_table emp_table emp_type_table:= emp_type_table(); begin for i in (select * from T2) loop T1_emp.extend; T1_emp(T1_emp.count):= (emp_type(i.id, i.firstname, i.lastname, i.salary)); end loop; return T1_emp; end get_T2_emp; end my_package; DECLARE v_Return emp_type_table; v_Return2 emp_type_table; BEGIN v_Return := get_T1_emp; v_Return2 := get_T2_emp(v_Return); for i in 1..2 loop DBMS_OUTPUT.PUT_LINE(v_Return2(i).id || ', ' || v_Return2(i).firstname || ', ' || v_Return2(i).lastname || ', ' || v_Return2(i).salary || 'EUR'); end loop; END;
Most important, I don't know how to write the get_T2_emp function. And also not very sure of my main function. Please can someone help my with my problem
Published by: dber November 6, 2011 21:22
Published by: dber November 6, 2011 23:38 addedHello
Here you go
SQL> DROP TABLE t1; Table dropped. SQL> DROP TABLE t2; Table dropped. SQL> CREATE TABLE t1 (id NUMBER, 2 firstname VARCHAR2(100), 3 lastname VARCHAR2(100) ); Table created. SQL> CREATE TABLE t2 (id NUMBER, 2 firstname VARCHAR2(100), 3 lastname VARCHAR2(100) ); Table created. SQL> INSERT INTO t1 (SELECT 1,'SURI','DAMA' FROM dual 2 UNION ALL 3 SELECT 2,'SRINU','DAMA' FROM dual); 2 rows created. SQL> INSERT INTO t2 (SELECT 3,'ABC','XYZ' FROM dual 2 UNION ALL 3 SELECT 4,'DEF','PQR' FROM dual); 2 rows created.
Package code
SQL> CREATE OR REPLACE PACKAGE test_array_pkg 2 AS 3 TYPE test_array1 IS TABLE OF t1%rowtype INDEX BY PLS_INTEGER; 4 TYPE test_array2 IS TABLE OF t2%rowtype INDEX BY PLS_INTEGER; 5 6 FUNCTION get_t1 RETURN test_array1; 7 FUNCTION get_t2(p_t1 IN test_array1) 8 RETURN test_array2; 9 10 END test_array_pkg; 11 / Package created.
Package body
SQL> CREATE OR REPLACE PACKAGE BODY test_array_pkg 2 AS 3 t1_array1 test_array1; 4 t2_array2 test_array2; 5 6 FUNCTION get_t1 7 RETURN test_array1 8 IS 9 10 n NUMBER :=0; 11 12 BEGIN 13 14 FOR i IN (SELECT * FROM t1) 15 LOOP 16 17 t1_array1(n).id:= i.id; 18 t1_array1(n).firstname := i.firstname; 19 t1_array1(n).lastname := i.lastname; 20 21 n:=n+1; 22 23 END LOOP; 24 25 RETURN t1_array1; 26 27 END get_t1; 28 29 FUNCTION get_t2(p_t1 IN test_array1) 30 RETURN test_array2 31 IS 32 33 n NUMBER:=0; 34 35 BEGIN 36 37 FOR i IN p_t1.FIRST..p_t1.LAST 38 LOOP 39 40 t2_array2(n).id:=p_t1(i).id; 41 t2_array2(n).firstname:= p_t1(i).firstname; 42 t2_array2(n).lastname := p_t1(i).lastname; 43 44 n:=n+1; 45 46 END LOOP; 47 48 FOR i IN (SELECT * FROM t2) 49 LOOP 50 51 t2_array2(n).id:=i.id; 52 t2_array2(n).firstname:= i.firstname; 53 t2_array2(n).lastname := i.lastname; 54 55 n:=n+1; 56 57 END LOOP; 58 59 RETURN t2_array2; 60 61 END get_t2; 62 63 64 END test_array_pkg; 65 / Package body created.
Main script
SQL> declare 2 3 t1_result test_array_pkg.test_array1; 4 t2_result test_array_pkg.test_array2; 5 6 begin 7 8 t1_result:= test_array_pkg.get_t1; 9 t2_result:= test_array_pkg.get_t2(t1_result); 10 11 FOR i IN t2_result.first..t2_result.last 12 LOOP 13 14 dbms_output.put_line(t2_result(i).id||' '||t2_result(i).firstname||' '||t2_result(i).lastname); 15 16 END LOOP; 17 18 end; 19 / 1 SURI DAMA 2 SRINU DAMA 3 ABC XYZ 4 DEF PQR PL/SQL procedure successfully completed.
-
What is the difference between the function declared in the package and the CIP
What is the difference between the definition of a function in the package and package body?
Published by: user10641405 on November 19, 2009 13:29If you describe a package, you will see only the functions declared in the spec.
If you declare only in the body but are not available to other packages (they are private to the package, non-public) -
How to get Nested table function
Hi friends,
In a package, I created a nested table type name Varchar2 EmployeeCodeList.
Then, I created a function whose return type is EmployeeCodeList. But I don't get how to get the values of this function?
TYPE EmployeeCodeList IS TABLE OF THE VARCHAR2 (30);
FUNCTION GenerateRandomEcF (Ec_length NUMBER, NumberOfEmp NUMBER)
< < the function code > >
RETURN v_RandomEmpCodes; END GenerateRandomEcF;
PROCEDURE GenerateEmpFile (NumberOfEmp NUMBER, Start_SN NUMBER, EmpValue NUMBER, VARCHAR2, VARCHAR2, Ec_length NUMBER EmpGroup HireDate) IS
v_Filename VARCHAR2 (40);
v_EmployeeCodes EmployeeCodeList;
v_EmpBatchF UTL_FILE. TYPE_DE_FICHIER;
BEGIN
v_Filename: = 'EMPLOYEE_BATCH_ ' | TO_CHAR (SYSTIMESTAMP, 'YYYYMMDD_HHMISS'): '. DAT';
v_EmployeeCodes: = EmployeeCodeList (NumberOfEmp);
v_EmployeeCodes: = SELECT * FROM TABLE (GenerateRandomAcF (Ac_length, NumberOfVoucher));
v_EmpBatchF: = UTL_FILE. FOPEN ('EXT_VOUCHER_DIR', v_Filename, 'W');
IF UTL_FILE.IS_OPEN (v_EmpBatchF) THEN
FOR i IN 1.NumberOfVoucher LOOP
UTL_FILE. Put_line (v_EmpBatchF, v_EmployeeCodes (i) |) ',' || Start_SN + (i-1). «, » || EmpValue | «, » || HireDate. «, » || EmpGroup);
END LOOP;
END IF;
END GenerateEmpFile;
How the line highlighted code above must be written so that I can get value of function in a variable of the same type of nested table.
If you use the second approach, I mean
56 v_EmployeeCodes: = GenerateRandomAcF (Ac_length, NumberOfEmployee);
then the collection must be initialized using the constructor method. Change line 33.48 as number below
33 v_RandomEmployeeCodes EmployeeCodeList: = EmployeeCodeList();
48 v_EmployeeCodes EmployeeCodeList: = EmployeeCodeList();
This is because when you use BULK COLLECT, Oracle automatically populates the collection without initialization. But if you do not COLLECT in BULK, then the collection must be initialized before filling / extending. Otherwise, you will get error of REFERENCE to the COLLECTION that is not INITIALIZED. So this should be the code, you should use. When you do not select... INTO, you might well declare the function is private and it is not necessary to declare in the package specification.
SQL > CREATE OR REPLACE PACKAGE BODY GenerateEmployeePackage AS
2 PROCEDURE Get_AC_Range (Ac_length NUMBER, Range_Start SERIES, certain Range_End NUMBER)
3 EAST
4 BEGIN
5 If Ac_length = 8 THEN
6 Range_Start: = 10000000;
7 Range_End: = 99999999;
8 Ac_length ELSIF = 9 THEN
9 Range_Start: = 100000000;
10 Range_End: = 999999999;
11 Ac_length ELSIF = 10 THEN
12 Range_Start: = 1000000000;
13 Range_End: = 9999999999;
14 Ac_length ELSIF = 11 THEN
15 Range_Start: = 10000000000;
16 Range_End: = 99999999999;
17 ELSIF Ac_length = 12 THEN
18 Range_Start: = 100000000000;
19 Range_End: = 999999999999;
20 Ac_length ELSIF = 13 THEN
21 Range_Start: = 1000000000000;
22 Range_End: = 9999999999999;
23 Ac_length ELSIF = 14 THEN
24 Range_Start: = 10000000000000;
25 Range_End: = 99999999999999;
26 END IF;
27 END Get_AC_Range;
28
GenerateRandomAcF FUNCTION 29 (Ac_length NUMBER, NumberOfEmployee NUMBER)
30 BACK IS EmployeeCodeList
31 NUMBER Range_Start;
32 Range_End NUMBER;
33 v_RandomEmployeeCodes EmployeeCodeList: = EmployeeCodeList ();
BEGIN 34
35 Get_AC_Range (Ac_length, Range_Start, Range_End);
36 v_RandomEmployeeCodes.extend (NumberOfEmployee);
37
38 FOR I IN 1.NumberOfEmployee LOOP
39 v_RandomEmployeeCodes (i): = TRUNC (DBMS_RANDOM.value (down-online Range_Start, high-online Range_End));
40 END LOOP;
41
42 v_RandomEmployeeCodes RETURN;
43
END 44 GenerateRandomAcF;
45
GenerateEmployeeFile PROCEDURE 46 (NumberOfEmployee NUMBER of Start_SN NUMBER, EmployeeValue NUMBER, displayed EmployeeGroup VARCHAR2, VARCHAR2, Ac_length NUMBER) IS
47 v_Filename VARCHAR2 (40);
48 v_EmployeeCodes EmployeeCodeList: = EmployeeCodeList ();
49 v_EmployeeBatchF UTL_FILE. TYPE_DE_FICHIER;
BEGIN 50
51 v_Filename: = 'Employee_BATCH_ ' | TO_CHAR (SYSTIMESTAMP, 'YYYYMMDD_HHMISS'): '. DAT';
52 v_EmployeeCodes: = EmployeeCodeList();
53
54 get nested table function
55 - SELECT * COLLECT in BULK IN TABLE v_EmployeeCodes (GenerateRandomAcF (Ac_length, NumberOfEmployee));
56 v_EmployeeCodes: = GenerateRandomAcF (Ac_length, NumberOfEmployee);
57 v_EmployeeBatchF: = UTL_FILE. FOPEN ('EXT_Employee_DIR', v_Filename, 'W');
58
59 if UTL_FILE.IS_OPEN (v_EmployeeBatchF) THEN
60. FOR i IN v_EmployeeCodes.FIRST... v_EmployeeCodes.Last LOOP
UTL_FILE 61. Put_line (v_EmployeeBatchF, v_EmployeeCodes (i) |) ',' || (Start_SN + (i-1)). «, » || EmployeeValue | «, » || Posted | «, » || EmployeeGroup);
LOOP END 62;
63 END IF;
64
END 65 GenerateEmployeeFile;
66
END 67 GenerateEmployeePackage;
68.
-
Error creating features in the packages - unknown command FUNCTION
Hello
I usually identify with the diagram of the system via the SQL command line and run my sql files. I have the database below and the test package. But I get the error:
Order unknown start "FUNCTION p...» ' - the rest of the ignored line
This is the database I load previously:
DROP TABLE Judete CASCADE CONSTRAINTS;
CREATE TABLE Judete
(
JD CHAR (2) PRIMARY KEY.
NumeJud char(10) NOT NULL UNIQUE,
Regiune CHAR (15) by default "Moldova" CHECK (Regiune IN ('Moldova', 'Transilvania', 'Banat'))
);
DROP TABLE Localitati CASCADE CONSTRAINTS;
CREATE TABLE Localitati
(CodPostal NUMBER (8) PRIMARY KEY,)
NumeLoc NON NULL, char (15)
Judet (2) tank,
FOREIGN KEY (Judet) made REFERENCE Judete (JD)
);
DROP TABLE Persoane CASCADE CONSTRAINTS;
CREATE TABLE Persoane
(NOC NUMBER PRIMARY KEY (15),)
NumePers NON NULL char (20)
PrenPers NON NULL char (20)
CodPostal NUMBER (10),
Such NUMBER (12) NOT NULL,
FOREIGN KEY (CodPostal) made REFERENCE to Localitati (CodPostal)
);
DROP TABLE Produse CASCADE CONSTRAINTS;
CREATE TABLE Produse
(CodProdus NUMBER (10) PRIMARY KEY,)
NumeProdus NON NULL, char (15)
Loan NUMBER (8) NOT NULL
);
DROP TABLE Vanzari CASCADE CONSTRAINTS;
CREATE THE Vanzari TABLE
(CodV NUMBER (8) PRIMARY KEY,
CodProdus NUMBER (10),
PersCNP Number (15),
DataV DATE NOT NULL,
NrProduse NUMBER (8) NOT NULL,
FOREIGN KEY (PersCNP) made REFERENCE Persoane (NOC),
FOREIGN KEY (CodProdus) makes REFERENCE Produse (CodProdus)
);
INSERT INTO Judete VALUES ('IS', 'Iasi', 'Moldova');
INSERT INTO Judete VALUES ("CJ", "Cluj", "Transilvania");
INSERT INTO Judete VALUES ("TM", "Timis', 'Banat');
INSERT INTO Localitati VALUES (200, "Vaslui", "IS");
INSERT INTO Localitati VALUES (201, 'Targu Frumos', 'IS');
INSERT INTO Localitati VALUES (202, 'Criseni', 'CJ');
INSERT INTO Localitati VALUES (203, "Dealu Botii", "CJ");
INSERT INTO Localitati VALUES (204, "Beba Veche", "TM");
INSERT INTO Localitati VALUES (205, "Blajova", "TM");
INSERT INTO Persoane VALUES (0001, "Ionescu", "Ion", 201, 0332504312);
INSERT INTO Persoane VALUES (0002, "Vasilescu", "Vasile", 203, 0332304612);
INSERT INTO Persoane VALUES (0003, "Ionescu", "Ion", 204, 0322564322);
INSERT INTO Produse VALUES (1, "Limp", 50);
INSERT INTO Produse VALUES (2, 'First', 80);
INSERT INTO Produse VALUES (3, 'Corn', 35);
INSERT INTO Vanzari VALUES (100, 1, 0001, to_date('2011-03-07','yyyy-mm-dd'), 5);
INSERT INTO Vanzari VALUES (101, 3, 0001, to_date('2011-02-07','yyyy-mm-dd'), 2);
INSERT INTO Vanzari VALUES (2, 102, 0002, to_date('2011-01-08','yyyy-mm-dd'), 7);
INSERT INTO Vanzari VALUES (1, 103, 0002, to_date('2011-03-08','yyyy-mm-dd'), 15);
INSERT INTO Vanzari VALUES (3, 104, 0003, to_date('2011-02-19','yyyy-mm-dd'), 9);
INSERT INTO Vanzari VALUES (105, 1, 0003, to_date('2011-03-29','yyyy-mm-dd'), 1);
the package is:
CREATE or REPLACE PACKAGE pachet_lab2
IS
FUNCTION prod_bine_vandut RETURN NUMBER;
END pachet_lab2;
/
CREATE OR REPLACE pachet_lab2 BODIES
FUNCTION prod_bine_vandut RETURNS the NUMBER IS
DECLARE
v_sale NUMBER (6);
V_nume char (15);
v_cod NUMBER (10);
BEGIN
SELECT max(p.pret * v.NrProduse) IN the v_sale DE Produse p, Vanzari v
WHERE the p.CodProdus = v.CodProdus;
SELECT p.numeProdus INTO v_nume Produse p, Vanzari v
WHERE p.CodProdus = v.CodProdus AND v_sale = p.pret * v.NrProduse;
SELECT p.codProdus INTO v_cod Produse p, Vanzari v
WHERE p.CodProdus = v.CodProdus AND v_sale = p.pret * v.NrProduse;
Return v_cod;
END prod_bine_vandut;
END pachet_lab2;
/
I need to change the schema that I use? How can I do?
Thank you
PaulCREATE OR REPLACE PACKAGE BODY pachet_lab2 IS --you misse keyword PACKAGE FUNCTION prod_bine_vandut RETURN NUMBER IS -- DECLARE is not allowed here v_sale NUMBER(6); -- ...
Good bye
DPT -
Hello
I have a database of Oracle 11 g Release 11.1.0.6.0 - 64 bit Production With the Real Application Clusters option.
I feel something strange with an XMLType column.
I have a table configurator.t_vehicle_configuration (id_vehicle x_configuration NUMBER, XMLType).
x_configuration is unstructured.
I created an index on the field of xml in this way:
CREATE INDEX idx_vehicle_configuration ON configurator.t_vehicle_configuration (x_configuration) INDEXTYPE IS XDB. XMLIndex;
Then I have a package implementing a function that count nodes in the xml field and its return values
This does not (return 0 instead of 1):
This mode of operation (return 1):SELECT count(*) INTO count_ FROM configurator.v_vehicle_configuration vc, table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen'))) p WHERE vc.id_vehicle = in_id_vehicle; RETURN count_;
As this mode of operation:str_ := '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen'; SELECT count(*) INTO count_ FROM configurator.v_vehicle_configuration vc, table(XMLSEQUENCE(EXTRACT(vc.x_configuration,str_))) p WHERE vc.id_vehicle = in_id_vehicle; RETURN count_;
And also this way it works:SELECT /*+ NO_XMLINDEX_REWRITE */ count(*) INTO count_ FROM configurator.v_vehicle_configuration vc, table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen'))) p WHERE vc.id_vehicle = in_id_vehicle; RETURN count_;
I sailed a bit on the internet but I have found no help for my problem...SELECT count(*) INTO count_ FROM configurator.v_vehicle_configuration vc, table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="228"]/user[@id="49"]/alarmwhen'))) p WHERE vc.id_vehicle = in_id_vehicle; RETURN count_;
I guess that's something concerning the substitution on the fly of the variables, which does not work with an index.
Do you have any suggestions?
Is there a way that will prevent the rewriting of all the functions?
Thanks in advanceFirst
On 11.1.0.6.0 Please do not use table (xmlsequence (extract ())) Please use the SQL/XML standard XMLTAble operator...
SELECT COUNT(*) INTO count_ FROM configurator.v_vehicle_configuration vc, XMLTABLE ( '$XML/vehicleconf/GeoFence/spaceTarget[@id=$ID_SPACE_TARGET]/user[@id=$ID_USER]/alarmwhen' passing vc.x_configuration as "XML", in_id_space_target as "ID_SPACE_TARGET", in_id_user as "ID_USER" ) WHERE vc.id_vehicle = in_id_vehicle; RETURN count_;
2. never generate XPATH strings dynamically (Note XMLTABLE simply will not allow it). It is almost impossible to optimize since in the case escalated, the query may be a function of the processing line, and it leaves the vulnerable application WHO the problems of injection. Earlier versions of XML DB supported the use of string concatenation technique to provide the value of predicate as a method of implementation of the bind variable, but from what I remember, this is only implemented and tested for storage relatiion object. Even when workng with storage relational object this technique should not be used in the development of new code n a 10.2.x post database. As far as I know this was not implemented for binary XML / XML INdex since the implementations of XMLQUERY, XMLTable and XMLEXists provided a much more robust implementation and standardized to link the underlying values at query runtime
If you do not know the XPATH expression until run time please build the complete SQL statement dynamically and run it via EXECUTE IMMEDIATE or DBMS_SQL, then pay attention to injection vunerabilities in your application.
The fact that you get different results seems to be the result of the previous method of binding of predicates works do not correctly with the XML Index. If the solution I gave above does not work, please fill out a bug and that we can continue the investigation
Published by: mdrake on February 25, 2011 17:32
-
I have a package which splits a string to a separate expression in table:
To test if it works, I use:CREATE OR REPLACE PACKAGE STRING_FNC IS TYPE t_array IS TABLE OF VARCHAR2(50) INDEX BY BINARY_INTEGER; FUNCTION SPLIT (p_in_string VARCHAR2, p_delim VARCHAR2) RETURN t_array; END; CREATE OR REPLACE PACKAGE BODY STRING_FNC IS FUNCTION SPLIT (p_in_string VARCHAR2, p_delim VARCHAR2) RETURN t_array IS i number :=0; pos number :=0; lv_str varchar2(50) := p_in_string; strings t_array; BEGIN -- determine first chuck of string pos := instr(lv_str,p_delim,1,1); -- while there are chunks left, loop WHILE ( pos != 0) LOOP -- increment counter i := i + 1; -- create array element for chuck of string strings(i) := substr(lv_str,1,pos); -- remove chunk from string lv_str := substr(lv_str,pos+1,length(lv_str)); -- determine next chunk pos := instr(lv_str,p_delim,1,1); -- no last chunk, add to array IF pos = 0 THEN strings(i+1) := lv_str; END IF; END LOOP; -- return array RETURN strings; END SPLIT; END;
Is it possible to use this package or split function in SELECT such as:DECLARE str string_fnc.t_array; BEGIN str := string_fnc.split('word1 word2 word3'); FOR i IN 1..str.count LOOP DBMS_OUTPUT.PUT_LINE(str(i)); END LOOP; END;
SELECT title
FROM t1
WHERE CONTAINS (title, HERE I have MIS FUNCTION('word1 word2 mot3")) > 0?;
I mean, for example, if I have the table with 4 rows with values word1, word2, mot3 and mot4 and I run this query without function, I get NO LINES FOUND, but you search for word1, word2, and mot3.SCOTT@orcl_11gR2> CREATE TABLE t1 2 (title VARCHAR2 (60)) 3 / Table created. SCOTT@orcl_11gR2> INSERT ALL 2 INTO t1 VALUES ('test') 3 INTO t1 VALUES ('tests') 4 INTO t1 VALUES ('tested') 5 INTO t1 VALUES ('testing') 6 INTO t1 VALUES ('plan') 7 INTO t1 VALUES ('plans') 8 INTO t1 VALUES ('planned') 9 INTO t1 VALUES ('planning') 10 INTO t1 VALUES ('game') 11 INTO t1 VALUES ('games') 12 INTO t1 VALUES ('other') 13 SELECT * FROM DUAL 14 / 11 rows created. SCOTT@orcl_11gR2> CREATE INDEX t1_title_idx 2 ON t1 (title) 3 INDEXTYPE IS CTXSYS.CONTEXT 4 / Index created. SCOTT@orcl_11gR2> VARIABLE string VARCHAR2 (4000) SCOTT@orcl_11gR2> EXEC :string := 'test plan game' PL/SQL procedure successfully completed. SCOTT@orcl_11gR2> SELECT title 2 FROM t1 3 WHERE CONTAINS (title, '$' || REPLACE (:string, ' ', ' OR $')) > 0 4 / TITLE ------------------------------------------------------------ test tests tested testing plan plans planned planning game games 10 rows selected. SCOTT@orcl_11gR2>
-
App packaging and Code-signing (Flash Builder Burrito)
Hi guys,.
I would like to know if the function "export version Release" (the tab Flash Builder project in the top menu) does not work correctly or if I should use the command line for the packaging. I see that my .bar includes the META-INF / "MANIFEST. MF' it's supposed to get generated only after the signature of the app.
Thank you
Hi daniel,.
Yes, you should always use the tools of command line to package and sign your applications. There is a bug in the IDE that prevents it to properly sign the app here is a thread that can help you with the signature of the command line:
Good luck!
-
How to know the name (package, procedures or functions) for current sessions
Hi all
I am DBA and I want to find a way to get the object name regardless (packages, procedures or functions) for the current statement running in the current session.
To specify when I open the browser session of Toad, I can see the active sessions and the current statement for each session, but without the name of the object.Is it possible to know this point.Thanks in advanceSelect *.
from dba_objects
When object_id in (select nvl (t.PLSQL_ENTRY_OBJECT_ID-1)
v $ session t
where sid = 452)
-----
Ramin Hashimzade
-
I try to use the table double tube function. However, I need help to understand how... I understand, the pipeline table functions do not wait for the function ends and begins to return the data as soon as it gets. The calling program can continue the treatment rather than wait. Does this program calling both functions work in parallel table?
The calling function must still wait for all of the lines to be processed it just means that it can start to view until all rows are returned. It will not automatically put the function as a kind of stand-alone function that runs in the background lines back.
Example:
You may need to return 100,000 rows
A pipeline function will return 1-5 000 from 5 000 are returned.
If you are returning a collection but don't not the processing pipeline, it must wait until all the 100,000 lines to collect and send everything at once.
A useful case of this pagination, or you want a user to see the first rows quickly since 99% of the time they will not be the page of the second series.
-
nested to perform DML and wait function call commit
Hello world
I would like to make a few DML - one insert statement, to be precise - in function and have the function and then return the number keys on the newly added row. I call this function from a different context and woud then be able to use the newly added data to do something.
Specifically, what I do is the following: I have a graph composed of triplets source, destination and distance in a picture. A user should now be able to
1.) add a node "A" to the curve.
2.) add a node 'B' to the chart
(3.) to get the shortest path from A to B in the graphs.
I have an internal function
adding new nodes to the chart, links, calculates distances etc. and returns a handle to the newly added node. I call this function twice function, externalfunction INSERT_NEW_NODE(node_in in sdo_geometry, graph_in in integer) return integer is pragma autonomous_transaction; cursor node_cur is select source, source_geom from graph ; cursor edge_cur is select source, destination, distance, edge_geom from graph where sdo_geom.relate(edge_geom, 'anyinteract', node_in, .005) = 'TRUE'; begin -- check if identical with any existing node for node_rec in node_cur loop if sdo_geom.relate(node_rec.source_geom, 'EQUAL', node_in, .005) = 'EQUAL' then return node_rec.source; end if; end loop; -- get edges for edge_rec in edge_cur loop -- new_node-->edge.destination and vice versa insert into graph ( ID, GRAPH, SOURCE, DESTINATION, DISTANCE, SOURCE_GEOM, DESTINATION_GEOM, EDGE_GEOM ) values ( graph_id_seq.nextval, --id graph_in, --graph morton(node_in.sdo_point.x, node_in.sdo_point.y), -- source morton key edge_rec.source, -- destination morton key sdo_geom.sdo_distance(edge_rec.source_geom_marl2000, node_in, .005, 'unit=M'), -- distance node_in, -- source geom edge_rec.source_geom, -- dest geom split_line(edge_rec.edge_geom_marl2000, node_in).segment1 -- edge geom ); commit; --new_node-->edge.source and vice versa insert into gl_graph ( ID, GRAPH, SOURCE, DESTINATION, DISTANCE, SOURCE_GEOM, DESTINATION_GEOM, EDGE_GEOM ) values ( graph_id_seq.nextval, --id graph_in, --graph edge_rec.source, -- source morton key morton(node_in.sdo_point.x, node_in.sdo_point.y), -- destination morton key sdo_geom.sdo_distance(edge_rec.source_geom, node_in, .005, 'unit=M'), -- distance edge_rec.source_geom, -- source geom node_in, -- dest geom split_line(edge_rec.edge_geom, node_in).segment2 -- edge geom ); commit; end loop ; return(morton(node_in.sdo_point.x, node_in.sdo_point.y)); end insert_new_node;
; and I think thatI have to use autonomous transaction in the internal function, so that the external function can see any changes made by the inside one. However, it doesn't work, when I call twice the function internal (i.e. remove the comment panels in front of the last two lines of code just before the return statement in the outer function.)function get_path (line_in in sdo_geometry, graph_in in integer) return sdo_geometry is source number; destination number; source_geom mdsys.sdo_geometry; destination_geom mdsys.sdo_geometry; begin source := insert_new_node(get_firstvertex(line_in), graph_in); destination := insert_new_node(get_lastvertex(line_in), graph_in); -- source := insert_new_node(get_firstvertex(line_in), graph_in); -- destination := insert_new_node(get_lastvertex(line_in), graph_in); return(get_path_geom(source, destination)); --returns a geometry which is the shortest path between source and destination end get_path;
So here are my questions: 1) why should I call the function twice to see the complete transaction? (and 2.) How can I avoid this? Is it possible to wait for the execution of the return statement in the internal function that the insert is committed and can be seen by the external function?
See you soon!OK, here's the solution: the external function
get_path()
calls a functionget_path_geom(source, destination)
, who himself called something liketable(dijkstra(source, destination))
, (omitted by me because only carefully tested and ok, my bad!) which makes the job of finding the shortest path and returns an array in pipeline. It turns out that this feature for some reason is not the scope of the external function and therefore does not see the transaction committed themselves on the graphics table. After you change thedijkstra()
-function to return a list instead of a table, all works all of a sudden.If this question has been answered; I would still like to know why the table function does not have the same scope as the rest of the transaction.
Edit: removed misleading blame on application external and inserted a correct solution.
-
New to Java:
I'm trying to learn more about the packages and JAR libraries using jdk1.7.0_17 on Debian 6.0.7 (Squeeze). I created a tree of directories and files to work with:
I use to make my orders are repeatable. the Makefile is 'quick and dirty '. Emphasis is placed on the keywords 'package' and 'import' of Java and command line tools and their options (javac, jar and java).2013-05-11 20:22:07 dpchrist@desktop ~/sandbox/java/jar $ tree . . |-- Makefile |-- bin | |-- using_class_files | | `-- MyApp.class | `-- using_jar_file |-- ext | `-- com | `-- example | `-- myapp | `-- util.jar |-- obj | `-- com | `-- example | `-- myapp | `-- util | `-- Speak.class `-- src `-- com `-- example `-- myapp |-- MyApp.java `-- util `-- Speak.java 17 directories, 6 files 2013-05-11 20:22:39 dpchrist@desktop ~/sandbox/java/jar $ cat src/com/example/myapp/util/Speak.java package com.example.myapp.util; public class Speak { public static void hello(String arg) { System.out.println("hello, " + arg); } } 2013-05-11 20:23:27 dpchrist@desktop ~/sandbox/java/jar $ cat src/com/example/myapp/MyApp.java import com.example.myapp.util.Speak; public class MyApp { public static void main(String [] args) { Speak s = new Speak(); s.hello("world!"); } } 2013-05-11 20:23:54 dpchrist@desktop ~/sandbox/java/jar $ cat Makefile .PHONY: all all: clean using_class_files using_jar_file .PHONY: using_class_files using_class_files: # create utility bytecode file (Speak.class) mkdir -p obj/com/example/myapp/util javac -d obj src/com/example/myapp/util/Speak.java # compile application file against Speak.class mkdir -p bin/using_class_files javac -d bin/using_class_files -cp obj src/com/example/myapp/MyApp.java # run application java -cp obj:bin/using_class_files MyApp .PHONY: using_jar_file using_jar_file: # put Speak.class into a Java archive (util.jar) mkdir -p ext/com/example/myapp jar cvf ext/com/example/myapp/util.jar -C obj/com/example/myapp/util Speak.class # print util.jar table of contents jar tf ext/com/example/myapp/util.jar # compile application against util.jar mkdir -p bin/using_jar_file javac -d bin/using_jar_file -extdirs ext src/com/example/myapp/MyApp.java .PHONY: clean clean: rm -rf bin ext obj
Compile the utility class (Speak.java), compile the application (MyApp.java) against the tree of bytecode (. / obj) and running the application against the tree quote bytecode:
Put the bytecode of the utility (Speak.class) file in a JAR file (util.jar) works, but compile the application against the tree in the POT (. / ext) fails:2013-05-11 20:23:58 dpchrist@desktop ~/sandbox/java/jar $ make clean rm -rf bin ext obj 2013-05-11 20:24:01 dpchrist@desktop ~/sandbox/java/jar $ make using_class_files # create utility bytecode file (Speak.class) mkdir -p obj/com/example/myapp/util javac -d obj src/com/example/myapp/util/Speak.java # compile application file against Speak.class mkdir -p bin/using_class_files javac -d bin/using_class_files -cp obj src/com/example/myapp/MyApp.java # run application java -cp obj:bin/using_class_files MyApp hello, world!
Any suggestions?2013-05-11 20:24:08 dpchrist@desktop ~/sandbox/java/jar $ make using_jar_file # put Speak.class into a Java archive (util.jar) mkdir -p ext/com/example/myapp jar cvf ext/com/example/myapp/util.jar -C obj/com/example/myapp/util Speak.class added manifest adding: Speak.class(in = 572) (out= 364)(deflated 36%) # print util.jar table of contents jar tf ext/com/example/myapp/util.jar META-INF/ META-INF/MANIFEST.MF Speak.class # compile application against util.jar mkdir -p bin/using_jar_file javac -d bin/using_jar_file -extdirs ext src/com/example/myapp/MyApp.java src/com/example/myapp/MyApp.java:1: error: package com.example.myapp.util does not exist import com.example.myapp.util.Speak; ^ src/com/example/myapp/MyApp.java:4: error: cannot find symbol Speak s = new Speak(); ^ symbol: class Speak location: class MyApp src/com/example/myapp/MyApp.java:4: error: cannot find symbol Speak s = new Speak(); ^ symbol: class Speak location: class MyApp 3 errors make: *** [using_jar_file] Error 1
TIA,
DavidNormally, you would run javac from the 'src' directory, so:
javac [options] com/mycompany/whatever/package/MyClass.java
It will then automatically find or compile all the other classes that are correctly under 'src' under their packages.
-
Find out all the package and procedure names linked using an array of specifc
I have 25 packages
(DBA_SOURCE is not objective).
Each package contains 30-35 procedures
I need to find all packages and procedures
Each procedure handles the Tables from 5 to 20 according to the need of business rule.
I need the entire package and related procedure names where a specific Table name isQuick response appreciated.
Thank you and best regards,It is difficult to help you if you do not want to read what is suggested. The utldtree.sql script will do what you want. Read the first part of the script and it will tell you what it does and how it works:
>
REM $Header: utldtree.sql, v 1.2 1992/10/26 16:24:44 $ RKOOI Stab
REM
REM Copyright (c) 1991 by Oracle Corporation
REM NAME
REM deptree.sql - Show objects recursively depends on given object
REM DESCRIPTION
REM This procedure, temp and table will allow you to see all
Objects REM (recursively) depends on the given object.
REM Note: you will see the objects for which you have permission.
Examples of rem:
REM run deptree_fill ('procedure', 'scott', 'billing');
REM select * from deptree by seq #;
REM
REM Execute deptree_fill ('table', 'scott', 'emp');
REM select * from deptree by seq #;
REM
REM run deptree_fill ("package body ', 'scott', 'accts_payable'");
REM select * from deptree by seq #;
REM
Way prettier REM to display this information only
REM select * from deptree by seq #;
REM is
REM select * from ideptree;
REM This shows the relationship of dependence via indentation. View
REM that no order by clause is necessary with ideptree.
REM RETURNS>
Did you notice the part that says? :
>
REM Execute deptree_fill ('table', 'scott', 'emp');
REM select * from deptree by seq #;>
If you supply a table name, it will display the objects that depend on this table just as you said you want.
Please try this script. -
ActionScript 3.0 drag and drop function
Hi, im trying to implement a drag and drop function to an array of movieclips on the stage using actionscript, but the same error keeps appearing: -.
Error
TypeError: Error #1010: a term is undefined and has no properties.
at draft1_fla::MainTimeline/down()
TypeError: Error #1010: a term is undefined and has no properties.
at draft1_fla::MainTimeline/release2drop()
Worked on this for a couple of hours and just can't get my head around it. Why this error keep appearing, what should I do to each object in the table to simply drag-and - drop!
Code: -.
import flash.events.MouseEvent;
var cereal1_Array:Array = [cereal1_1, cereal1_2, cereal1_3, cereal1_4, cereal1_5, cereal1_6, cereal1_7, cereal1_8, cereal1_ 9];
for (var i: Number = 0; i < cereal1_Array.length; i ++)
{
cereal1_Array [i] .addEventListener (MouseEvent.MOUSE_DOWN, down); Listen the Mousedown event, waiting to be executed
cereal1_Array [i] .addEventListener (MouseEvent.MOUSE_UP, release2drop);
}
/ * function to the bottom (evt:MouseEvent): void
{
cereal1_Array [i] .startDrag ();
}function release2drop(event:MouseEvent):void
{
cereal1_Array [i] .stopDrag ();If (cereal1_Array [i] .hitTestObject (back) == true)
{
trace ("fell into the basket")
} ElseIf (cereal1_Array [i] .hitTestObject (back) == false)
{
trace ("not in basket");
}
}Instead of "cereal1_Array [i] .startDrag (); you want to refer to the current object as "evt.target.startDrag ()";
Also use this same method to the second function:
function release2drop(event:MouseEvent):void
{var thisItem:Object = event.target;
stopDrag();If (thisItem.hitTestObject (back) == true)
{
trace ("fell into the basket")
} ElseIf (thisItem.hitTestObject (back) == false)
{
trace ("not in basket");
}
}You need not have stopDrag() attached to a particular object. StopDrag() stop all current drag.
Maybe you are looking for
-
Where can I find more iPhone 7 wallpapers?
The iOS10 comes with 15 fixed and 7 wallpapers more dynamic. Where can I see more outside my Camera Roll and my family photos?
-
My two cameras work fine in Live View mode, but not in normal viewfinder mode. And customs settings work fine. The shutter is damaged?
-
Problems when scanning double-sided printer Officejet 8600 Pro Plus
Hello everyone I recently bought a printer HP Officejet 8600 Pro Plus (CM750A n911g) I am facing difficulties when more than one original double face scanning by ADF. A single page works fine, but with several pages it works in about 10% of cases. Th
-
Does anyone know how to set the automatic answer of my blackberry by programming feature?
I have a BlackBerry Pearl and I can put it on auto answer when the phone out of the case through the menu options, but I was wondering if you can do this via code. I am writing an application that I want to activate the automatic response feature an
-
drive hard dv1375EA (Pavilion DV1000 series): IDE or SATA?
Hello Could anyone who has accurate knowledge let me know DV1375EA has a drive hard IDE or SATA, so I need to get a replacement (not not jumped the laptop cover again, so to speak). I think it's IDE, but I assure you. Thank you!