Howto use functions inside IN conditions
Hi all.
Is possible to use functions after an "IN" condition?
If it's possible, What kind of datatype must return the function? And how can I add data to this kind of datatype?
I want to do somthing like:
CREATE OR REPLACE FUNCTION function1 (param number) RETURN xxxxx IS
END;
SELECT * FROM TABLE1 WHERE codigo IN function1(10);
Thanks a lot.
Olver
Since a function returns a single value you would normally use = rather than IN.
If you need to return multiple values, depending on the version of Oracle, you could use a pipelined table function. Your query would then be
SELECT *
FROM my_table
WHERE my_key IN (SELECT key FROM TABLE( pipelined_table_function( parameter ) ) );Justin
Similar Messages
-
How to use function inside background job?
I try to call function inside job. It does not work. Is it possible to use function inside job or not. I hope you can help me. Here is my example code.
Start-Job -Name ForestJob {param($v01,$v02)
$line = @()
function test {
return "testvalue"
$t = test
$line += $t
} -ArgumentList $var01, $var02Hi,
Just checking in to see if the suggestions were helpful. Please let us know if you would like further assistance.
TechNet Subscriber Support
If you are
TechNet Subscription
user and have any feedback on our support quality, please send your feedback
here.
Regards, Yan Li -
Can i use function inside sql in a form ?????
Here SERIAL_NUM is a function, this sql work fine in TOAD and SQLPLUS but inside the form iam getting error saying "function serial_num cannot be used in a sql" Why is it like that ?? Is there anyother way to execute this sql ?
cursor c1 is
SELECT msn.ATTRIBUTE7 Order_No,
SERIAL_NUM(i.SERIAL_NUMBER) Serial_No,
msn.ATTRIBUTE5 Firmware,
msn.ATTRIBUTE15 Site_Pref
FROM atrd.INSTALLER_INFO i,
mtl_serial_numbers msn
where SERIAL_NUM(i.SERIAL_NUMBER)=msn.SERIAL_NUMBERhi,
yes of course you can use the functions in sql as well as in forms( within sql statements).
here i think you are not connected to the Specified user which is having the function Serial_num
or other thing may that ur syntax
just check both of them that may help you.
enjoy
Tehzeeb Ahmed -
Howto use methods inside itemRenderer
Hi,
I have basic itemRenderer made as component:
<mx:Component id="ColorRenderer">
<mx:Label
text="{rgb2hex(255,100,50)}" // This gives error: 1180: Call
to a possibly undefined method rgb2hex
/>
</mx:Component>
My method works if i use it with "normal" label like
<mx:Label x="22" y="12" text="{rgb2hex(255,100,50)}"
width="150"/>
but it does not work inside itemRenderer ?
What am i missing here ?quote:
Originally posted by:
peterent
When you use the <mx:Component> tag you are defining a
new variable scope. In this scope, rgb2hex does not exist. You need
to qualify it: {
outerDocument.rgb2hex(255,100,50)}
Yep, that was the answer, Thanks -
Call library function inside a conditiona​l disable bug
i'm trying to call a function in a dll using the call library function inside a conditional disable structure.
one of the parameters is a pointer to a C structure.
here is the prototype:
short in myfunction(short in DevNum, void *pMetrics);
outside of the conditional disable, LabVIEW allows me to wire the pMetrics parameter to a cluster.
if i put the function inside the conditional disable, LabVIEW doesn't allow me to wire it.
as a workaround, i put the cluster inside the conditional disable as well.
any ideas?Simply create a constant of the cluster and and put it outside the disable structure. Wire this constant to all inputs (left side terminal) of the Call Library Node. A Call Library Node (CLN) set to Adapt to Type does need a valid datatype to adapt too. This works from the outside side (right side terminal) of the CLN only if the according indicator is inside the same data structure. In older LabVIEW versions you actually had to always define the left side by wiring a constant or a dummy control to it.
This has to do with the algorithme that evaluates datatypes along wires. Making that algorithme go backwards (against the natural dataflow) inside one subdiagram without causing circular references or similar is already a challange. Doing that across diagram boundaries (case, disable, loop, etc. structures) is basically impossible without causing the entire edit operation to get very slow.
Message Edited by rolfk on 10-20-2009 08:28 AM
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Built-in functions inside text_io
I am using text_io to get dir information. When inside the loop built-in functions such as to_date are not working. It is simply ignoring the function. However if I put a simply message box, it works.
Is there a limitation to using functions inside text_io.
Also, any code, including message boxes, outside text_io exit loop is ignored. Is there something I can do to fix it?
Thanks,
SrikanthBut if I want to compare 2 dates, I cannot assign it to variables. I need to something like
If to_date(a) - to_date(b) > 0 then
else
end if;
This is not working inside text_io. Any ideas?
thanks -
I have problems for to use Start function inside a case structure.
I am doing data acquisition using the Config, Start and Read functions, all them inside a while loop. I want to use Config function only when certain conditions occur, so I put the function inside a case and no problem. But when I put the start function inside the same case, the acquisition is not good. Please view my attachment. My application is client-server type.
Attachments:
scope_server(config_start).vi 160 KBBoxer,
I checked your example and have several easy but important suggestions for you:
1.- First, make sure that the first time you initialize the VI, the AI Config and AI Start are executed, because based on the debug I made, your program doesn't do it, and this is very important.
2.- Add an AI Clear after the acquisition is done, so that you release the resources. This is a good programming technique, and may help you solve your issue.
3.- Add an Error Cluster, so that you know if an error occurred at some point of the acquisition. This will help you track the issue.
4.- What do you mean by "the acquisition is not good". What does it happen? What does it do? Do you get an error? <- This is the reason of step 3.
5.- Finally, if you have doubts
programming AI, check one of the shipping examples of LV. They can give you a much clearer idea.
Hope this helps,
L Aguila
Applications Engineeer
National Instruments -
How to use analytical functions inside a mapping
Hello everybody. Here Isend you a trick that we are using for two years.
If you want to use a function (for instance :ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...)) inside a mapping you must create an expression with in the INGRP1 the fields you are going to use in the window function and in the OUTGRP1 the function you want. Create an Out -attribute with the expressión and link it to a distinct operator (using a "distinct" you encapsulte the sql and you will be able to use the function inside a filter - in the where clause.). The distinct can eliminate some register (depends on the function). If you validate the expression an error will appear (don't worry about that, the mapping will be ok).
But there is a limitation, you will not be able tou sum over, min over, max over (it detect that they are aggregator functions). Other limitation: the debugger doesn't run with this kind of functions.
Please publish this information on "The Warehouse Builder Utility Exchange". Mi email is [email protected] (if you need more information)It is possible to add SUM, MIN, MAX functions also to OWB releases prior to Paris - You have to put them in double quotes - write "MIN" "MAX" "SUM" etc. The rest of the rules (adding cut-off operator after the expression - as DISTINCT, or UNION ALL) is analogical to with ROW_NUMBER()
That means You can create mapping with following functionality:
SELECT
sum (salary) over (partition by DEPARTMENT) department_salary,
salary,
employee_id,
employee_name
FROM employees_salaries
writing it this way in OWB:
SELECT
"SUM" (salary) over (partition by DEPARTMENT) department_salary,
salary,
employee_id,
employee_name
FROM employees_salaries
Regards,
Martin -
Problem in using aggregate functions inside case statement
Hi All,
I am facing problem while using aggregate functions inside case statement.
CASE WHEN PSTYPE='S' THEN MAX(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ELSE SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) END,
how can I achieve above requirement ? Con anyone help me.
Thanks and Regards
DGHi All,
Below is my query:
SELECT
CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT
ELSE POS.PACCT || '-' || DECODE(POS.SYSTEMCODE,'GMI1','1', 'GMI2','2', 'GMI3','4', 'GMI4','3', '0') ||POS.PFIRM|| NVL(POS.POFFIC,'000') END,
CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-')
ELSE POS.PFIRM||POS.POFFIC||POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-') END,POS.SYSTEMCODE,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,POS.PEXCH||DECODE(POS.PSUBEX,'<NULL>',''),
POS.PCURSY,
CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) END ,
NVL(POS.PSUBTY,'F') ,POS.PSTRIK,*SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ,SUM(DECODE(POS.PBS,2,ABS(POS.PPRTQ),0))* ,
POS.PCLOSE,SUM(POS.PMKVAL) ,
TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
POS.UBS_ID,POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER ,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,TO_CHAR(POS.BUSINESS_DATE,'YYYYMMDD'),
POS.SOURCE_GMI_LIB,
--DECODE(POS.SYSTEMCODE,'GMI1','euro','GMI2','namr','GMI3','aust','GMI4','asia','POWERBASE','aust','SINACOR','namr',POS.SYSTEMCODE),
DECODE(p_reportid,'RVPOS_SING','euro','RVPOS_AUSTDOM','aust','RVPOS_AUSTEOD','euro','RVPOS_GLBLAPAC','asia','POS_RV_SN','namr','POS_PB','aust',POS.SYSTEMCODE),
POS.RIC,
CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
NVL(C.SSECID,POS.PCUSIP),
NULL,
POS.PYSTMV,
POS.PMINIT,
POS.PEXPDT,
CASE WHEN POS.PSUBTY='S' THEN SUBSTR(C.ZDATA2,77,1) ELSE NULL END,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
FROM POSITIONS_WRK POS LEFT OUTER JOIN
(SELECT * FROM CDS_PRODUCTS CP INNER JOIN FUTURE_MASTER FM ON
(CP.STRXCH=FM.ZEXCH AND CP.SFC=FM.ZFC AND CP.BUSINESS_DATE = FM.BUSINESS_DATE )) C ON POS.PCUSIP = C.SCUSIP
AND NVL(POS.PCUSP2,'X') = NVL(C.SCUSP2,'X')
WHERE
POS.PEXCH NOT IN ('A1','A2','A3','B1','B3','C2','D1','H1','K1','L1','M1','M3','P1','S1')
AND (POS.PSBCUS IS NOT NULL OR POS.PCTYM IS NOT NULL OR POS.PSTYPE ='S')
AND POS.BUSINESS_DATE = run_date_char
GROUP BY
POS.UBS_ID,POS.SYSTEMCODE,POS.RECIPIENTCODE,POS.BUSINESS_DATE,POS.PACCT,POS.PFIRM,POS.POFFIC,POS.PCUSIP,POS.PBS,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,
POS.PEXCH,POS.PSUBEX,POS.PCURSY,
CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) END,
NVL(POS.PSUBTY,'F') ,POS.PSTRIK,POS.PCLOSE,TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,POS.PSUBTY,POS.SOURCE_GMI_LIB,RIC,
CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
NVL(C.SSECID,POS.PCUSIP),
POS.PYSTMV,
POS.PMINIT,
POS.PEXPDT,
CASE WHEN PSUBTY = 'S' THEN SUBSTR(C.ZDATA2,77,1) ELSE NULL END;Now, could you plz help me in replacing the bold text in the query with the requirement.
Thanks and Rgds
DG
Edited by: BluShadow on 16-May-2011 09:39
added {noformat}{noformat} tags. Please read: {message:id=9360002} for details on how to post code/data -
How to use select a vi function inside a loop?
I am modifying the notifier basics part 2.vi to send a notifier to each of 64 sub-vi's. How can you use the 'select a vi' function inside a loop for 64 iterations to access the individual filenames??
Attachments:
Notifier_BASICS_Part_2.vi 87 KBIf all you are trying to do is send notifiers to each of these 64 subVIs, I would suggest not doing it in a loop, but rather just placing the 64 subVIs in your diagram.
The alternative is of course to use the call by reference node and have an array of VI names. This is a little cleaner on the diagram, but 1) doesn't occur in parallel and 2) is a bit tricky. Additionally, you have to be sure that your array of filenames is correct, and that you NEVER move or rename those VIs. Of course, you could always put them in a directory and create an array by reading the directory contents.
Either way, good luck, it doesn't sound like fun. -
Using the result of a function, inside a subselect
Hi!
I´m wondering if it´s possible to use the result of a function inside a subselect. Let me give you an example of what I´m trying to do here:
select * from t_node where node_pk in (get_node_parents_pk(22345));
The function get_node_parents_pk stands in for the following SELECT-statment:
select node_pk from t_node_child where parent_node_pk = 12345
The statement above would return something like this: 12435,23423,23453,23452
These values represent the node_pk value for the parent nodes.
I want the get_node_parents_pk function to return a result set similar to this so that I might call it inside the IN ( ) statement.
Any clue? =)I created a collection type in the database:
CREATE OR REPLACE TYPE nodes_pk_arr IS TABLE OF INTEGER;
The function get_node_parents_pk () is made to return the collection type above. However, this does not work. I get the following error message:
SELECT *
FROM t_node
WHERE node_pk IN
(SELECT * FROM TABLE (get_node_parents_pk (22345)));
ORA-22905: cannot access rows from a non-nested table item
However, if I insert a nodes_pk_arr collection directly into the SQL-statement, like I do below, it works:
SELECT *
FROM t_node
WHERE node_pk IN
(SELECT * FROM TABLE (nodes_pk_arr(24564,23545,34523));
So, when returning the collection from the function I´m told that the collection is not a nested table, when in fact it is. What gives?
Also, is there no way to return a result set directly from the get_node_parents_pk() function, making it possible to write the statement like that shown below?
SELECT *
FROM t_node
WHERE node_pk IN (get_node_parents_pk (22345));
Your reply is much appreciated!
Kind regards
Robert -
Use a package function inside a select of the same package
Hi.
How can i use a function defined inside a package, with a select used inside that same package ?
Example
... package example
CREATE OR REPLACE PACKAGE BODY pkg_example
AS
FUNCTION sum_two_values(p_val1 NUMBER,p_val2 NUMBER) RETURN NUMBER
IS
BEGIN
RETURN p_val1 + p_val2;
END sum_two_values;
FUNCTION use_another_function_example RETURN VARCHAR2
IS
v_value NUMBER;
BEGIN
SELECT sum_two_values(2,2) INTO v_value FROM dual;
RETURN 'waaaazzzzupppppp'
END use_another_function_example;
END pkg_example;
This will not work
-- SELECT sum_two_values(2,2) INTO v_value FROM dual;
How can i call a function inside a select statement, a function of the same package where the query is being called.
(i have Oracle 9.2x)
Cheers.are you sure? you are not using package1, you are using pack1
SQL> CREATE OR REPLACE PACKAGE package1
2 IS
3 FUNCTION f1
4 RETURN NUMBER;
5
6 FUNCTION f2
7 RETURN NUMBER;
8 END;
9 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY package1
2 IS
3 a NUMBER;
4
5 FUNCTION f1
6 RETURN NUMBER
7 IS
8 BEGIN
9 RETURN 1;
10 END;
11
12 FUNCTION f2
13 RETURN NUMBER
14 IS
15 BEGIN
16 SELECT package1.f1
17 INTO a
18 FROM DUAL;
19
20 RETURN a;
21 END;
22 END;
23 /
Package body created.
Why not just this
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE PACKAGE BODY package1
2 IS
3 a NUMBER;
4 FUNCTION f1
5 RETURN NUMBER
6 IS
7 BEGIN
8 RETURN 1;
9 END;
10 FUNCTION f2
11 RETURN NUMBER
12 IS
13 BEGIN
14 a:= f1;
15 RETURN a;
16 END;
17* END;
SQL> /
Package body created.formatted
Message was edited by:
devmiral -
Can I use table function inside Dynamic query ?
Dear Gurus,
I have following code
DECLARE
TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
QUERY_STRING VARCHAR2(4000);
BEGIN
OtherNoList := CRITERIA_LIST_TABLE();
SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
'SELECT C1,'||
'C2 '||
'FROM TAB1 ,'||
'TABLE( '||
'CAST (OtherNoList AS CRITERIA_LIST_TABLE) '||
') OTHRNOS '||
'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
EXECUTE IMMEDIATE QUERY_STRING;
END;
Can I use Table function inside dynamic query.
Thanking in advance
SanjeevTry:
DECLARE
TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
QUERY_STRING VARCHAR2(4000);
BEGIN
OtherNoList := CRITERIA_LIST_TABLE();
SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
'SELECT C1,'||
'C2 '||
'FROM TAB1 ,'||
'TABLE( '||
'CAST (:OtherNoList AS CRITERIA_LIST_TABLE) '||
') OTHRNOS '||
'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
EXECUTE IMMEDIATE QUERY_STRING using OtherNoList;
END;p.s. not tested
Amiel Davis -
Using function Decode inside Decode for Oracle Reports
Has anyone used a decode inside of a decode to get a single record from mulitple records?
ThanksI've used decode inside of decode to create a view. Then in the report, I used a group by query to combine the records. Let me know if you want to my sql.
-
How to open labview program with Quit Labview function inside?
Hi Any idea how to open labview program with Quit Labview function inside?
I forgot to add and set the condition of the type for this program.
If the program is an application, it would close straight away.
If it is still labview work, it will go straight to editing program without closing.
So I need to recover, open it and make some changes.
Clement
Solved!
Go to Solution.Put the VI in a project and open it from there, then it shouldn't autorun. You can use App.kind property of application to decide whether to close or not.
/Y
LabVIEW 8.2 - 2014
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
G# - Free award winning reference based OOP for LV
Maybe you are looking for
-
My wife and I use the same app store account, but we would like to have our own separate accounts. How can we do this and not loose our own personal apps. and music.
-
Did not find error in message but message is in error
Hi dears, i got a synchronous message in error.and i checked that in SXMB_MONI.Where its original message is recorded and its response message is in error category of 'Request Message Mapping' .with no error id. i want to find exact error in its Tra
-
Hi, all, I wanted to let you know about a special one+ day track at JavaOne this year focusing on TV: Java� Technology in TV: Blu-ray Disc and Cable Day at the JavaOne℠ Conference in San Francisco Thursday, May 10 Morning General Session: Friday, May
-
View Deleted sales orders by material
Hi gurus, how I can see deleted sales order by a specific material. My requeriment is that know all deleted sales order or items deleted in existing orders filtering by material. It's possible? Table CDPOS doesn't contain field material... Thank you!
-
How to close FTP, SSH, Telnet ports on OS 10.6.2?
SheildsUP! at https://www.grc.com/x/ne.dll?bh0bkyd2 tells me that I have ports 21, 22, and 23 open. The application firewall on my iMac allows "signed software to receive incoming connections" and "stealth mode" is checked. The option "Block all inco