function defined by the user in where clause
HelloPlease let me know how to use user-defined in the where clause. I need to use the function that returns the date for dateid.
It generates the error...
SELECT To_char(fnc_get_date_for_dateid(a.postdateid),'DD-MON-YYYY') transaction_date,
SUM(A.points) POINTS_OR_MILES_CREDITED,
SUM(CASE WHEN a.points is null THEN a.transactionamount ELSE a.points END),
FROM accrual a
JOIN datecal dc ON dc.dateid = a.postdateid
join MemberALL m on m.memberid = a.memberid
WHERE a.awardnumber IS NULL
AND a.accrualtype = 'B'
GROUP BY To_char(fnc_get_date_for_dateid(a.postdateid),'DD-MON-YYYY')
ORDER BY a.postdateid;
ErrorORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
Thank youSandy
Hi Sandy,
Have you tried like
===========================
SELECT To_char (fnc_get_date_for_dateid (a.postdateid), 'DD-MON-YYYY') transaction_date,.
Sum (A.points) POINTS_OR_MILES_CREDITED,
SUM (CASE WHERE the a.points is null THEN a.transactionamount ELSE a.points END),
The ACCRUAL one
JOIN dc datecal ON dc.dateid = a.postdateid
Join MemberALL m on m.memberid = a.memberid
WHERE a.awardnumber IS NULL
AND a.accrualtype = 'B '.
GROUP BY a.postdateid - To_char (fnc_get_date_for_dateid (a.postdateid), 'DD-MON-YYYY')
ORDER BY a.postdateid;
==========================
Thank you
Slokam
Tags: Database
Similar Questions
-
function defined by the user in the package
Hi all
is it possible to return a value greater than 1 when you use the function defined by the user in the package?You must declare variables US1 and US2 as well. I also modified your code a little more assing numbers directly rather than using select.
First of all,
Your package body and specifications should have the same input parameter names. Your spec is seen cid and your body with ccid. Has changed.
CREATE OR REPLACE PACKAGE creator.marco_function_clienttype IS -- 0 - not found -- 1 - small business -- 2 - corporate -- 3 - individual FUNCTION f_clienttype (ccid number ) RETURN NUMBER; END; /
CREATE OR REPLACE PACKAGE BODY creator.marco_function_clienttype IS FUNCTION f_clienttype (ccid NUMBER) RETURN NUMBER IS us NUMBER; us1 NUMBER; us2 NUMBER; BEGIN --officialtype = 2 - corporate, officialtype = 3 - individual SELECT ct.officialtype INTO us1 FROM contragenttype ct, contragent d WHERE d.ID = ccid AND ct.cid = d.contragenttypeid; --- IF us1 = 3 THEN us := 3; ELSE --ENTERPRISETYPE.id = 910 - small business SELECT dd.enterprisetypeid INTO us2 FROM contragent dd WHERE dd.ID = ccid; IF us2 = 910 THEN us := 1; ELSE us := 2; END IF; END IF; RETURN NVL (us, 0); END; END; /
G.
-
You can use functions defined by the user in orardf: statement?
Hello, reading Chapter 5: refined for RDF data access control
I found this example:
OPTIONAL
{
? control pred: hasContractValue? Val.
? control pred: hasManager * ' sys_context ("his $ appctx ', 'app_user_uri') ' ^^ orardf: instruction *.
}
See the orardf type: statement, I got the question if you can use functions defined by the user in the place where he has used the sys_context?
Thank you.
PD: The translation was made from Spanish to English by using Google TranslatorHello Alberto,.
Only the sys_context function is supported. The user-defined functions are not supported.
Thank you
Matt -
Function defined by the user in order by?
Hey guys. We try our postgres database to Oracle to port, and I fall on this issue. We have columns called "sortSequences", which are arrays of arbitrarily long integers. To some fine POC, I use varray(), but that probably won't work as a production application, due to its strongly defined by size. In any case, the crux of the problem is that I need to be able to select * from foo by sortSequence, where the evaluation order is custom code. The array of integers represent essentially mathematics of infinite precision and we have a deterministic algorithm to compare, but we can't just produce a value between them (what I think keeps me to use a card member function in a user-defined object type.) In other words, we don't really care what are the values, we are just using their collectively as an index of sort. An aggregate function like the right answer, and a simple scalar function is out of the question. We watched the field index, but it is not clear to me that even if we created an operator related to our type defined by the user that the db would use this function for order by rating...
Everyone can think of a solution to this problem? If we must live without this feature, we can reproduce in the application code, but we want to avoid that at all costs...
Thank you
Brian
The array of integers represent essentially mathematics of infinite precision and we have a deterministic algorithm to compare, but we can not simply to produce a value between them (I think preventing me to use a card member function in a user-defined object type.)
OK, but what about a method of ORDER?
Since you seem to have the algorithm already, is not just a matter of implementation of the COMMAND method?
Performance, it is not ideal but it's a start.
Something along these lines:
create or replace type array_t is varray (32767) integer;
/
create or replace type sort_sequence_t as object)
v array_t
member function serialize return varchar2
, for the integer return order member function match (o sort_sequence_t)
);
/
create or replace type body sort_sequence_t is
member function serialize return varchar2 is
RES varchar2 (4000);
Start
because me in 1... self.v.Count loop
If I have 1 > then
RES: res = | ',';
end if;
RES: res = | TO_CHAR (self.v (i));
end loop;
return res;
end;
order whole return leg (o sort_sequence_t) member function is
whole v1;
whole v2;
Start
because me in 1... Greatest (self.v.Count, o.v.Count) loop
If self.v.exists (i) then
v1: = self.v (i);
on the other
v1: = 0;
end if;
If o.v.exists (i) then
V2: = o.v (i);
on the other
V2: = 0;
end if;
If v1< v2="">
Returns - 1;
elsif v1 > v2 then
Return 1;
end if;
end loop;
return 0;
end;
end;
/
Tests...
SQL > with sample_data (id, sort_seq) as)
2 Select 1, sort_sequence_t (array_t (10,1,1)) of all the double union
3 select 2, sort_sequence_t (array_t (1,1, -1)) of all the double union
4 Select 3, sort_sequence_t (array_t (1,1,1)) of all the double union
5. Select option 4, sort_sequence_t (array_t (1,1,2)) of all the double union
6 select 5, sort_sequence_t (array_t (1,20,1)) of all the double union
7. Select 6, sort_sequence_t (array_t (1,7,1)) of double
8)
9. Select t.id
10, t.sort_seq.serialize (as seq_str)
sample_data 11 t
12 order by t.sort_seq;
ID SEQ_STR
---------- --------------------------------------------------------------------------------
2-1,-1, -1
3 1,1,1
4 1,1,2
6 1,7,1
5 1,20,1
1 10,1,1
6 selected lines
Post edited by: odie_63 - added example
-
Functions defined by the user with several parameters
I set features three following user using "Define."
UF1 takes a single patameter;
UF2 takes two parameters;
and UFX takes two parameters - with the second is 'X' in the definition.
Œuvres F1. F2 is the EVAL of F1 version and it works too. User functions only seem to work fine.
F3, a function of two user settings, produces a graph of NaN.
F4 is the EVAL of F3 version. Note that 'B 'is not replaced by 1'. Also produces a NaN chart.
F5 produces a graph of NaN.
F6 is EVAL of F5. The 'X' is not replaced (even with the ' B' above), and even if it looks like 'X * X', it also produces a graph of NaN.
Is it possible to get defined by the user, with several parameters, features work by tracing the curve?
Hi!, Fortin:
If you download and install the ultimate Firmware with the version of the software: 2015 6 17 (8151), with the number of Version: 1.1.2 - 11, you can trace your examples of definition of the function, with curves and values, without NaN.
-
Need for a function defined by the user in order to obtain a weighted average
Hello
We have a table where we want to device the weighted average for a column of prices below using formula,
sum (quantity * price) / sum (qty)
We have a few lines where part or all of the columns that is price or quantity can be NULL.
We have tried to write the function as follows however, it fills even after 30 minutes, where as we have the addition of this feature request could was completed in 25 seconds.
Please note that we are dealing with big data i.e. the table could have 50 million records. It has appropriate indexing and other components to improve performance required.
We know that we did something wrong in the creation of feature below, but we are unable to resolve
CREATE OR REPLACE FUNCTION "WEIGHTEDAVGPRICE" (PCOLNAME NUMBER( ) RETURN NUMBER
IS
TEMP NUMBER (26,13);
BEGIN
SELECT SUM (QUANTITY * PCOLNAME) / SUM (QUANTITY) IN TEMP DE FEES;
RETURN TEMP;
END WEIGHTEDAVGPRICE;
Here, we send the parameter THAT PCOLNAME represents the name of the price column we want to do a weighted average.
We know we could do this without adding a feature, but we need instructions BOX, and then in our SELECT clause. We use toplink to query the database, in this case, it will be difficult to covert.
Also, we want this function to be used in other places as well.
Thank you
@Bhagyesh KNW
The reason for the decrease in performance when you use the function, you call the function from a query and which is originally a context switch between SQL and PL/SQL engines. That is known to slow down performance. If you can only do the task in SQL, you must do so, in order to avoid context switching.
It would be useful that you provided a few sample data and expected the output, as indicating the version of your database, so that people can understand and help you better.
Please read:
-
Can I use function defined by the user in the control file Sql Loader?
Hi Master,
Can I use fuction user-defined in the sql loader control file? Please advise... !!
If you can provide an example... It's very kind of you.
Concerning
AR
Here are a few examples that should give you clues: Sql loader
I seriously wonder if why you use the century previous SQL * Loader instead of a external table:
ORACLE-BASE - external Tables: querying data from flat files in Oracle
-
Generator function defined by the user (normalize data points)
Hi all
You can use the function Scale1D to the Analisys Advanced library.
-
How to call the function defined by the user
Hello
I need help...
In my project, I have page Login.jspx where there is a user name text box.
I second success.jspx page that has its bean class of success.java I define a method "display(). Now, I want to display() cal on my success.jspx page.
can anyone help me what is the way to do it.
Thanks in advance...
Thank you
NehalHello
I think we can declare the variable txtVal of chain in the world or outside of the method and create the Set accessor method and the Get accessor.
Then, we could try to access the value like this...value = "#{backingBeanScope.backing_FrgtPwd.txtVal} '"
~ Abhijit
-
Defined by the user function in query...
I have included a function defined by the user in the SQL query that gave rise to the query takes a long time.
Select col1, col2 (col1, col2) fn_userfunction from table where col1 in (values);
The function calculate some values based on col1 and col2.
How this improved query performance?
Concerning
Jean-LouisHello
If it was before including quickly, then you must look at the function for the performance. Maybe you can include the function in the SQL code, which makes it faster. Something else may be to put the function in a subquery:
select col1, col2, (select fn_userfunction(col1, col2) from dual) xxx from table where col1 in (values);
But you should always try to put at least as possible function in SQL. He created above.
If the query is too slow without the function, then an index on col1 can help, but depends on the data and distribution.
If you need help with the feature, you must provide the code for the forum. Then, perhaps we can help.
Herald tiomela
http://htendam.WordPress.com -
Function of stored procedure defined by the user of the appellant
Hi all -
I am trying to call a function defined by the user of a stored procedure. I'm using something like
the above is correct.IF condition1 THEN function1(param1, param2); END IF;
I have PLS-00221 function1 is not a stored procedure or is not defined?Well, if it is a function, you will need to assign its result value in a variable.
Like this:
DECLARE some_variable [of the right datatype]; ... IF condition1 THEN some_variable := function1(param1, param2); END IF;
-
Defined by the user exception handling
Hello
version Oracle 11.1.0.7
Question 1:
I just want to know what is the difference between the methods for using user-defined exceptions.
Method 1: don't need initialization exception
Method 2: use initialization exceptioncreate or replace procedure p1 as exc_p1 exception; begin do something .... -- fails Raise exc_p1; exception when exc_p1 then raise; end;
Question2create or replace procedure p2 as exc_p2 exception; prgma exception_init(exc_p2,-20999); begin p1; exception when exc_p2 then raise; end;
Please let me know when and where to use these user-defined functions and I read the comments of Tom kyte on the use then than others, then raise or raise_application_error
exception management. Rather than use the raise or raise_application_error can I use "dbms_output.put_line (dbms_utility.format_error_backtrace); dbms_output.put_line (dbms_utility.format_error_stack)) 'or can I do the exceptions as handler below.
Thank you" when others then raise_application_error(-20001,'error in p1 '||dbms_utility.format_error_backtrace ||dbms_utility.format_error_stack); "
MikeMike wrote:
Helloversion Oracle 11.1.0.7
Question 1:
I just want to know what is the difference between the methods for using user-defined exceptions.Method 1: don't need initialization exception
create or replace procedure p1 as exc_p1 exception; begin do something .... -- fails Raise exc_p1; exception when exc_p1 then raise; end;
Method 2: use initialization exception
create or replace procedure p2 as exc_p2 exception; prgma exception_init(exc_p2,-20999); begin p1; exception when exc_p2 then raise; end;
The first method is used when you plan to raise user-defined errors by using the name, and user-defined errors are raised in the procedure you capture them.
The second method is used when you want to capture a specific error number, it's an error specific oracle (one that has not already been appointed) or a user defined error. In your example procedures, if we show what exceptions occur by putting in the debugging...
SQL> ed Wrote file afiedt.buf 1 create or replace procedure p1 as 2 exc_p1 exception; 3 begin 4 Raise exc_p1; 5 exception when exc_p1 then 6 dbms_output.put_line('P1:exc_p1'); 7 raise; 8* end; SQL> / Procedure created. SQL> SQL> create or replace procedure p2 as 2 exc_p2 exception; 3 pragma exception_init(exc_p2,-20999); 4 begin 5 p1; 6 exception 7 when exc_p2 then 8 dbms_output.put_line('P2:exc_p2'); 9 raise; 10 when others then 11 dbms_output.put_line('Other exception'); 12 raise; 13 end; 14 / Procedure created. SQL> set serverout on SQL> exec p2; P1:exc_p1 Other exception BEGIN p2; END; * ERROR at line 1: ORA-06510: PL/SQL: unhandled user-defined exception ORA-06512: at "SCOTT.P2", line 12 ORA-06512: at line 1
... we can see that the captured P1 procedure an exception defined by the user by his name, but procedure P2 could only recognize as being a mistake 'OTHERS '.
But if P1 were to raise a specific error number...
SQL> create or replace procedure p1 as 2 exc_p1 exception; 3 begin 4 Raise exc_p1; 5 exception when exc_p1 then 6 dbms_output.put_line('P1:exc_p1'); 7 raise_application_error(-20999,'Procudure 1 error raised',true); 8 end; 9 / Procedure created. SQL> exec p2; P1:exc_p1 P2:exc_p2 BEGIN p2; END; * ERROR at line 1: ORA-20999: Procudure 1 error raised ORA-06512: at "SCOTT.P1", line 7 ORA-06510: PL/SQL: unhandled user-defined exception ORA-06512: at "SCOTT.P2", line 9 ORA-06512: at line 1 SQL>
... then because P2 is looking for this under his own name of exp_p2 error number, he seized the exception thrown by P1 as is exp_p2 exception.
Now, just to complete the example...
SQL> create or replace procedure p1 as 2 exc_p1 exception; 3 pragma exception_init(exc_p1,-20999); 4 begin 5 Raise exc_p1; 6 exception when exc_p1 then 7 dbms_output.put_line('P1:exc_p1'); 8 raise; 9 end; 10 / Procedure created. SQL> exec p2; P1:exc_p1 P2:exc_p2 BEGIN p2; END; * ERROR at line 1: ORA-20999: ORA-06512: at "SCOTT.P2", line 9 ORA-06512: at line 1
... P1 has now associated with error number 20999 is exc_p1 exception, when he simply raises this exception is triggered 20999 error number. P2 is unable to capture under the name of exc_p1 because this exception name does exist in the process of P1, but because P2 seeks 20999 under his own name of exc_p2 exception, it manages to capture him.
So, to summarize, the name of the exception without the pragma is allowed to handle exceptions as part of the same name, but if you need capture outside the scope, you use the pragma to assign a number to it-specific exception.
Question2
Please let me know when and where to use these user-defined functions and I read the comments of Tom kyte on the use then than others, then raise or raise_application_error
User-defined exceptions are used mainly to treat logic errors. The key is the word "handful." If you can handle an exception (i.e. to do something) you should capture it and do what needs doing. If you can't handle it then, you have to trigger it.
Using a then "than others' exception should be a last resort. In general, you only manage exceptions that you plan to arrive. One then "than others' captures all exceptions that have not already been dealt with. If you have an exception "while others" and you do not throw the exception upward once again, then effectively hide you any errors to get noticed (errors are still happening, but you are not aware of them except for the fact that your "code does not work" or "data is not correct"). The only time you would really use one then "than others' exception would be if you need to connect all the errors in a table, but then after the cut, which should continue to be the exception to the calling code.exception management. Rather than use the raise or raise_application_error can I use "dbms_output.put_line (dbms_utility.format_error_backtrace); dbms_output.put_line (dbms_utility.format_error_stack)) 'or can I do the exceptions as handler below.
" when others then raise_application_error(-20001,'error in p1 '||dbms_utility.format_error_backtrace ||dbms_utility.format_error_stack); "
You should not use dbms_output.put_line, except for the purpose of debugging. To use that assumes that the output of the server is catches or displayed, which, if it is a backend process, it won't. The correct way to error log is a table, or at worst a file on the server.
If you need generate an application error and you want to keep the stack error, you just need the third parameter set to TRUE.
raise_application_error({errornumber},{message},true);
-
Variables, FPGA, defined by the user and SoftMotion 2012 + NOR 9505
Hello
To http://forums.ni.com/t5/Motion-Control-and-Motor-Drives/Softmotion-and-NI-950X-Module-Compatibility/... Nathan says:
NathanK wrote:
The glue code that connects Softmotion on FPGA LV code RT is called 'the axis interface. The version of the interface of the 2011 Softmotion axis necessary creation screw RT that exposes certain capabilities to Softmotion.
....
Improvements have been made in 2012 Softmotion who has removed the requirement to write RT live. Disclosure for the FPGA happens rather on the Variables (UDVs) user-defined. It is also possible to create a kind of axis 9501 for configuration of the module as well as an axis UDV generic for other completely custom 950 x modules or axes. It is not a specific example for the 9505 yet.
This caught my attention, as I'm trying to develop a system using LabVIEW SoftMotion 2012 and the NI 9505. I'm curious to see if there are alternative methods to write my application.
Where can I find more information on this 'generic UDV axis' and how to implement a? Nathan says "is not a specific example for the 9505 yet", but there are examples for the other modules - how similar/different are these modules from the 9505, and it involves a lot of effort to bring examples of the 9505?
Thank you!
Hi JKSH,
I have some relevant information that it is request that may be useful:
Working with Axes Variable defined by the user (NI SoftMotion Module)
Resource binding dialog box (NI SoftMotion)
Configuration OR SoftMotion Axes (OR SoftMotion Module)
Example that mentions of Nathan is the drive Stepper (9501) .lvproj (material Input and Output"Motion Control" NI SoftMotion"Device Specific" NI 950 x"OR 9501), I would take a peek at this on use of the UDVs.
-
How can I score points defined by the user in amplitude / frequency diagram?
I have a table of frequencies and amplitudes. I need these values to display frequency values on the x axis and axis is amplitude. a default fixed parcel must be constantly visible in the graph, and then I want to score a few points defined by the user in the same graph, save these two plots in the same graph and then make a mark on the chart.
Help kindly it's about my master of engineering project where I am trying to biuld an audiometer (to test hearing sensitivity) and I'll interface with microcontroller ardiuno labview and my hardware devices.
so kindly help.
Thank you.
rich
The points defined by the user might just be another plot. You can add annotations to a conspiracy, but it's a lot of work.
-
I can save is no longer shades defined by the user.
It's something I've done many times:
-create objects with the fill color > select > add the color group to illustration selected in the swatches Panel > click the menu library swatch in the swatches Panel and select "Save the nuances" in the drop-
This would normally take me to the exact location where I need to record a sample, defined by the user - something like: (user defined) / Library/Application Support/Adobe/Adobe Illustrator (version) /(defined language)/samples. I can see this site for a fraction of a second, before the file browser window switches back me on the directory of the user. The library is open is no longer in this dialog box.
I run two versions of Illustrator - CC and CS5 and oddly, it is the case in both, so I think the problem is Adobe - of - rights of library. I use a Mac, running OS X Yosemite 10.10.5.
To be clear, I did several times in the past and it worked. And I tried to restart the computer.
Any help/advice are welcome
OK, I solved the problem by chance, and I'll leave the solution here if someone has the same problem.
Namely, my Finder browser "save the file" has been on "Sort by date", and this mode will not access library. I went to "sort by name", and the library with user-defined shades reappeared. (Do not know what is the logic of this, but there you go).
-Ana
Maybe you are looking for
-
Thunderbird v. 24.4.0: Yahoo send does not
receiver works fine via the IMAP settings [using the Yahoo IMAP connector]The transmission does not work - I checked the password and the outgoing server settings are correct for the mail from yahoo. I am invited for the password when sending and see
-
Windows XP. Firefox 3.6.12. Java extensions console, AVG safe search, ADblocker plus, Deputy MS net framework.Was watching a video clip on PBS. Full screen. The video menu wouldn't go away. I have a click with the right button on the video screen, ch
-
FPGA acquires only the positive part of the signal
Hi all I have the NI USB-7855R and using the personality of DAQ balanced example of e/s (http://www.ni.com/example/5961/en/). I plugged my generator Agilent to AI0 (in mode CSR) and I have the following problems: (1) waveform graph in LabVIEW is only
-
HP ENVY 17 Notebook PC: HP ENVY 17 Touchpad problem
IDK if its supposed to be like that, which i dout it is, but the right side of my touch pad is lower than the left side. If you run your finger along the bottom of my touch pad, you can feel that buffer gets lower and the right side of the touchpad i
-
Firewire/ieee device not detected on both computers.
We have two PC with firewire ports and none of them connects to one of the two different cameras. Are trying to detect a Panasonic HVX 200 for example. Thanks in advance for any help that you can provide for these PCs to detect these cameras!