Limitations in using a function within a select statement
I have a function which retrieves various data elements from the
database and formats it accordingly. The data (varchar2)
returned could be in excess of 2,000 characters length.
I need to use the returned data as part of a view. I am able to
use the function in a "select" statement, but when I use it with
returned data in excess of 2,000 chars, I get the following
error:
ORA-06502: PL/SQL: numeric or value error
This error is occurring whenever the returned data is in excess
of 2,000 characters.
Is there an alternative method to what I am proposing, I have
tried alternative data types but if I am able to use it in a
"select" statement, I get the above error when the returned
length exceeds 2,000 chars.
Thanks
Peter
are u using oracle 7. varchar2 limit in 8 is 4000.
Similar Messages
-
DBMS_XMLQuery behavior when using stored function within cursor select
Consider the following SQL Statement
select t1.id
, t1.name
, cursor ( select t2.id
from tab t2
where t2.t1_id
= t1.id
and validate(t2.xyz,:bd1)
= 1
from tab t1
where t1.id = :bd2
DBMS_XMLQuery is used to create a context and to bind the appropriate values. In this case 'validate' is a stored function. I get the following error message upon execution:
ORA-29532: Java call terminated by uncaught Java exception:
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
Issuing a similar statement in SQL*Plus works fine. I was wondering whether this is a known issue when using a stored function in the cursor select statement in the context of DBMS_XMLQuery or whether I'm doing something wrong.Hi Jan,
This problem has been identified and fixed. The fix should be available in the next release. Thank you for bringing this up to our attention.
visar -
SQL query - how to get parameters into a function within a SELECT statement
Hi,
I have SQL query roughly as follows
SELECT A, B, C, MAX(CASE...) AS "D_NAME", FunctionX(B, C, "D_NAME")
FROM...
WHERE...
How to get alias "D_NAME" as a valid parameter into FunctionX?Hi,
user8819407 wrote:
Hi,
I have SQL query roughly as follows
SELECT A, B, C, MAX(CASE...) AS "D_NAME", FunctionX(B, C, "D_NAME")
FROM...
WHERE...
How to get alias "D_NAME" as a valid parameter into FunctionX?Either
(1) repeat the calculation or
(2) compute it in a sub-query
Here's an example of (2)
WITH got_d_name AS
SELECT A, B, C, MAX(CASE...) AS "D_NAME"
FROM...
WHERE...
SELECT A, B, C, D_NAME, FunctionX (B, C, D_NAME)
FROM got_d_name
;A column alias (like d_name) can be referenced in the ORDER BY clause of the query where it was defined, but that's the only place in that query where it can be referenced. -
Using Saxon Functions Within XSLT
Hi,
Please let me know how to use saxon functions within XSLT.
E.g.: If I want to implement saxon:base64Binary-to-string() function in XSLT in "xsl:value-of" function, then what will be the format for implementation.
I have selected the Processor as Saxon 8.9.0.3 (the one available) and using xmlns:saxon="http://saxon.sf.net/" in the xsl:stylesheet tag.
I am using Stylus Studio 2007 XML Enterprise Suite for XSLT.
Thanks,
Abhishek.Hi,
Yes I intended to use the XLST mapping within PI...but now will have to change the plan...is there any other way to do it?....is this the problem with the SP?.....anybody who can put more light on this topic.....
Thanks,
Abhishek. -
Can call a function in the select statement?
Is there any ways to call a function in the select statement?
what I like to do is this:
select deptno, totalEmployees(deptno), TotalSalary(deptno)
from emp;
I know it can be done by count(*) and join tables, but my case
is much more complex and the where clauses are different from
one function to another, and have many tables to join and many
combinations
ThanksFunctions can be used in a select statement subject to certain
restrictions, see
http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/
server.817/a85397/statem9b.htm#2062024
It's under "CREATE FUNCTION> Keywords and Parameters> function>
Restrictions on User-Defined Functions"
Here is an except...
When a function is called from within a query or DML statement,
the function cannot:
a) Have OUT or IN OUT parameters
b) Commit or roll back the current transaction, create or roll
back to a savepoint, or alter the session or the system. DDL
statements implicitly commit the current transaction, so a user-
defined function cannot execute any DDL statements.
c) Write to the database, if the function is being called from a
SELECT statement. However, a function called from a subquery in
a DML statement can write to the database.
d) Write to the same table that is being modified by the
statement from which the function is called, if the function is
called from a DML statement.
Except for the restriction on OUT and IN OUT parameters, Oracle
enforces these restrictions not only for the function called
directly from the SQL statement, but also for any functions that
function calls, and on any functions called from the SQL
statements executed by that function or any function it calls. -
Will a explain plan consider a function in a select statement.
Hi gurus,
I have a question regarding explain plan.
I ran a query, which returns me explain plan with multiple CPU costs around 300K.
now i use a function, and the number of lines displayed in explain plan reduces from 12 to 8 lines.
What i dont understand is.. Is the explain plan considering the function in the select statement ?
ex.
explain plan for
select column1,
column2,
function(value1)
from case
where case_no = 1will a explain plan consider the functions in a select statement ?
Thank you.What i dont understand is.. Is the explain plan considering the function in the select statement ?Maybe there are tweaks which reveal more information from the explain plan, but a straightforward way won't necessarily expose any function call:
SQL> create or replace function get_dname (i_deptno integer)
return varchar2
as
l_dname dept.dname%type;
begin
select dname
into l_dname
from dept
where deptno = i_deptno;
return l_dname;
end get_dname;
Function created.
SQL> explain plan
for
select ename, deptno, get_dname (deptno) dname
from emp
where deptno = 10
Explain complete.
SQL> select * from table (dbms_xplan.display ())
PLAN_TABLE_OUTPUT
Plan hash value: 3956160932
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5 | 45 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMP | 5 | 45 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("DEPTNO"=10)
13 rows selected.
SQL> truncate table plan_table
Table truncated.
SQL> explain plan
for
select ename, deptno
from emp
where deptno = 10
Explain complete.
SQL> select * from table (dbms_xplan.display ())
PLAN_TABLE_OUTPUT
Plan hash value: 3956160932
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5 | 45 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMP | 5 | 45 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("DEPTNO"=10)
13 rows selected. -
Using pop-up value in select statement
Hello.
I want to select a value from a pop-up box and then use that value in a select statement for another pop-up. Is that possible?
The first pop-up is P39_PIIN_CALL but it is not recognized in the second pop-up when I use it in the select statemnt... select * from table where PIIN = :P39_PIIN_CALL. I get nothing back because it has no idea what :P39_PIIN_CALL is. I'm desperate and on a timeline.
Thanks,
Mark EHi,
After fetching the value from first popup the page should submit so that the value is availble to the second popup..
Edit the first popup.. and in HTML Form Element Attributes and enter onchange="doSubmit('MyRequest')"
Regards,
Shijesh -
Use of cursors insted of select statements
could any one please explain what is the advantage of using cursors instead of simple select statements
thanks
sibyA benefit to using an explicit cursor rather than a select statement, is for the NO_DATA_FOUND exception. Its kind of like a free IF statment. IF no data is found, then stop.
if you write a select statement, and no data is returned, you SHOULD code for the NO_DATA_FOUND exception. Often people say, "i'll ALWAYS get a row returned". but you should always cover your code "just in case". so you must code an exception...
declare
v_var varchar2(1);
procedure do_something(p_parm varchar2) is
begin
null;
end do_something;
procedure log_error is
begin
null;
end log_error;
begin <<main>>
do_something('x');
begin <<selectblock>>
select dummy
into v_var
from dual
where dummy = 'a';
do_something(v_var);
exception
when no_data_found then
log_error;
end selectblock;
do_something (v_var||'abc');
end main;
if you use an explicit cursor instead, you don't need to code for the NO_DATA_FOUND. If an explicit cursor opens and finds no rows, there are simply no rows. of course, you don't need a loop if you expect only 1 row returned under normal circumstances.
BTW, don' forget that SQL%ROWCOUNT and your_cursor%ROWCOUNT are not initialized. There is a null, until a row is successfully fetched. therefore if no rows are returned at all, %ROWCOUNT is NULL.
declare
v_var varchar2(1);
cursor my_cur is
select dummy
from dual
where dummy = 'a';
procedure do_something(p_parm varchar2) is
begin
null;
end do_something;
procedure log_error is
begin
null;
end log_error;
begin << main>>
for cur_rec in my_cur loop
dbms_output.put_line('inside');
begin <<loop_block>>
if nvl(my_cur%rowcount,0) > 1 then
do_something(cur_rec.dummy);
else
log_error;
end if;
end loop_block;
end loop;
end main;
/ -
Using a function within a process flow...
Hi,
I'm trying to figure out a way of using a function (or something else) to return a status before attempting to run a mapping. I'd like to have a table with all my mappings, start date, end date, status, etc.
1. SELECT status FROM table, if the mapping has already been executed do nothing, else execute the mapping, etc.
Is there a way to accomplish that in OWB flow ?
Thank you.
GaétanHi,
We had a similiar set up in my previous role where we have a Process flow for each mapping. Under that processflow, before attempting to run the mapping we called function to check whether that particular mapping has been run successfully for that date. The function would take "PF Name" as an input and returns the status as 1 (return success - the mapping was not run, so has to be run today)
2 (return warning - the mapping is already run no need to run this time)
3 ( any fatal errors).
The function code is as below - _______________________________________________________
CREATE OR REPLACE FUNCTION "PUB_CHECK_RUN_STATUS"("IN_ETL_PROCESS_FLOW_NAME" IN VARCHAR2) RETURN NUMBER IS
--initialize variables here
lv_Current_Load_Id NUMBER;
lv_Last_Load_Id NUMBER;
BEGIN
<<Check_PF_Status>> -- This block is Standard for all Loads Jobs
BEGIN
SELECT LOAD_ID
INTO lv_Current_Load_Id
FROM LOAD_ADMIN.LATEST_LOAD;
SELECT LAST_COMPLETE_LOAD_ID
INTO lv_Last_Load_Id
FROM LOAD_ADMIN.ETL_PROCESS_FLOW
WHERE ETL_PROCESS_FLOW_NAME = in_ETL_Process_Flow_Name;
IF Lv_Last_Load_Id = lv_Current_Load_Id
THEN
-- This Process Flow has already been completed during this Load, so do not re-run
RETURN 2; -- Returns a Warning Status
ELSE
-- This Process Flow has not completed during this load, so need to run this now
RETURN 1; -- Returns a Success Status
END IF;
END Check_PF_Status;
EXCEPTION
WHEN OTHERS THEN
RETURN 3; -- Returns an Error Status
RETURN NULL;
END;
In the above code
LATEST_LOAD is a view which always returns one row with current load information (like load _id, start time etc)
ETL_PROCESS_FLOW is a table containing one row for each process flow with information like (execution status, load_id when it was execute )
You can modify to suit your requirements.
HTH,
Mahesh -
Why a function within a SELECT FROM DUAL is faster?
1)I have a SELECT with a function. Ex:
"SELECT DISTINCT function(...) FROM table"
2)I changed the SELECT and put the function inside a SUB-SELECT with FROM DUAL. Ex:
"SELECT DISTINCT (SELECT function(...) FROM DUAL) FROM table"
3)The second SELECT is faster than the first.
I discovered this problem on my tables and my functions. So I did a generic example for this forum with a common function and large table. My results:
Table has 2.196.058 records and the field is a VARCHAR2:
SELECT DISTINCT SUBSTR(field, 2) FROM Table -> Executed in 110 seconds
SELECT DISTINCT (SELECT SUBSTR(field, 2) FROM DUAL) FROM Table -> Executed in 39 seconds
Why "SELECT DISTINCT (SELECT function(...) FROM DUAL) FROM table" is faster than "SELECT DISTINCT function(...) FROM table"
thanks,
FernandoHi hoek,
I followed your informations and, sorry, I am more confused! I did an interesting example below.
1)I created a table:
CREATE TABLE T
name VARCHAR2(50)
); 2)I inserted 10 lines:
NAME
A
B
C
D
E
F
G
H
I
J 3)I created a function that returns the parameter concatenated with the current millisecond:
CREATE OR REPLACE FUNCTION f (param1 IN VARCHAR2) RETURN VARCHAR IS
BEGIN
return param1 || '-' || to_char(CURRENT_TIMESTAMP, 'FF');
END; 4)The query(A): SELECT f(name) AS col1, f(name) AS col2, f(name) AS col3 FROM t; gave me:
COL1 COL2 COL3
A-693786000 A-693887000 A-693941000
B-693989000 B-694017000 B-694043000
C-694071000 C-694097000 C-694124000
D-694153000 D-694180000 D-694206000
E-694235000 E-694261000 E-694287000
F-694316000 F-694341000 F-694367000
G-694396000 G-694422000 G-694448000
H-694477000 H-694503000 H-694529000
I-694557000 I-694583000 I-694609000
J-694638000 J-694664000 J-694690000If I repeat the SELECT, new values are generated.
4)The query(B): SELECT (SELECT f(name) FROM Dual) AS col1, (SELECT f(name) FROM Dual) AS col2, (SELECT f(name) FROM Dual) AS col3 FROM t; gave me:
COL1 COL2 COL3
A-253546000 A-253643000 A-253746000
B-253791000 B-253821000 B-253850000
C-253881000 C-253909000 C-253937000
D-253969000 D-253997000 D-254026000
E-254057000 E-254085000 E-254113000
F-254145000 F-254173000 F-254202000
G-254232000 G-254261000 G-254289000
H-254320000 H-254348000 H-254376000
I-254407000 I-254436000 I-254464000
J-254495000 J-254523000 J-254551000The result generated new values too.
5)I changed the function and I put the DETERMINISTIC clause:
CREATE OR REPLACE FUNCTION f (param1 IN VARCHAR2) RETURN VARCHAR DETERMINISTIC IS
BEGIN
return param1 || '-' || to_char(CURRENT_TIMESTAMP, 'FF');
END; 6)I repeated the queries(A) and (B) and the result has generated different values. Then, with the DETERMINISTIC clause, the result has not changed
7)I changed the function and I put the RESULT_CACHE clause:
CREATE OR REPLACE FUNCTION f (param1 IN VARCHAR2) RETURN VARCHAR RESULT_CACHE IS
BEGIN
return param1 || '-' || to_char(CURRENT_TIMESTAMP, 'FF');
END;8)I repeated the query(A) and now, the result was different:
COL1 COL2 COL3
A-381048000 A-381048000 A-381048000
B-381242000 B-381242000 B-381242000
C-381322000 C-381322000 C-381322000
D-381400000 D-381400000 D-381400000
E-381481000 E-381481000 E-381481000
F-381556000 F-381556000 F-381556000
G-381634000 G-381634000 G-381634000
H-381815000 H-381815000 H-381815000
I-381895000 I-381895000 I-381895000
J-381971000 J-381971000 J-381971000The line columns are equals and if I repeat the SELECT, all the result is the same too. The query(B) returned the same result like the query(A)! Now I see the cache in action!
After the tests, I concluded that the function in the subquery doesn't use cache and it is faster than the normal function. The mistery continues... -
Trouble using pipelined function in an select list lov query
I'm trying to use a pipelined function in a select list lov query but i cet the error
"LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query."
my query is as follows :
SELECT gt.navn d, gt.GEOGRAPHY_TYPE_ID r
FROM GEOGRAPHY_TYPE gt
WHERE gt.kode NOT IN (1)
and gt.kode in (select lov_value from table(RAPPORT_FILTER_PKG.GET_RAPPORT_FILTER_VALUE_PIP (
SYS_CONTEXT ('rapport_filter_ctx','filter_id'),'GEOGRAPHY_TYPES')) )
ORDER BY gt.navn DESC
if i use a discrete values '80' instead of the call to
SYS_CONTEXT ('rapport_filter_ctx','filter_id')
i don't get eny errors, but then the LOV isn't as dynamic as i has to be
any idears???
Edited by: [email protected] on Dec 1, 2008 8:50 AM
Edited by: [email protected] on Dec 1, 2008 11:17 AMnope that doesn't do it either
contains a syntax errror at
SYS_CONTEXT (('rapport_filter_ctx',:P500_RAPPORT_FILTER_ID),'GEOGRAPHY_TYPES'))
my theory is that it's got something to do with the way APEX binds values because
the query
SELECT gt.navn d, gt.GEOGRAPHY_TYPE_ID r
FROM GEOGRAPHY_TYPE gt
WHERE gt.kode NOT IN (1)
and gt.kode in (select r from table(RAPPORT_FILTER_PKG.GET_RAPPORT_FILTER_VALUE_PIP ('80','GEOGRAPHY_TYPES')) )
ORDER BY gt.navn DESC
works fine in both TOAD and in APEX but as soon as i replace th '80' with :P500_RAPPORT_FILTER_ID then, apex won't accept the code??????
Edited by: [email protected] on Dec 3, 2008 7:54 AM -
Return multiple values from a function to a SELECT statement
I hope I've provided enough information here. If not, just let me know what I'm missing.
I am creating a view that will combine information from a few tables. Most of it is fairly straightforward, but there are a couple of columns in the view that I need to get by running a function within a package. Even this is fairly straightforward (I have a function named action_date in a package called rp, for instance, which I can use to return the date I need via SELECT rp.action_date(sequence_number).
Here's the issue: I actually need to return several bits of information from the same record (not just action_date, but also action_office, action_value, etc.) - a join of the tables won't work here as I'll explain below. I can, of course, run a separate function for each statement but that is obviously inefficient. Within the confines of the view select statement however, I'm not sure how to return each of the values I need.
For instance, right now, I have:
Table1:
sequence_number NUMBER(10),
name VARCHAR(30),
Table2:
Table1_seq NUMBER(10),
action_seq NUMBER(10),
action_date DATE,
action_office VARCHAR(3),
action_value VARCHAR(60),
I can't simply join Table1 and Table2 because I have to do some processing in order to determine which of the matching returned rows I actually need to select. So the package opens a cursor and processes each row until it finds the one that I need.
The following works but is inefficient since all of the calls to the package will return columns from the same record. I just don't know how to return all the values I need into the SELECT statement.
CREATE VIEW all_this_stuff AS
SELECT sequence_number, name,
rp.action_date(sequence_number) action_date,
rp.action_office(sequence_number) action_office,
rp.action_value(sequence_number) action_value
FROM table1
Is there a way to return multiple values into my SELECT statement or am I going about this all wrong?
Any suggestions?
Thanks so much!Hi,
What you want is a Top-N Query , which you can do using the analytic ROW_NUMBER function in a sub-query, like this:
WITH got_rnum AS
SELECT action_seq, action_dt, action_office, action_type, action_value
, ROW_NUMBER () OVER ( ORDER BY action_date
, action_seq
, action_serial
) AS rnum
FROM table2
WHERE action_code = 'AB'
AND action_office LIKE 'E' -- Is this right?
SELECT action_seq, action_dt, action_office, action_type, action_value
FROM got_rnum
WHERE rnum = 1
;As written, this will return (at most) one row.
I suspect you'll really want to get one row for each group , where a group is defined by some value in a table to which you're joining.
In that case, add a PARTITION BY clause to the ROW_NUMBER function.
If you'd post a little sample data (CREATE TABLE and INSERT statements), I could show you exactly how.
Since I don't have your tables, I'll show you using tables in the scott schema.
Here's a view that has data from the scott.dept table and also from scott.emp, but only for the most senior employee in each department (that is, the employee with the earliest hiredate). If there happens to be a tie for the earliest hiredate, then the contender with the lowest empno is chosen.
CREATE OR REPLACE VIEW senior_emp
AS
WITH got_rnum AS
SELECT d.deptno
, d.dname
, e.empno
, e.ename
, e.hiredate
, ROW_NUMBER () OVER ( PARTITION BY d.deptno
ORDER BY e.hiredate
, e.empno
) AS rnum
FROM scott.dept d
JOIN scott.emp e ON d.deptno = e.deptno
SELECT deptno
, dname
, empno
, ename
, hiredate
FROM got_rnum
WHERE rnum = 1
SELECT *
FROM senior_emp
;Output:
. DEPTNO DNAME EMPNO ENAME HIREDATE
10 ACCOUNTING 7782 CLARK 09-JUN-81
20 RESEARCH 7369 SMITH 17-DEC-80
30 SALES 7499 ALLEN 20-FEB-81
By the way, one of the conditions in the query you posted was
action_office LIKE 'E'which is equivalent to
action_office = 'E'(LIKE is always equivalent to = if the string after LIKE doesn't contain any wildcards.)
Did you mean to say that, or did you mean something like this:
action_office LIKE 'E%'instead? -
How to pass an array to a function from a SELECT statement
Hi all. I have a problem with passing an array to a function directly from a SELECT statement.
Here is what I want. If I have a function
function AAA(arrayVar <ArrayType>) return number;
I want to be able to call this function this way
select AAA((2,3,4))
from dual
or this way
select AAA((10,12))
from dual
In other words I want to be able to pass an arbitrary number of numbers to the function. And I want this to work in a SELECT statement.
Does anyone have any ideas how to implement this? What <ArrayType> should I use?(I've read about VARRAY, nested tables in the Oracle documentation but as far as I've understood these array types are meant to be used within PL/SQL blocks).
I found only this http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:208012348074 through Google but it didn't help me.
Thank you in advance.> What <ArrayType> should I use?
SQL data types - as 3360 showed above. You cannot use PL/SQL structures and user types in the SQL Engine.
You can however use all SQL structures and types in PL/SQL.
Arrays in SQL is created as collection type - basic o-o. The collection type (or class) serve as a container for instantiated objects or scalar type.
This is covered in detail in [url http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14260/toc.htm]
Oracle® Database Application Developer's Guide - Object-Relational Features -
Calling a user defined function in a select statement
PLS-00231: function 'F_GET_PROJECT_ID' may not be used in SQL
I am caling a user defined function 'F_GET_PROJECT_ID' in a select statement and getting the above error .
Can any one help me to resolve it.
I can not replace the function with a local variable nor can I assign the output of the function to a variable and use the variable in the sql stmt. cos, the in put parameters of the function comes from the same select statement.
Please help
Thanks in advanceCan you provide your function code? Using a function like that is possible from the below example. I suspect something in your function code.
SQL> create or replace function sample_func(p_sal number)
2 return number
3 is
4 v_sal number;
5 begin
6 v_sal := p_sal+100;
7 return v_sal;
8 end;
9 /
Function created.
SQL>
SQL> select empno, ename, sal, sample_func(sal)
2 from emp
3 /
EMPNO ENAME SAL SAMPLE_FUNC(SAL)
7839 KING 5000 5100
7698 BLAKE 2850 2950
7782 CLARK 2450 2550
7566 JONES 2975 3075
7654 MARTIN 1250 1350
7499 ALLEN 1600 1700
7844 TURNER 1500 1600
7900 JAMES 950 1050
7521 WARD 1250 1350
7902 FORD 3000 3100
7369 SMITH 800 900
7788 SCOTT 3000 3100
7876 ADAMS 1100 1200
7934 MILLER 1300 1400
14 rows selected.
SQL>And yeah... your formatted code is this.
cursor c1 is
SELECT t.upi_nbr upi_nbr,
f_get_project_id(l.pay_type_code,
l.charge_type_nme,
l.charge_code) project_id,
LAST_DAY(TO_DATE(SUBSTR(t.Year_Month, 5, 2)||'/'||'01'||'/'||SUBSTR(t.Year_Month,1,4),
'MM/DD/YYYY'))reporting_period_end_date,
SUM (c.hours_worked_qty) reported_hrs
from trs.trs_timesheet@oraprod5 T,
trs.trs_line@oraprod5 L,
trs.trs_cell@oraprod5 C
where T.upi_nbr=L.upi_nbr
and T.year_month=L.year_month
and L.row_nbr=C.row_nbr
and L.upi_nbr=C.upi_nbr
and L.year_month = C.year_month
and L.invalid_activity_ind = 'V'
and rtrim(L.charge_code) is not null
AND L.Pay_Type_Code<>'REQ'
and C.Hours_Worked_Qty > 0
GROUP BY t.upi_nbr,
t.year_month,
t.oui_nbr,
l.charge_code,
l.activity_detail_code,
l.charge_type_nme,
l.pay_type_code;Cheers
Sarma. -
Apex_util.prepare_url within a select statement
APEX Version: 3.1.2.00.02
Need help with embedding APEX_UTIL.PREPARE_URL in select statement. Unable to reference column name as a bind variable...or it allows as in code below, but no values are included in the URL. Using PREPARE_URL so checksum is created.
URL created:*
https://.../f?p=108:90:623968923157010::NO::P90_RID:&cs=3CB12F3B467B3989B51377487817BDB08
Note: href >> replaced with >> hrf
declare
q varchar2(32767); -- query
w varchar2(4000) ; -- where clause
we varchar2(1) := 'N'; -- identifies if where clause exists
begin
q := 'select "RID", '||
' "EMPLOYEE_NO", '||
' InitCap(first_name)||
'||''' '''||
'||InitCap(last_name) as "Name", '||
' "HIRE_DATE", '||
' "JOB_TITLE", '||
' CASE '||
' WHEN CORRECTION_IND = 'X' '||
' THEN ''<a hrf="' ||
apex_util.prepare_url('f?p='||:APP_ID||':90:'||:APP_SESSION||'::'||:DEBUG||'::P90_RID:'||:RID) ||
'">Correction</a>'' ' ||
' ELSE NULL '||
' END CORRECTED '||
' from "#OWNER#"."EMPLOYEE_TABLE" ';
if :P28_FIRST_NAME IS NOT NULL
then
w := w || ' AND first_name LIKE UPPER(:P28_FIRST_NAME||'||'''%''' ||')' ;
we := 'Y';
end if;
if :P28_LAST_NAME IS NOT NULL
then
w := w || ' AND last_name LIKE UPPER(:P28_LAST_NAME||'||'''%''' ||')' ;
we := 'Y';
end if;
if we = 'Y'
then q := q || w;
end if;
return q;
end;Edited by: JSandoval on May 25, 2011 1:03 PMI think that the problem is that the function apex_util.prepare_url is executed building the "q" variable, not during query execution. (you have to try to quote it ...)
I often use the "Query from function".
There a couple of things that helps me:
- I always put in the page an item PXX_SHOW_SQL(checkbox) visible only to administrator (a user setting in my application...).
Before the "return q" put a htp.p(q) if this Item is not null. So you can see the actual SQL (often helps reformattig the output with SqlDeveloper)
- I'm became crasy tring to quote complex query ... Now I write the query code in a TABLE
Example AUXSQL(APP_ID number,APP_PAGE number, PRG number, sql VARCHAR2(4000))
More "PRG" if more than 4000 chars. (I start in this way, but someone use CBLOB ...)
I find this very usefully!!
Thanks
Stefano Corradi
Maybe you are looking for
-
Hi, We bought an Nvidia Quadro 4000 for Mac for use RayTrace on After Effects CS6 (11.0.2) with our Mac Pro 5.1 on OS 10.6.8. And the Mac lost the Cuda driver when we restart it. We use the Nvidia driver 256.02.25f01 for Mac Os 10.6.8 and we made tes
-
I dragged my url to customize toolbar, now my url is gone, how do I get it back?
I mistakenly dragged my url into the customize toolbar, thinking I'd at it to my Favorites, but, it totally disappeared, how do I get it back? I tried all the suggestions I read elsewhere, but, they didn't work.
-
SetBackground color not working
Hello, While viewing my applet from within a HTML file, my background color is still grey, except the buttons. The color is fine while viewing with appletviewer so I'm a bit confussed. Any ideas as to why would be appreciated. Thanks in advance. impo
-
Can't re-install after uninstall
I was told by the developer of an App Store app to uninstall + re-install his app, iNet. After uninstalling + re-starting, my App Store shows that the app is installed, even though it's not listed in my Applications. How can I re-install?
-
Reflect changes in editable cell in subtotal/total row...
Hello Experts, I have one editable column in my OO ALV grid(cl_gui_alv_grid) and what I want is that after entering a value in a given cell, I want that value to be reflected in my subtotal and total row. Also, How come when I enter a value lets say