Report- Pl/sql function returning sql query parsing page items as text?
Hi Team,
I am facing a strange issue .
I have four page items namely
1)JOB_CODE
2)MIN_EXP
3) MAX_EXP
4) SOURCES1
I have a report of the type "Pl/sql function returning sql query"
declare
v_sql varchar2(4000);
begin
if (:JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql:= 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:JOB_CODE IS NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:MIN_EXP IS NULL and :JOB_CODE IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years <= :MAX_EXP and V_REQUIREMENT = :JOB_CODE and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:MAX_EXP is null and :JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
end if;
insert into query_list values (v_sql);
insert into debug values (:JOB_CODE , :MIN_EXP , :MAX_EXP , :SOURCES1);
return v_sql;
end;
Please not that I am insertin the query into a table called Query_list and the page item values into the table called Debug thru the pl/sql function which returns teh query.
Now I select the data from the debug tables.
select unique(query) from query_list;
select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like '%:SOURCES1%'
select * from debug;
JOBCODE MINEX MAXEX SOURCE
21 1 10 donkeyHire
And if I run the query in sql I get some records returned
select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = 21 and v_experience_years >= 1 and v_experience_years <= and source like 'donkeyHire'
V_CANDIDATE_ID V_FNAME V_CURRENT_EMPLOYER V_EXPERIENCE_YEARS
2 Vengu Andale Tech 4
But the record does not show up in the report!
does this type of report parse page items as text?
Why is it so?
Waiting for an early reply.
Thanks,
venkat
Venkat - You don't want to put ':SOURCES1' in quotes like that.
Scott
Similar Messages
-
On Submit process not firing -report (PL/SQL function returning SQL query)
Can anyone suggest possible causes / solutions for the following problem?
I have a report region that uses a PL/SQL function returning SQL query. The report allows the user to update multiple fields / rows and then click a button to submit the page which should run the On-Submit process to update the database. However the process does not run and I get a 'HTTP404 page cannot be found' error; and when I navigate back using the Back button I cannot then navigate to any other page in my application without getting the same error. The button was created by a wizard selecting the options to submit the page and redirect to a (same) page. The button does not actually have a redirect in its definition but the wizard created a branch to the same page which should work and the button has the text 'submit as SUBMIT' next to it so it appears to be set up correctly.
I have recreated this page several times in my application and I cannot get the On-Submit process to run. However I have created a cut down version of the same page in the sample application on apex.oracle.com at http://apex.oracle.com/pls/otn/f?p=4550:1:179951678764332 and this works perfectly so I am at a loss to understand why it does not work in my application. I cannot post any part of the application itself but if anybody would like to check out page 30 of the sample application (Customer Update Test tab) updating the surnames only, using credentials ja, demo, demo this is pretty much what I have got in my application.
Any ideas would be much appreciated?Thanks for the suggestions guys. I have now identified that the problem goes away when I remove the second table from my report query. The original report query retrieved data from two tables and the process was updating only one of the tables. I thought I had approached the task logically i.e. first get the report to display the records from the two tables, then get the process to update the first table and finally to modify the process further to update the second table.
Can anyone point me to an example of multiple row updates on multiple tables using a PL/SQL function returning an SQL query? -
Issue with running PL/SQL function returning Sql query
hi, I am trying to create a report region by using the option of PL/SQL function returning sql query.
I notice that it's very slow for the report region page to show up. In my PL/SQL function body, there are only 3 steps, first update all the 10 rows of varchar2 fields to null,then insert values to those fields, then select all from the table to show report results. It takes more than 5 minitues for the page to load up, how ever, if i run those steps in SQL*Plus, it only takes a couple of seconds to finish. Any suggestions?
Thanks,
ginaSergio, the codes are as followed,
Declare
q varchar2(32767); -- query
Begin
q := 'select "ID",'||
'"ENTRY NAME","TOTAL","#CM","%CM","#CA",'||
'"%CA", from Info_table';
update info_table
set "TOTAL" = '',
"#CM" = '',
"%CM" = '',
"#CA" ='',
"%CA"=''
where "ID"<=10;
// set all data in column Total to null,there is only 10 rows in the table
update info_Table set Total = vTotal,
"#CM" = vCM
(those variables hold user key-in Text filed value)
where ID = 1;
return q;
End; -
SQL Query(PL/SQL Function Returning SQL Query)
I am trying to write a dynamic report using SQL Query(PL/SQL Function Returning SQL Query).
I can get the report to run but I need to concatinate some columns into one, seperated by a comma or a dash.
I have tried select *****||','||***** alias
also select *****||'-'||***** alias
but I always get an error.
Is there a way of doing this please
GusThis is my full query
declare
v_query varchar2(4000);
begin
if :P63_TRAN_INFO = 2 THEN
v_query := 'select
A.FILENR,
A.EXERCISENAME,
A.STARTDATE,
A.ENDDATE,
A.UNIT,
A.ACCADDRESSES, B.ADDRESS, B.ADDRESS_1, B.POST_CODE, B.TOWN,
A.EXERCISEAREAS,
A.TOTALVEHICLES,
A.TOTALTROOPS+A.RNTOTALTROOPS+A.RAFTOTALTROOPS TOTALTROOPS,
A.CAR, A.MINIBUS, A.HGV,
A.NAMERANK, A.ADDRESS, A.ADDRESSI, A.ADDRESSII, A.POSTCODE,
A.TRANSIT,
A.INFOONLY
from BFLOG_AT A, BFLOG_ACCADDRESS B
WHERE A.ACCADDRESSES = B.NAME
AND A.STARTDATE >= :P63_START_DATE
AND A.ENDDATE <= :P63_END_DATE
AND A.AUTHORISED = 1
AND A.INFOONLY = 1' ;
END IF;
RETURN v_query;
END;
This query runs ok, but if I try changing it to the code below with fields concatinated, then it fails
declare
v_query varchar2(4000);
begin
if :P63_TRAN_INFO = 2 THEN
v_query := 'select
A.FILENR,
A.EXERCISENAME,
A.STARTDATE,
A.ENDDATE,
A.UNIT,
A.ACCADDRESSES||','||B.ADDRESS||','||B.ADDRESS_1||','||B.POST_CODE||','||B.TOWN ADDRESS,
A.EXERCISEAREAS,
A.TOTALVEHICLES,
A.TOTALTROOPS+A.RNTOTALTROOPS+A.RAFTOTALTROOPS TOTALTROOPS,
A.CAR, A.MINIBUS, A.HGV,
A.NAMERANK, A.ADDRESS, A.ADDRESSI, A.ADDRESSII, A.POSTCODE,
A.TRANSIT,
A.INFOONLY
from BFLOG_AT A, BFLOG_ACCADDRESS B
WHERE A.ACCADDRESSES = B.NAME
AND A.STARTDATE >= :P63_START_DATE
AND A.ENDDATE <= :P63_END_DATE
--AND (A.EXERCISEAREAS LIKE "GAP, OA, OAL")
--OR (A.EXERCISEAREAS LIKE "Harz")
AND A.AUTHORISED = 1
AND A.INFOONLY = 1' ;
END IF;
RETURN v_query;
END;
Cheers
Gus -
Column order in SQL Query (PL/SQL function returning a query)
Hi,
when I define a PL/SQL function returning a query inside a region, I often find that the column order is arbitrarily changed.
How do I enforce the column order ?
Bye,
FlavioI removed the 11th column called service_name from this dynamic query: and now the report says: report error:
ORA-01403: no data found. I messed around with the Headiuns Type. It was set to Custom. I changed it to Column Names. There is no difference.
I am not sure how to fix?
declare topqry varchar2(32000);
whereqry varchar2(32000);
finalqry varchar2(32000);
var_status varchar2(100);
division_status varchar2(50);
office_status varchar2(1000);
user_status varchar2(1000);
overdue_status varchar2(1000);
begin
if :P10_FALLBACK = 'All' then
var_status:= ' and vp.status in (''FA'',''FBA'',''FBI'',''25%'',''50%'',''90%'',''Closed'') ';
elsif :P10_FALLBACK = 'Active' then
var_status:= ' and vp.status in (''FA'',''25%'',''50%'',''90%'',''FBA'') ';
elsif :P10_FALLBACK = 'FB' then
var_status:= ' and vp.status in (''FBA'',''FBI'') ';
elsif :P10_FALLBACK = 'Closed' then
var_status:= ' and vp.status in (''Closed'') ';
elsif :P10_FALLBACK = 'Inactive' then
var_status:= ' and vp.status in (''FBI'') ';
end if;
if :P10_DIVISION = 'All' then
division_status:= ' and vp.vms_division in (''News'',''Ad Services'') ';
elsif :P10_DIVISION = 'News' then
division_status:= ' and vp.vms_division in (''News'') ';
elsif :P10_DIVISION = 'Ad' then
division_status:= ' and vp.vms_division in (''Ad Services'') ';
end if;
if :P10_OFFICE = '%' then
office_status:= ' and OFFICE_ID in (select office
from VMS_OFFICE_ACCESS
where user_id = lower(:P0_user) ) ';
else
office_status:= ' and OFFICE_ID in :P10_OFFICE ';
end if;
if :P10_LIMIT_USER = '%' then
user_status := ' and SALESPERSON in (select first_name || '' '' || last_name
from VMS_PROSPECT_users u
join vms_office_access o
on u.office_id = OFFICE
where o.user_id = lower(:P0_USER) ) ';
else
user_status:= ' and SALESPERSON in (:P10_LIMIT_USER ) ';
end if;
if :P10_SHOW_OVERDUE = 'Show' then
overdue_status:= ' and target_close_date <= sysdate ';
var_status:= ' and vp.status in (''25%'',''50%'',''90%'',''FBA'') ';
else
overdue_status:= ' and FIRST_APPOINTMENT between
nvl(to_date(:P10_FIRST_APPT_START, ''mm/dd/yyyy''),FIRST_APPOINTMENT) and
nvl(to_date(:P10_FIRST_APPT_END,''mm/dd/yyyy''),FIRST_APPOINTMENT) ';
end if;
topqry := 'SELECT OFFICE_ID ,vp.PROSPECT_ID ,ENTRY_DATE ,ACCOUNT , NEXT_CONTACT_DATE ,ACTION_STEP ,
TARGET_CLOSE_DATE ,vp.STATUS ,SALESPERSON ,vp.SALES_TYPE ,service_name , FIRST_APPOINTMENT ,MODIFY_DATE ,EST_ANNUAL_REVENUE ,EST_INCREMENTAL_REVENUE ,
pi.NOTES , pi.SALES_TYPE ,pi.STATUS ,Contact ,Origin_Source FROM VMS_PROSPECTING_ITEMS pi right outer join VMS_PROSPECTS vp on vp.PROSPECT_ID = pi.PROSPECT_ID left outer join VMS_SERVICES vs on vs.service_ID = pi.service_ID where 1 = 1 ';
whereqry := ' and (not exists (select *
from VMS_PROSPECTING_ITEMS i3
where vp.prospect_id = i3.prospect_id)
or exists (select *
from VMS_PROSPECTING_ITEMS i2
where i2.order_id = pi.order_id
and active = ''Y'' )) and instr(upper(ACCOUNT),upper(nvl(:P10_ACCOUNT,ACCOUNT))) > 0 ';
whereqry := whereqry || var_status || division_status || office_status || user_status || overdue_status;
finalqry := topqry || whereqry;
return finalqry ;
end; -
I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
Here is my dilemma:
I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
Thank you,
Tony Miller
UTMB/EHN
Title changed, maybe SOMEONE has an idea on this??
Message was edited by:
Tony MillerHi,
1/ first check you are passing the bind variables and
appropriate values in the call to your report - if
the query returns no data then you get an empty page
So if your query takes :P10_USERNAME variable then
pass it to the report in the URL
f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=YOUR_REP_QUERY_N
AME:::P10_USERNAME:MYUSER
2/ try to use the Default layout first to check your
report query really returns the data when called
3/ if you defined a header in your rtf template check
there is no & (ampersand) - if using & in the header
and preview the template from word it displays data
OK, but if you use this template in the report query
it fails to render the data (bug in Apex-> Bi
Publisher integration maybe?)
4/ If using the table in the rtf template check its
width does not overflow the page margins - there is a
problem with pdf export
5/ check
/oc4j/j2ee/home/application-deployments/xmlpserver/app
lication.log forthe information on BI Publisher runs
RadoIssue was in the APEX page having issues.. I recoded a new page and am able to generate BI Publisher based PDF files..
Thank you,
Tony Miller
UTMB/EHN -
Conditional display of region with PL/SQL function returning SQL query
Hello,
ApEx 2.0.
I use PL/SQL functions that return SQL queries to display the contents of a region.
How could I conditionally display such region ? If no data is found, the region shouldn't be shown. I tried with "SQL query returns at least one row" but this doesn't seem to work.
Thanks,
MatthiasHi Matthias,
Are the regions in question report regions? So your PL/SQL process is returning a SQL query and then populating a report?
The EXISTS(SQL Query returns at least one row) condition should work, try running the query you are using in the Expression 1 textarea inside SQL*Plus, or SQL developer using the same parameters, and see what gets returned.
If you are still stuck, can you post the query you are using inside your Expression 1 textarea of the Conditions section and I can take a look at it for you.
Hope this helps,
Cj -
SQL Query problem (PL/SQL function returning SQl query)
I am using 3.1.2 Apex. When I create the region source with the following code.
DECLARE
l_sql VARCHAR2(32767);
X1 VARCHAR2(9);
X2 VARCHAR2(9);
X3 VARCHAR2(9);
X4 VARCHAR2(9);
X5 VARCHAR2(9);
X6 VARCHAR2(9);
X7 VARCHAR2(9);
X8 VARCHAR2(9);
BEGIN
SELECT decode(:P3_FAILED_CDD,'0','0','1','1', '2','2' ) INTO X2
FROM DUAL;
SELECT decode(:P3_Order_status,'J','J','1','1','2') INTO X3
FROM DUAL;
SELECT decode(:P3_FAILED_STAGE,'0','0','1','1','2') INTO X4
FROM DUAL;
SELECT decode(:P3_ORDER_TYPE,'TYPE1','TYPE1','TYPE2','TYPE2','2') INTO X5
FROM DUAL;
SELECT decode(:P3_INCLUDE_SFIN,'NO','NO','YES','YES') INTO X6
FROM DUAL;
SELECT decode(:P3_CDD_MATCH,'0','0','1','1', '2','2' ) INTO X7
FROM DUAL;
SELECT decode(:P3_FIELD,'0','0','1','1', '2','2' ) INTO X8
FROM DUAL;
l_sql := 'SELECT
ORDER_NR,
FNN,
ST,
SOT,
STAGE,
CUST_NAME,
STG_DAYS,
ZONE,
P1.OWNER,
QUEUE_A,
STG_LFD,
LFD_LEFT,
CIJ_FLAG,
FST_FLAG,
CCD_COUNT,
TCD_COUNT,
LATEST_RET_CODE,
CRD,
CDD_DATE,
CRD_LEFT CDD_LEFT,
TCD_DATE RTCD_DATE,
PROP_TCD_DATE TCD_DATE,
PROJECT_ID,
APPLN_TBO,
CO_ORD_ID,
CON_WSTN,
P1.STATE,
A_DTB,
B_DTB,
DESIGN_NO,
CREATE_DATE,
DATE_APPLN,
CUSTOMER_ID,
SALES_QUEUE,
TRACKING_NR,
WORK_REQUIRED,
SFIN_STAGE_ENTERED_DATE,
APPLN_CONTACT_OFFICER,
A_LOCATION_ADDRESS,
B_LOCATION_ADDRESS,
SO_CREATE_USERID,
OP_SEP,
WMC_CODE
FROM RASS_TICKET_VIEW P1
WHERE WMC_CODE like :p3_wmc_code
AND ST in (SELECT SYSTEM_ID from PRDRF where PRODUCT_CATEGORY like :p3_product_cat)';
IF X2 = '0' then
l_sql := l_sql || ' and CRD_LEFT < 0';
END IF;
IF X2 = '1' then
l_sql := l_sql || ' and CRD_LEFT >= 0';
END IF;
IF X3 = 'J' then
l_sql := l_sql || ' and CIJ_FLAG = ''J''';
END IF;
IF X3 = '1' then
l_sql := l_sql || ' and CIJ_FLAG is null';
END IF;
IF X4 = '0' then
l_sql := l_sql || ' and LFD_LEFT < 0';
END IF;
IF X4 = '1' then
l_sql := l_sql || ' and LFD_LEFT >= 0';
END IF;
IF X5 = 'TYPE1' then
l_sql := l_sql || ' and SOT in (''NEW'',''NET'',''ERT'',''UGP'')';
END IF;
IF X5 = 'TYPE2' then
l_sql := l_sql || ' and SOT not in (''NEW'',''NET'',''ERT'',''UGP'')';
END IF;
IF X6 = 'NO' then
l_sql := l_sql || ' and STAGE in (''DSAL'',''DPLO'',''OISS'',''TRPB'',''OTST'',''TEQP'',''DSPS'')';
END IF;
IF X7 = '0' then
l_sql := l_sql || ' and PROP_TCD_DATE <= CDD_DATE';
END IF;
IF X7 = '1' then
l_sql := l_sql || ' and PROP_TCD_DATE > CDD_DATE';
END IF;
RETURN l_sql;
END;
The query returns data.
If I add some more code just after the where clause.
AND decode(CUST_CODE,'TW','TW','RET') like (select decode(OPS_SEP,'TS','%',OPS_SEP) from T_U_CDW_BU_OP_SEP where upper(USER_ID) = upper(:APP_USER))
The query just stops working and no error message is returned.
I thought there was an issue prior to version 3.1.2 that was fixed in version 3.1.2
Othwerwise is there a better way to write the code? As I have 7 radio btn's that control the condition within the where clause.
Thanks
Ron>
bug in APEX 3.0
>
Are you sure?
Do as Paul has suggested and post the code that doesn't work (including your extra line) using the {noformat}{noformat} tags +exactly+ as you had it in the region source.
Cheers
Ben -
Plugin with PL SQL function returning query
Hi all,
I have created plugin using SQL query many times. But can we create a plugin from scratch using PL SQL function returning SQL query? Any ideas or sample.
Thanks
Sunil BhatiaHi Scott,
By this i mean, i have created a region type plugin for integrating jqx Grid into oracle apex. This takes input parameter as SQL statement, and creates jqx grid for me on page. Now my question is, can i do this using PL SQL function returning SQL, because when i try to give return statement, plugin gives error "SQL statement mandatory'. I hope i am clear enough now.
Thanks
Sunil Bhatia -
Interactive Report based on a function returning SQL query?
Hi guys!
I'm wondering if the IR based on a function returning SQL query will be available on the final release of APEX 4.0..I can't see this functionality in EA1 and EA2 and I think it should be there..dont you think?
With regards,
PsmakRHi!
You're absolutely sure you're talking about the Interactive Report region and not about the default SQL Report region ?
With regards,
PsmakR -
Function returning SQL query for mutiple series in a chart
Hi,
I would like to know if there is a way to specify a single PL/SQL function returning the queries for multiple series in a 2D Line Flash Chart. I have multiple series in my chart that has different values in the where clause. I can write a PL/SQL function that can return all these queries in one shot. Is there anyway that I can specify this function as returning the queries for all the series in the chart?
As an example, assume that I am using the following three queries for the series in my chart:
select deptno, count(*) from emp where deptno = 10 group by deptno
select deptno, count(*) from emp where deptno = 20 group by deptno
select deptno, count(*) from emp where deptno = 30 group by deptno
I can't write a PL/SQL function that returns a query in the multiple series syntax (SELECT link, label, series_1_value [, series_2_value [, ...]]FROM ...) as I am using an aggregate function and my where clause is different for each series.
Thanks,
RupeshHi Roel,
Thanks for your reply. I am already using an analytical function (RATIO_TO_REPORT(COUNT(*)) OVER () ) in my actual report. My problem is that the query for one series differs from the other only in one where clause. I will be able to dynamically able to generate all the queries for all the series in one pl/sql function. But the chart definition screen does not allow us to define a single function that returns queries for the all the series - possibly seperated by some seperator like S1: select.... S2:select and so on.
Regards,
Rupesh -
Using 'Function Returning SQL Query' with Flash charts
I have created a pl/sql function that returns a SQL query as a varchar2 of this form:
select null link
<x value> value
<Series1 y value> Series 1 Label
<Series2 y value> Series 2 Label
<Series3 y value> Series 3 Label
from tablea a
join tableb b
on a.col = b.col
order by <x value>
If I now call the function from a Flash Chart Series SQL box with the Query Source Type set to 'Function Returning SQL Query' like this:
return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'))
it parses correctly and the page is saved; however, when I run the page I don't get any output - nor any error messages or other indication of a problem.
Now, if I call the function in a SQL client, capture the SQL query output using dbms_output and paste that into the Flash Chart Series SQL box - changing the Query Source Type to SQL Query - and save the page it works fine when I run it and returns a multi-series flash chart.
Can anyone suggest either;
1. What have I might have missed or done wrong?
2. Any way to usefully diagnose the problem...
I have tried using the Apex debugger - which is very nice, by the way - but it doesn't provide any info on what my problem might be. I even tried writing my own debug messages from my function using the apex_debug_message package - got nothing...
Thanks,
EricHi Eric,
Try expressing the source as this:
begin
return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'));
end;That works fine for me, and if I take out the begin-end and the trailing semicolon from the return statement I get the same behavior as you.
It does mention in the help for the source (only during the wizard though) that this source type has to be expressed that way, but I agree it would be helpful if the tool would validate for this format when 'Function Returning SQL Query' is used or give some sort of indication of the trouble. Anyway, this should get you going again.
Hope this helps,
John
If you find this information useful, please remember to mark the post "helpful" or "correct" so that others may benefit as well. -
PL/SQL function returning a SQL Query
Is this only availabe in HTML db or in 10g in general? Where do I find more about this feature?
Thanks in advance,
DenesNot sure what you mean. HTML DB allows to use a PL/SQL function returning a valid SQL query in report regions.
Its just a PL/SQL function returning a string, outside of HTML DB, I guess you can use it wherever it makes sense. -
Pl/sql block returning sql query.
Hello,
I am using oracle 10g apex 3.2 version.
I am using the following return statement inside my report which is pl/sql block returning sql query.
declare
pid varchar2(100);
begin
return 'select patient_id_code from t_files_data_exp where patient_id_code not in pid';
end;
How am i suppose to mention the pid inside the return stmt i mean with any quotes or anything? because the above return stmt gives error
"1 error has occurred
Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. The query can not be parsed, the cursor is not yet open or a function returning a SQL query returned without a value."
ThanksHello,
I did exactly the way u told
declare
pid varchar2(100) := '(61092,61093)';
begin
return 'select patient_id_code from t_files_data_exp where patient_id_code not in ' || pid;
end;
patient_id_code is varchar2(100) only in table.
For this i am getting "invalid number error".
Thanks -
Date format in PL/SQL Procuredure returning SQL Query
We have parameters (a begin date and end date) that are entered in on a form and then passed as parameters to a report that is displayed using PL/SQL Procedure returning SQL Query. We would like the users to be able to enter the date in the format of mm/dd/yyyy but when we change the format mask on the begin and end date fields we get invalid month entered. I then went into my PL/SQL procedure and changed the code to the following
q := q || ' WHERE ' ||
'(:P41_W_BEGIN_DT IS NULL OR (:P41_W_BEGIN_DT IS NOT NULL AND
:P41_W_BEGIN_DT <= to_char(HARDWARE_INFO.WARRANTY_END_DT,''mm/dd/yyyy')))
AND
(:P41_W_END_DT IS NULL OR (:P41_W_END_DT IS NOT NULL AND :P41_W_END_DT >=
to_char(HARDWARE_INFO.WARRANTY_END_DT,''mm/dd/yyyy''))
The code is accepted but when we run the report against the parameters it seems to only be looking at the mm/dd constraint it pays no attention to the YYYY constraint. In the to_char condition if I try using single tick marks it errors out. The only way I can get the tick marks to be accepted in the code is to use 2 single tick marks ''. Any ideas on what I am doing wrong.
Thanks!user520671,
You are doing the conversion in reverse. Because you're applying a function (TO_CHAR) to the columns in your predicate, you'll be negating the use of any indexes. Not prudent from a performance standpoint.
Instead, convert your input values to a date and do the comparison that way.
q := q || ' WHERE ' ||
'(:P41_W_BEGIN_DT IS NULL OR
(:P41_W_BEGIN_DT IS NOT NULL AND to_date(:P41_W_BEGIN_DT,''MM/DD/YYYY'') <= HARDWARE_INFO.WARRANTY_END_DT))
AND
(:P41_W_END_DT IS NULL OR
(:P41_W_END_DT IS NOT NULL AND to_date(:P41_W_END_DT,''MM/DD/YYYY'') >= HARDWARE_INFO.WARRANTY_END_DT))'Also ensure that you are truly passing in a 4-digit year.
Joel
Maybe you are looking for
-
How to get the position of a tag in XML,when i am using the org.xml.sax
Hi, I am able to parse a xml document.I want to get the position of a tag in the document.So that by keeping that as reference, i can access other tags.Plz help me.I am using org.xml.sax API.
-
Update my macbook black to 10.6.2 and it won't reboot! just get blu screen
I need your help please, I'm very disappointed! After Installing the new update on my mac book black my screen turn blue for long long suspicious time I have been waiting for 20 minutes then re boot and again the same issue!!! Is there any way to fix
-
I want my new tabs to open at the end of the row of tabs, how do I do that?
When I open a new tab, I would like it to open at the end of the row of tabs, not next to the tab I'm on now. I'm used to it opening on the end like it did in older versions of Firefox. I'm sure this is an easy fix but I can't find anything in option
-
CS5 Bridge freezes Windows 7 - help?
Have been using CS5 and Bridge for quite a while. Yesterday it's decided not to work. Anytime I click on the start-up icon, the system stops responding and has to be reset to get it going again. InDesign, Illustrator and Photoshop seem fine. Have uni
-
Logged on to my account but they are giving a different number with my details.
Money was disappearing from my pay as you go without me using it. I went on line to check my account, it has a different number with my details. I tried to ring Orange & EE but they do not put me through to talk to some boy. I do not want to top up a