How to operate my function from PL/SQL?
I have 4 table1st is EMPLOYEE (E #, ENAME), the primary key is E #.
2nd is DRIVER(E#,L#), the primary key is E # ID EMPLOYEE
3. is TRIP(T#,L#), the primary key is T #, foreign key L # driver
4th is the primary key TRIPPT(T#,PT#) T # travel
I create a function that finds the length (total number of pt #) of the longest point to the driver
create or replace function LONGPT (DL# in TRIP.L#%type)
return TRIPPT.PT#%type
IS
TRIPPT# TRIPPT.PT#%type;
begin
select max (PT#)
into TRIPPT#
from TRIPPT
where T# in (select T#
from TRIP
where L# = DL#);
return nvl (TRIPPT#, 0);
end LONGPT;
/
How can I do a select query to view the employee NAME, LONGPT. The name of the driver that perform no trigger point must be in the application as well.I try
SELECT DRIVER.L# AS License_No, LONGTPT(TRIP.L#) AS "LONGEST POINT"
FROM DRIVER
LEFT OUTER JOIN TRIP on DRIVER.L# = TRIP.L#;
This only query the L# and the LONGEST Point.
Could someone guide me how to do select on screen the ENAME and with my LONGPT function.Published by: user4757127 on November 25, 2012 10:11
Published by: user4757127 on November 25, 2012 10:17
Published by: user4757127 on November 25, 2012 10:18
Hello
Welcome to the forum!
user4757127 wrote:
... How can I do a select query to view the employee NAME, LONGPT. The name of the driver that perform no trigger point must be in the application as well.
I don't know what you mean by "the employee, LONGPT.
My best guess is that you need join the employee table in your current query:
SELECT driver.l# AS License_No
, employee.ename -- ***** NEW *****
, longtpt (trip.l#) AS "LONGEST POINT"
FROM driver
JOIN employee ON driver.e# = employee.e# -- ***** NEW *****
LEFT OUTER JOIN trip ON driver.l# = trip.l#
;
Again, this is just a guess and guess isn't always the best way to solve problems.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002}
Tags: Database
Similar Questions
-
Hey guys,.
I'm using version 4.2.6 apex. The theme is 26.
IM also using Listener Oracle APEX.
I can print my classic report in PDF or CSV format.
But I need to export it as a .xls extension.
Report type: SQL (body of function from PL/SQL returning the SQL) query
I need is like this cause my 'where' clause type is dynamic.
Look at using this method: Tom's Blog: a non-standard export excel 2010 (.xlsx)
I do something similar for downloads to excel in my projects...
Thank you
Tony Miller
Software LuvMuffin
Ruckersville, WILL -
SQL (body of function from PL/SQL returning the SQL) query when you use to_char
We are trying to build a page of Type SQL Query report (body of function from PL/SQL returning SQL query).
our request is simple, to extract the month of the column recording_date.
declare
l_query varchar2 (1000);
Start
l_query: = 'select to_char (recording_date, 'MM') of re_productive;
Return l_query;
end;
but we would like the following for this query problem
Function returning SQL query: query cannot be parsed in the generator. If you believe that your query is syntactically correct, check the box of generic columns below the source of the region without analysis.
(ORA-06550: line 4, column 42: PLS-00103: encountered the symbol "MY" what awaits one of the following values:.) (* @ % & = - +; <>/ at is mod remains not rem <>or! = or ~ = > = < = <>and or as between | multiset Member SUBMULTISET_ the symbol ".") was inserted before 'MY' to continue.)
Notes:
1 - the request is correct and it has been tested under sqlplus and toad.
2. we tried option use generic name (analysis of query runtime only) column, but we get the same problem.
any quick help please.Hello
You have not escaped your quote in the string. Try this...
DECLARE l_query VARCHAR2(32767); BEGIN l_query:= 'select to_char(recording_date,''MM'') from re_productive'; RETURN l_query; END;
See you soon
Ben
-
How can I get a value from a function from pl/sql by OADBTransaction
Hi all
Hope you will be fine.
as we know, we can get a sequence by this code value:
Super.Create (AttributeList);
Transaction OADBTransaction = getOADBTransaction();
Vendor ID is obtained from the table sequence
Number supplierId = transaction.getSequenceValue ("FWK_TBX_SUPPLIERS_S");
My question is how can I get a value in a variable to a pl/sql function:
the function is defined as follows:
******
create or replace function getNextTrans return varchar2
is
Team varchar2 (20);
Start
SELECT "CASH". TO_CHAR (SYSDATE, 'DDMMYYYY') | GP_CASH_TRX_SEQ. NEXTVAL FROM DUAL;
return team;
end;
/Hey Dina,
Reference http://www.oraclearea51.com/oracle-technical-articles/oa-framework/229-calling-database-procedures-and-function-from-oaf.html
Kind regards
GYAN -
How to the return type of function from PL/SQL
Hello
I need to create a function that returns a list of ID, which is stored in a type T_IDs, something like:
search function (searchstring in varchar2) return to T_IDs
I have a little problem with the type within the body of the function using a select statement and filling
Select the id of the table where the text as searchstring.
which is to select a list of IDS corresponding to the where clause. Is it possible to use select in or should I go for another mechanism?
Thanks for all the ideas.Bulk Collect works for me...
SQL> create type t_ids as table of number; 2 / Type created. SQL> ed Wrote file afiedt.buf 1 create or replace function get_ids(deptno in number) return t_ids is 2 ids t_ids; 3 begin 4 select empno 5 bulk collect into ids 6 from emp 7 where deptno = get_ids.deptno; 8 return ids; 9* end; SQL> / Function created. SQL> select * from table(get_ids(10)); COLUMN_VALUE ------------ 7782 7839 7934
However, I would rarely use such a data collection, as it fills with PGA in memory and passing a lot of data between SQL and PL/SQL. I must have a just cause and justified in wanting to do things this way.
-
Authorisation scheme: poll from function from PL/SQL Boolean value
Hello
I use with authorisation schemes on page 2 as function of PL/SQL to return a Boolean.
The value of P1_PREF is from page1 (search) report box, driven model type (< class td = "t12data" >#PREF # < table >)
--(lien hypertexte pref) to page 2 P2_PREF.
I tried passing the value (: P2_PREF or: P1_PREF) but it does not work. If I assign (where pref = "100") or any other value it works fine.
Is it to do with sessions or to store the value in a variable prior to authorization of the page. Please notify.
DECLARE
v_userrole VARCHAR2 (400) DEFAULT NULL;
v_staffaccess VARCHAR2 (400) DEFAULT NULL;
BEGIN
Select USER_ROLE IN v_userrole
to userrole
where (upper (USER_LOGIN) = upper(:APP_USER)
or (upper (:APP_USER)) = 'TEST');
Select staff_access in the v_staffaccess of sm
where pref = "P2_PREF";
IF INSTR (v_userrole, 'A') > 0
THEN
RETURN TRUE;
END IF;
IF (((v_userrole) = "SP" OR (v_userrole) = 'U') and nvl (upper (v_staffaccess), 'x') do not ("SUPER %')) THEN)
RETURN TRUE;
ELSE RETURN FALSE;
END IF;
END;
Please advise on the passage of the value.
Thank you very much
HarinderHi Harinder
There are many ways this can be achieved. It seems to me that your problem is that the value passed to page 2 is not be updated at each visit?
So how about this (as only one way to do it).
Page 1 to P1_PREF
You press a button or link to go to page 2, that SUPPORTS THE PAGE (important)
You have a hidden item P2_PREF on page2, who has...Source used - always replace any existing value in session state
Source - point TypeAnd then refer to P1_PREF.
Or you can create a calculation that sets the value of P2_PREF to the value of P2_PREF on the laundry front header.
Or your button on page 1 could create a branch to page 2 using "defined these elements" "with these values" options in the industry...
See you soon
Ben
-
How to place a collar from pl/sql tab to set cursor?
Hello
I constantly get this error:
**************************************
Error on line 1
declare
--------------------------------------------
number of j: = 1;
cursor f
ORA-06550: line 9, column 20:
PLS-00103: encountered the symbol "TABLE" when the expected in the following way:
constant exception < an ID >
< a between double quote delimited identifiers > double Ref table Fedya
char time timestamp interval date binary national character
NCHAR
*************************************************
Code snippet:
declare
--------------------------------------------
number of j: = 1;
cursor firstquery (c_item in varchar2) is
SELECT SEARCH, the NAME, ID OF tablename
WHERE name LIKE c_item.
first_rec_tbl_type is the firstquery % rowtype directory index table;
first_rec_tbl first_rec_tbl_type;
type act_str_tbl_type is table of the varchar2 (50) index directory.
act_put_str_tbl act_str_tbl_type;
Start
It's the fine workmanship that I performed as a stand-alone script also
a table of act_put_str_tbl here.passing of values to below:
-I guess the problem lies here-
Start
dbms_output.put_line (' second reached start ');
I'm in act_put_str_tbl.first... act_put_str_tbl. Last
loop
dbms_output.put_line (' inside the second loop start ');
Open firstquery (act_put_str_tbl (i));
loop
extract the firstquery in first_rec_tbl (j);
j: = j + 1;
released in firstquery % notfound or firstquery is null;
end loop;
close firstquery;
end loop;
How to use parameterized cursor with PL/SQL table, any help is appreciated in the snippet above.
Thank youuser540130 wrote:
In the two above you are beating the objective by the way
Open firstquery ('S%'); Why you can not spend the type of array here is also of type varchar.Oops. Check my edited answer now.
SY.
-
How to call the package from a SQL string function
I create a SQL string in my c# application. Within the selection, I have a function call to a package in my diagram.
ex.
"Select id, package1.fncFormat (text) of tblText".
If I run this within Oracle it works fine but when I run my application and the SQL runs the use of OracleDataReader I get
«ORA-00904: "PACKAGE1".» ' FNCFORMAT': invalid identifier.
Is this possible to do?
It is a dynamic sql string that is built using many different options.
Thanks for any helpDo you run this application and directly on DB package by the same user?
Check the privileges of the user on the application.Kind regards
Bobin -
Irregular data loss - function from PL/SQL returning data using Ref Cursor
Database Version: 10.2.0.4.0 (node 2 CARS)
The high-level process flow is as below:
(1) insert records in a few tables & commit the same
(2) call the pl/sql function to extract files (on certain conditions with joins with other tables) of the tables which are filled in step 1.
-> It uses the ORDER BY clause to queries inline & line number 5000 records return for each call.
Sense - if inline query is supposed to return 1,00,000 records then 20 calls to the same function. This, because the application cannot contain records beyond number.
(3) the data returned by the ref cursor is then processed by application (Tibco BW) to generate the flat file.
We are facing the problem of data loss in the file and there is no fixed model. It happens once between 200-300 calls process.
Resolution: When the problem occurs, triggering the process and in almost every time re-outbreak of the process provides required data.
Guidance on what could be the reason?
* Examples of Code for the function:
CREATE OR REPLACE FUNCTION FUNC_GET_HRCH_TOTAL_DATA)
outinstrid in NUMBERS
outinstrkey in NUMBERS
rownumberstart in NUMBERS
rownumbereend in NUMBERS
err_code OUT VARCHAR2,
err_msg OUT VARCHAR2)
RETURN PACK_TYPES. HRCH_TOTAL_CURSOR
IS
REF_HRCH_TOTAL_CURSOR PACK_TYPES. HRCH_TOTAL_CURSOR;
BEGIN
OPEN FOR REF_HRCH_TOTAL_CURSOR
SELECT *.
FROM (SELECT A.HIERARCHY_KEY, B.KEY, B.VAL_KEY, A.KEY_NEW, C.ITEMID, B.VAL_TAG, B.sort_order, ROWNUM ROWNUMBER
OF AOD_HRCH_ITEM A, AOD_HRCH_ATTR B, AOD_HRCH_ITEMS C
WHERE A.outputid = B.outputid
AND A.outputid = C.outputid AND A.outputkey = B.outputkey
AND A.outputkey = C.outputkey AND A.outputid = outinstrid
AND A.outputkey = outinstrkey AND A.ITEM_SEQ = B.ITEM_SEQ
AND A.ITEM_SEQ = C.ITEM_SEQ AND A.HIERARCHY_LEVEL_ORDER = B.SORT_ORDER
ORDER BY A.HIERARCHY_LEVEL_ORDER DESC)
WHERE ROWNUMBER < rownumbereend
AND ROWNUMBER > = rownumberstart;
RETURN REF_HRCH_TOTAL_CURSOR;
EXCEPTION
WHILE OTHERS
THEN
err_code: = x_progress | ' - ' || SQLCODE;
err_msg: = SUBSTR (SQLERRM, 1, 500);
END FUNC_GET_HRCH_TOTAL_DATA;
/
Published by: meet_sanc on February 16, 2013 10:42Your SELECT statement is almost certainly incorrect
SELECT * FROM ( SELECT A.HIERARCHY_KEY, B.KEY, B.VAL_KEY, A.KEY_NEW, C.ITEMID, B.VAL_TAG, B.sort_order,ROWNUM ROWNUMBER FROM AOD_HRCH_ITEM A, AOD_HRCH_ATTR B, AOD_HRCH_ITEMS C WHERE A.outputid = B.outputid AND A.outputid = C.outputid AND A.outputkey = B.outputkey AND A.outputkey = C.outputkey AND A.outputid = outinstrid AND A.outputkey = outinstrkey AND A.ITEM_SEQ = B.ITEM_SEQ AND A.ITEM_SEQ = C.ITEM_SEQ AND A.HIERARCHY_LEVEL_ORDER = B.SORT_ORDER ORDER BY A.HIERARCHY_LEVEL_ORDER DESC) WHERE ROWNUMBER < rownumbereend AND ROWNUMBER >= rownumberstart;
Since the ORDER BY is applied after the ROWNUM is assigned in this case, your query is requested for a period of 5000 lines any arbitrariness. It would be perfectly valid for a single line to return in each of your 200 different calls or for a line to return in any of them.
You definitely want to do something in the sense of the canonical askTom wire
select * from ( select a.*, rownum rnum from ( YOUR_QUERY_GOES_HERE -- including the order by ) a where rownum <= MAX_ROWS ) where rnum >= MIN_ROWS
That said, it seems inconceivable that Tibco is unable to manage a cursor that returns more than a certain number of lines. You do a ton of work to return the data pages that are certainly not necessary. Unless you're saying that you somehow paralyzed your installation of Tibco giving him a ridiculously small amount of memory to process, something doesn't look good. A slider is just a pointer - it holds that no data - so the number of lines that you can extract a slider should have no impact on the amount of memory on the client application needs.
As others have already pointed out, your exception handler is almost certainly do more harm than good. Return the error codes and error messages as from the OUT parameters, instead of simply allowing the exception to propagate deletes a ton of useful information (such as the mistake of the stack) and makes your process much less robust.
Justin
-
Body of function from PL/SQL query SQL - problem with where Cluase return
Hi all
I have problem with sub PL/SQL. Where clause does not filter the values even when I change the value: P7_INVESTIGATOR. I have marked with an asterisk for where clause where I want the values to filtered.
DECLARE
v_sql varchar2 (5000);
v_inv VARCHAR2 (100);
Start
v_inv: = UPPER(:P7_INVESTIGATOR);
v_sql: = ' select TBLCASES. INVESTIGATOR as an INVESTIGATOR,';
v_sql: = v_sql | "TBLCASES. CASENUMBER as CASENUMBER,';
v_sql: = v_sql | "TBLCASES. OPENDATE as OPENDATE,';
v_sql: = v_sql | "TBLCASES. ESTCOMPLETE as DATE_CIBLE,';
v_sql: = v_sql | "TBLCASES. STATUS of STATUS ';
v_sql: = v_sql | "TBLCASES. Case CODE case CODE as,';
v_sql: = V_sql | "TBLCASES. FAIR_HOTLINE as FAIRHotline,';
v_sql: = v_sql | "TBLCASES. NYSIG as NYSIGCase,';
v_sql: = v_sql | "TBLCASES. The REGION';
v_sql: = v_sql | "TBLCASES. PROGAREA as PROGArea ';
v_sql: = v_sql | ' from TBLCASES where 1 = 1';
**************************************************************
If v_inv <>null then
v_sql
: = v_sql | "and UPPER (trim (tblcases.investigator)) = UPPER (trim (v_inv))';
END IF;
***************************************************************
v_sql: = v_sql | "order by tblcases.investigator";
Return v_sql;
end;
Thank youwrote:
Or it is possible to write it this way:if v_inv is not null then v_sql := v_sql ||' and UPPER(trim(tblcases.investigator)) = UPPER(trim(:P7_INVESTIGATOR))'; END IF ;
In this case we will use bind variables and we all know that it is very important.
Lev
Of cause, it is the best option. and I strongly suggest the OP to use.
But it depends on how the sql is used later.
Without knowing that, we cannot be sure if the item is available here. -
Impossible to retrieve the return value of function from pl/sql using the DB adapter
Dear Experts,
I use the DB adapter in my BPEL process. Using the DB adapter I invoke a PL / SQL function. I am able to send two input parameters for the pl/sql function. But I do not know how to retrieve the return value of the function. Please suggest me.
Thank you
RajeshCan you tell how pl/sql function looks like you? you return the value of the function, right?
-
How can I call ttOptUpdateStats from PL/SQL
I would like to: call ttOptUpdateStats from within a PL/SQL block.
An example of one: run immediately using the input arguments in the PL/SQL Developer's Guide.
The examples cover only builtin procedures returning data.
Thanks for the help! Here's my working version:
Create procedure UPDATE_STATS as
type of TblList is the table sys. TBL_STATS. TYPE % TBLID;
tblids TblList;
TBL VARCHAR2 (255);
flag for number: = 1;
plsql_block VARCHAR2 (255);
LASTDATE SYS. TBL_STATS. TYPE % LASTSTATSUPDATE;
Start
plsql_block: = "call ttOptUpdateStats(:tbl,:flag)";
Select TBLID bulk collect into SYS tblids. TABLES where the TBLOWNER not in ('SYS', 'TTREP', 'GRID');
because me in tblids. FIRST... tblids. LAST
loop
Select trim (TBLOWNER): '. ' || Trim (TBLNAME) tbl of SYS. TABLES where SYS. TABLES. TBLID = tblids (i);
execute immediate plsql_block using tbl, flag;
Select LASTSTATSUPDATE from SYS lastdate. TBL_STATS where SYS. TBL_STATS. TBLID = tblids (i);
dbms_output.put_line ('< '="" ||="" rpad(tbl,45)="" ||="" '="" '="" ||="" lastdate="" ||="" '="">');
end loop;
exception
while others
then
Rollback;
end UPDATE_STATS;
/
Ed...
-
How to call a function from creationComplete clicking a button?
Hello
I wrote a function called getJson (jsonUrl) within the complete creation. I need where to load the default power json in the carousel.
However, I also need to be able to call from button clicks, i.e.
var blogJsonURL = ' http://mywebsite.com/ui_jsonFeeds/blog.aspx?callback=?';
getJson (blogJsonURL);
This is so that I can switch between different json stream.
Any help would be most appreciated.
Thank you.
And you should also keep the definition above the function call:
Thus,.
var defaultJsonURL = 'http://dev-www5.coj.net/ui_jsonFeeds/coj2/mayorsBlog.aspx?callback=?';
sym.getJson = function (jsonURL) {...};
sym.getJson (defaultJsonURL);
HTH,
Vivekuma
-
How to call a function from another script.
Hallo
TypeError: Error #1009: cannot access a property or method of a null object reference.
next / NEXT)and here is my script.
Main.As
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.URLLoader;
SerializableAttribute public class Main extends MovieClip
{
public void Main()
{
trace ("Startup");
}public void PRINT (): void
{trace ('work');
}
}
}
Next.Aspackage
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.URLLoader;
SerializableAttribute public class then extends MovieClip
{private var _main:Main;
public function Next()
{
NEXT_INT();
}
private void NEXT_INT (): void
{mc.buttonMode = true;
mc.addEventListener (MouseEvent.MOUSE_DOWN, NEXT_PRINT, false, 0, true);
}private void NEXT_PRINT(e:MouseEvent):void
{
_main. PRINT();
}}
}
http://noLabel.pl/QuickTest.rar
http://noLabel.pl/QuickTest.zip
Try this. I can't compile your application in case of location (names of variables with national characters). Here you have a quick example: we have two symbols in the library buttonMC and playerMC related to clssses Player and button. There handleClick (click event handler) method in the Button class, who do the work for you.
concerning
JK
-
Calling functions from another class
How one accesses a function from another class?
Let's say I have a file called .as hand. My flash file uses this as this is the main class to make it work when you test the program. Let's say I have another class named Test that looks like this:
package
{
public class Test
{
public void Test()
{
trace ("why don't you work?');
}
}
}
I want call the Test function when the game takes place (in the appellant to hand), how would he enter the main run file? I imported to it, made sure that the functions were public/static, created as a variable and it still doesn't work.
Any help would be good
the constructor for a class is different from a 'normal' function
If you can't do something like
meow: Test of var = new Meow();
To call it thus:
test: Test of var = new Test();
test. Meow();
Maybe you are looking for
-
MacBook Pro goes black rear boot.
This is my daughter pro MacBook. I remember exactly what OS it is running, but I think it's 10.9 She returned to be there and told me that one day it just started doing this: After starting and the normal boot process, the screen goes black and a few
-
Video performance, Windows XP and Windows 7
I tried to watch videos HD with Windows 7, but it was not very good. The image would stop and start then the audio rolled on. I went back to XP and is surprised that the 1280 x 720 mkv file worked fine under XP. It was not perfect, there were a coupl
-
Windows XP on Compaq CQ61-410US
Hello, I recently bought a Compaq CQ61-410US and he was giving me no trouble. I need to install Widnows XP out there because I need to run programs that won't run in Windows 7 Home premium x 64. So I tried to slipstream drivers and all, but I get the
-
If you change a value on a disabled control programmatically, become reactivated?
I'm trying to solve a problem on a surface that worked before I added new codes... I have a cluster with Boolean LED, ring type dropdown menus and text boxes. Before... I've had situations where I've disabled the entire cluster... and it worked, and
-
How can I get rid of the error 80070005? __
I try to install an update ("HP - display - HP w2207 LCD wide screen"), but constantly get error 80070005. How can I fix it?