SQL QUERY THAT RETURNS THE PL/SQL
Hello
I'm putting in 4.2 below apex
DECLARE
date of frdate: =: P22_FROMDATE;
date date: =: P22_TODATE;
l_date1 varchar2 (11): = to_char(frdate,'dd-mon-yyyy');
l_date2 varchar2 (11): = to_char(todate,'dd-mon-yyyy');
v_sql varchar2 (32000);
v_Name varchar2 (4000): = months_name (frdate, todate);
char (1) of the v1: = q "[']";
number of lbr1 (6): =: P22_FROMBRANCH;
number of LBR2 (6): =: P22_TOBRANCH;
number of M1 (6): = 11;
Start
v_sql: ='SELECT * FROM (SELECT LBRCODE, PRDACCTID, MN, AVGX FROM (SELECT LBRCODE, PRDACCTID, MN, SUM (BALL) BALL, COUNT (MN) DAYS, ROUND (SUM (BAL) count (MN), 2) AVGX ';))
v_sql: = v_sql | "FROM (SELECT LBRCODE, PRDACCTID, TO_CHAR (BALDATE,'|)) CHR (39) | ' MM' | CHR (39) |') ' | ' ||'|| CHR (39) | » _'|| CHR (39) |' | ' || «TO_CHAR (BALDATE,'|)» CHR (39) | ' AAAA '. CHR (39) |') MN, BALL ';
V_SQL: = V_SQL | "(SELECT Q2. LBRCODE, Q2. PRDACCTID, T1. BALDATE, T_OST_NEW (Q2. LBRCODE, Q2. PRDACCTID, T1. BALDATE) BALL ';
V_SQL: = V_SQL | "FROM (select TO_DATE('||) Chr (39) | l_date1 | Chr (39) | «, » || CHR (39) | ' DD-MON-YYYY ' | CHR (39) |') baldate FROM DUAL Union all the ';
V_SQL: = V_SQL |' select (TO_DATE('||) Chr (39) | l_date1 | Chr (39) | «, » || CHR (39) | ' DD-MON-YYYY ' | CHR (39) |') + level) double baldate ';
V_SQL: = V_SQL |' connect by level < = (TO_DATE('||) Chr (39) | l_date2 | Chr (39) | «, » || CHR (39) | ' DD-MON-YYYY ' | CHR (39) |') -TO_DATE('||) Chr (39) | l_date1 | Chr (39) | «, » || CHR (39) | ' Dd-mon-yyyy ' | CHR (39) |')) ) Q1,';
V_SQL: = V_SQL | "(SELECT LBRCODE,'|) ' (rpad (prdcd, 8,'|)) V1 ||'' || v1 |') || LTRIM (rpad('|| v1 ||) » x'|| V1 | «, 25, » || v1 | » 0' || v1||'),'|| v1 | » x'|| v1 |')) prdacctid OF D009021 WHERE the LBRCODE between ' | : P22_FROMBRANCH |' and ' | : P22_TOBRANCH | "AND moduleinfo =' | TO_NUMBER(:P22_SELECTLIST);
V_SQL: = V_SQL |') ((Q2)) GROUP BY LBRCODE, PRDACCTID, MN))';
V_SQL: = V_SQL | "PIVOT (MAX (AVGX) (MN) IN (';))
V_SQL: = V_SQL | V_NAME;
V_SQL: = V_SQL |')) ORDER OF LBRCODE, PRDACCTID ';
RETURN V_SQL;
END;
I created all the elements of the required page
I get the error message like missing expression
to test, I created a function to return the query, it works very well know to return a query that gives me desired report
am I missing something?
Help, please
HEMU wrote:
Hello Sir
Sorry to bother you again
I tried to use «function that returns colon-delimited topics»
and I got following error
unable to determine query headings: ORA-06550: line 1, column 138: PLS-00103: Encountered the symbol ";" when expecting one of the following: . ( ) , * % & = - + < / > at in is mod remainder not rem => <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset member submultiset The symbol ")" was substituted for ";" to continue.failed to parse SQL query:can take you a look at page901 once again please and a function named months_namex
is it feasible that I'm looking for?
The immediate cause of this error is simply incorrect report headings function call syntax:
return months_namex(to_date(:p901_fromdate,'dd-mon-yyyy'),to_date(:p901_todate,'dd-mon-yyyy')
This should be:
return months_namex(to_date(:p901_fromdate,'dd-mon-yyyy'),to_date(:p901_todate,'dd-mon-yyyy'));
However there is no months_namex
function defined in the workspace.
Tags: Database
Similar Questions
-
I need a query that returns the average amount of characters from text colum in MS SQL.
I need a query that returns the average amount of characters from text colum in MS SQL.
Could someone show me how?Sorting, I need of the
DATALENGTH
function
-
Do stuff to PL/SQl that returns the value and redirect to modal page by setting this value
Hello
a button click Page1 I would perform a PL/SQL procedure that returns a value in P1_ITEMVAL and then redirect to a page 2 (modal page) and the value of an item on this page with the value previously returned. To do the same thing with a normal page is quite easy:
Button action is present, then process of PL/SQL that returns the value in the P1_ITEMVAL element and, finally, a branch at page 2 that sets P2_ITEMVAL with P1_ITEMVAL. I really have no idea how to do the same thing when the target is a modal page.
I created a unit test on https://apex.oracle.com/pls/apex (application 1554 - redir_to_modal)
Workspace: tests
USER: supporter
PWD: supporter1234
Any help would be much appreciated.
Kind regards
Pavel
Pavel
If you prepare a URL using the value calculated in the PLSQL of DA part you can then use a subsequent stage of javascript to set the location of the window.
This will jump to the top of the page of the modal dialog box
: P1_URL: = apex_util.prepare_url)
' f ? p ='|| : APP_ID - Application id
|': 2' - Page id
||': ' || : APP_SESSION - Session id
||':' -- Request
||':NO' -- Debug
: ': ' - Clear Cache
: ': ' - Settings
||' P2_ITEMVAL'
: ': ' - Parameter values
|| (: P1_ITEMVAL);
then in the action of javascript
Window.Location.Replace ($v ('P1_URL'));
Hope this is of some use
Concerning
Kelvin
-
Need help to write a MySQL query that returns only the peer matching records
Because I don't know how to explain it easily, I use the table below as an example.
I want to create a MySQL query that returns only the records that match counterparts where 'col1' = 'ABC '.
Notice the ' ABC / GHI' record does not have a Counter-match ' GHI / ABC' record. This record must not be returned because there is no Counter-Party correspondent. With this table, the ' ABC / GHI' record should be the one returned in the query.
How can I create a query that will do it?
ID | col1 | col2
--------------------
1. ABC | DEF
2. DEF | ABC
3. ABC | IGS
4. DEF | IGS
5. IGS | DEF
* Please let me know if you have no idea of what I'm trying to explain.I wanted to just the results where col1 = ABC, but I already got the answer I needed on another forum. Thank you anyway.
SELECT a.col1,
a.col2
FROM table_name AS a
LEFT OUTER
Table_name JOIN b
ON b.col1 = a.col2
AND a.col1 = b.col2
WHERE b.col1 IS NOT NULL AND a.col1 = 'ABC '. -
Query Union returns the correct data x 2
I have a union query that returns 2 identical lists of data. The data are correct, but I can't work on why it is duplicated. Can anyone help? Thank you.
John
****************************
set linesize 400
set pagesize 9999
NewPage Set 1
wrap off Set
break off Set
Set of feedback on
set the file name = CATS_TURBO_all_LiveT
coil & filename
Noprint today new_value DATEVAR COLUMN
COLUMN case_id FORM 999999 TITLE 'fault '.
COLUMN product_name FORMAT a10 HEADING 'node '.
COLUMN priority_type_name format a4 POSITION "PRI."
Report_date FORMAT of the COLUMN entitled date 'Date of Recvd'
Restore_date FORMAT of the COLUMN date TOPIC "restored".
Close_date FORMAT of the COLUMN date POSITION "closed".
COLUMN assigned_tech_id FORMAT a10 TITLE "GENIUS".
COLUMN status_type_name FORMAT a3 DIRECTION "FS".
Header of COLUMN name format a4 'Type '.
Header of COLUMN Champ_1 format a20 'Exchange '.
COLUMN sla_name format a12 direction "platform".
Format COLUMN header generic a4 "Gen."
COLUMN question_text format a90 titled "Error Description".
COLUMN note_text a90 format called 'progress '.
TTITLE left 'report ' -.
Center ' TURBO all flaws (& filename... SQL) "-"
Jump STRAIGHT DATEVAR-
Left ' wait > > ' jump 1
Select distinct
a.case_id "Fault."
c.product_name
, decode (f.priority_type_name, 'Low', '4', 'Medium', '3', 'High', '2', 'Urgent', '1') Pri
, to_char (a.report_date, ' DD/MM/YYYY HH24') "received".
, to_char (' a.restore_date, ' DD/MM/YYYY HH24 ")"restored ".
, to_char (a.close_date, ' DD/MM/YYYY HH24') 'closed '.
, decode (d.name, 'Software', from ", 'Hardware', 'H', 'Firmware', 'F', 'Unknown', 'U', 'General', 'Gen', 'Doc', 'Doc', 'n' and"No. Fault"") 'Type '.
, decode (b.status_type_name, ' closed - resolved ', '02', 'Pending', '40', 'On Hold - waiting for approval', '41 ', 'pending', '41', 'Wait-Service restored', ' 41', 'lack of training', '44', 'Telesys survey fault', '44') FS
g.field_1
e.sla_name
, decode (a.assigned_tech_id, '10', 'JSMITH', '09', 'MBROWN', '07', 'SCHATTER', '08', 'RSMEED' ', '12', ' SCHOYM') 'B '.
, to_char (sysdate, 'DD-MON-YYYY HH24') today
, to_char (translate (dbms_lob.substr(a.question_text,100), CHR (13) |)) CHR (10), CHR)
question_text 32)))
, null "Note".
of oracledb.incident one
oracledb.status_type b
c oracledb.item_type
oracledb.problem_type d
e oracledb.sla
oracledb.priority_type f
oracledb.item g
oracledb.incident_note h
where (a.status_type_id = b.status_type_id)
and (a.product_id = c.product_id)
and (a.problem_type_id = d.problem_type_id)
and (a.sla_id = e.sla_id)
and (a.priority_type_id = f.priority_type_id)
and (a.product_id = g.product_id)
and e.sla_name = "TURBO PÉI"
and g.field_1 not in the (' SysCntl-1', ' SysCntl-2', "TURBO PÉI" "")
and a.case_id = h.case_id (+)
and not exists (select case_id from k oracledb.incident_note where k.case_id = a.case_id)
and a.deleted <>' 1'
Union
Select distinct
a.case_id "Fault."
c.product_name
, decode (f.priority_type_name, 'Low', '4', 'Medium', '3', 'High', '2', 'Urgent', '1') Pri
, to_char (a.report_date, ' DD/MM/YYYY HH24') "received".
, to_char (' a.restore_date, ' DD/MM/YYYY HH24 ")"restored ".
, to_char (a.close_date, ' DD/MM/YYYY HH24') 'closed '.
, decode (d.name, 'Software', from ", 'Hardware', 'H', 'Firmware', 'F', 'Unknown', 'U', 'General', 'Gen', 'Doc', 'Doc', 'n' and"No. Fault"") 'Type '.
, decode (b.status_type_name, ' closed - resolved ', '02', 'Pending', '40', 'On Hold - waiting for approval', '41 ', 'pending', '41', 'Wait-Service restored', ' 41', 'lack of training', '44', 'Telesys survey fault', '44') FS
g.field_1
e.sla_name
, decode (a.assigned_tech_id, '10', 'JSMITH', '09', 'MBROWN', '07', 'SCHATTER', '08', 'RSMEED' ', '12', ' SCHOYM') 'B '.
, to_char (sysdate, 'DD-MON-YYYY HH24') today
, to_char (translate (dbms_lob.substr(a.question_text,100), CHR (13) |)) Chr (10), Chr (32))) question_text
, to_char (translate (dbms_lob.substr(h.note_text,100), CHR (13) |)) Chr (10), Chr (32))) note_text
of oracledb.incident one
oracledb.status_type b
c oracledb.item_type
oracledb.problem_type d
e oracledb.sla
oracledb.priority_type f
oracledb.item g
oracledb.incident_note h
where (a.status_type_id = b.status_type_id)
and (a.product_id = c.product_id)
and (a.problem_type_id = d.problem_type_id)
and (a.sla_id = e.sla_id)
and (a.priority_type_id = f.priority_type_id)
and (a.product_id = g.product_id)
and e.sla_name = "TURBO PÉI"
and g.field_1 not in the (' SysCntl-1', ' SysCntl-2', "TURBO PÉI" "")
and a.case_id = h.case_id
and h.note_id = (select max (i.note_id)
oracledb.incident_note I have
where a.case_id = i.case_id)
and a.deleted <>' 1'
order by 1;
/
SPOOL OFF
Clear jump
output
Published by: user13388553 on 11/24/2010 14:59If your code is that you run in the production data splits because you're runnign queries twice.
from oracledb.incident_note i where a.case_id = i.case_id) and a.deleted '1' order by 1; / SPOOL OFF
The semicolon after that command by 1 causes the statement to be executed, the slash on the next line causes the reexecute being. Delete one of them.
John
-
Looking for an example of "function that returns the error text.
Environment: APEX 3.1.1.00.09 on AIX 5.3
I'm looking for an example implementation of the posting of the "function that returns the error text.
I would like to write a database function that does the validation logic and return the text of the error.
Is it possible to create multiple lines of text of error based on error conditions?
I'm trying to use it at the end of the input data to go on the set of the 'document' to the entry and highlight all error conditions encountered before the 'document' is subject to additional processing.
I wrote the function and reference it in a posting as ' validate_stuff (: P3_DOC_SEQ); »
I have an error message "validate_stuff is not a procedure or is not defined.
The object is a function, not a procedure. It is defined to return a parameter VARCHAR2 hoped posting if it is not NULL.
When I run the SQL function * more and spend in a number of documents are returned the correct error messages.
Any direction is greatly appreciated.
-garyHi Gary,.
You must RETURN the result of the function:
BEGIN RETURN validate_stuff(:P3_DOC_SEQ); END;
Andy
-
Query that returns number 1 - Add additional columns based on percentages
I have a query that returns a large number. The return value will always be a single field (a column, a line, a single value).
I need to have also three other columns in the return of this request: one that returns a number that is 50% of the original number, one that returns a number that is 75% of the original number, and one that is double the original number. How is that possible? If anyone can point me to examples, it would be a great help. I got the results mixed by searching, so I'm not sure good practices.
Thank you for the input in advance.
Hello
Whenever you have a question, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the accurate results you want from this data, so that people who want to help you can recreate the problem and test their ideas.
Explain, using specific examples, how you get these results from these data.
If you show what you want to do using commonly available tables, like those of the scott schema, then you don't need to display the sample data; just results and explanations.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: Re: 2. How can I ask a question on the forums?
I'm not sure that understand the question.
If x is a number, then
.50 * x is 50% of this number,
.75 * x is 75% of that number, and
2 * x is to double this figure.
You can get them all in the same query, if you want to. For example:
SELECT ename
sal
.50 * sal AS p_50
.75 * sal AS p_75
2 * sal AS dbl
FROM scott.emp;
Output:
ENAME SAL P_50 P_75 DBL
---------- ---------- ---------- ---------- ----------
SMITH, 800, 400, 600, 1600
1600 800 1200 3200 ALLEN
1250 625 WARD 937,5 2500
JONES 2975 1487.5 2231,25 5950
1250 625 MARTIN 937,5 2500
2850 1425 BLAKE 2137,5 5700
2450 1225 CLARK 1837,5 4900
3000 1500 2250 6000 SCOTT
KING 5000 2500 3750 10000
1500 750 1125 3000 TURNER
1100 550 825 2200 ADAMS
JAMES 950 475 712,5 1900
FORD 3000 1500 2250 6000
1300 650 975 2600 MILLER
Is that what you ask?
-
Method that returns the bb::cascades:Application?
Hi, is there a method that returns the bb::cascades:Application?
I solved the problem by simply passing the request of my class that needs it. If its solved because there is no such method I think.
-
I need a query that selects the amount of records for each day of a table.
I need a query that selects the amount of records for each day of a table.
For example, the result would be:
1 14 date
Date 2-3
etc.
Any ideas?Sort:
SELECT count ([IDCommentaire]), convert (varchar, dateAdded, 112)
OF COMMENTSgroup by convert (varchar, dateAdded, 112)
-
Function that return the name of the current report
Hello
Anyone know if there is a function that returns the name of the current report?, similar to GET_APPLICATION_PROPERTY (CURRENT_FORM) in the forms.
Tnks,
LEFMHello
You can use the builtin: SRW. GET_REPORT_NAME
This function returns the file name of the running reporthttp://www.Oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwrefex/PLSQL/builtins/SRW/srw_get_report_name.htm
NOTE: it is not the name of the RDF file. Is the name defined in the reporting name property.
Concerning
-
Query should return the number of records that do not match the values of the DB
I have the SQL query in the IN clause that I have certain values to verify each year against DB. I need a query that should tell the number 1 for existing records and 0 to not exist records. I get only matched lines from now account. Help is very appreciated.
sample
number of values
SAM 1
CAT 0
POOL 1
JACK 1
FUN 0
Concerning
Prakash.with search_for_values as ( select 'SAM' name from dual union all select 'CAT' from dual union all select 'HEN' from dual union all select 'JACK' from dual union all select 'FUN' from dual ) , search_in_tab as ( select 'SAM' name from dual union all select 'HEN' from dual union all select 'JACK' from dual union all select 'HEN' from dual union all select 'JACK' from dual union all select 'HEN' from dual union all select 'JACK' from dual ) select sfv.name , case when exists ( select null from search_in_tab sit where sit.name = sfv.name ) then 1 else 0 end cnt from search_for_values sfv
Anton
-
a function that returns the type with a table joint!
Good day to all,
I have a function that returns a type.
so I select it as:
Select * from table (function (param1, param2))
now I want to combine this with a table so that the settings for the service we get from the join table. Is this possible? And how?
I tried different options without success.
something like:
Select *.
table table (function (b.column1, b.columnb) x), tablea b
where x.a = b.col
Is this possible?
Thanks in advance?user564819 wrote:
something like:
Select *.
table table (function (b.column1, b.columnb) x), tablea b
where x.a = b.colIs this possible?
Somehow...
SQL> create or replace type TIntegers is table of integer; 2 / Type created. SQL> SQL> --// our sample pipeline simply spews 2 numbers for eevry number input - simple SQL> --// to use for the testcase below SQL> create or replace function FooPipe( n number ) return TIntegers pipelined is 2 begin 3 pipe row( trunc(n) ); 4 pipe row( trunc(n)*-1 ); 5 return; 6 end; 7 / Function created. SQL> SQL> with dataset( n ) as( 2 --// ignore this part as it only builts a base table 3 --// for us to use to select values for input to 4 --// to the pipeline - in "real world" use this table 5 --// will already exist 6 select 7 level 8 from dual 9 connect by level <= 10 10 ), 11 pipe_line( n, array ) as( 12 --// we run the pipeline as a nested table column 13 --// in the SQL projection - the CAST is important 14 --// in order to establish the nested table type 15 select 16 d.n, 17 cast( 18 FooPipe(d.n) as TIntegers 19 ) 20 from dataset d 21 ) 22 --// we now use a standard query to unnest the nested table column 23 select 24 p.n, 25 pipe_val.* 26 from pipe_line p, TABLE(p.array) pipe_val 27 / N COLUMN_VALUE ---------- ------------ 1 1 1 -1 2 2 2 -2 3 3 3 -3 4 4 4 -4 5 5 5 -5 6 6 6 -6 7 7 7 -7 8 8 8 -8 9 9 9 -9 10 10 10 -10 20 rows selected. SQL>
Not sure I like it. What is the real problem that this method (driving a pipeline with input of a base table rows) is supposed to address? There may be a simpler and more elegant approach...
-
Dynamic action - show/hide area based on LOV that returns the ID
Hi people,
This should be simple, so someone who works with dynamic actions.
I have a LOV based on query below:
Agenda: P200_KOD is based on LOV that displays KOD and returns the ID.select OBJECT_ID, KOD from x_data x; retuns: ID KOD ---------------------------- 492961 BMW 492964 VOLVO 492960 MERCEDES 492963 VOLKSWAGEN 492959 SKODA
On my page, I have also 1 region called TEST_REGION.
I want to put in place a testament of shich dynamic action SHOW/HIDE a TEST_REGION based on the value selected in the order of the day: P200_KOD (LOV). Region should be shown if displayed (KOD) selected ID value begins with '% V '.
By other words, if following query returns any folder, then the SHOW, HIDE it on the other:
How can I define a condition of dynamic action fires, for article: P200_KOD?select * from x_data x where x.kod like 'V%' and x.object_id = :P200_KOD;
Thank you
TomasHello
One way:
Create an advanced dynamic action.
Name: Region to hide
Event: change
Selection type: item (s)
Items (s): P200_KOD
Condition: Expression of JavaScript
Value:$(this.triggeringElement).children("option:selected").html().substring(0,1) !== "V"
Action: hide
Fire on the Page loading: true
Hide all items on the page on the same line: No.
Action of false: show
Fire on the Page loading: true
Display all items in the page on the same line: No.
Selection type: region
Region: TEST_REGIONKind regards
Jarihttp://dbswh.webhop.NET/dbswh/f?p=blog:Home:0
-
Function that returns the results of a select statement
Hello
I would like to create a feature on the famous HR Departments oracle table to select * from him. I don't know how to do it.
Is someone can help me?.
Thank youOracle stored functions cannot return result sets directly but can return the REF CURSOR. Please read [optimize result set retrieval using ODP.NET and Ref Cursor | http://www.oracle.com/technology/pub/articles/mastering_dotnet_oracle/williams_refcursors.html] which gives complete examples in PL/SQL for the side Server and VB. NET client side.
-
Request report - use the function that returns the cursor
My requirement is to create a report, which the source will be a function that returns a cursor (the type of cursor is ref cursor).
How this can be done?
for example. function my_func (pol_no in number) return cur_type < ref cursor >
Edited by: viveks on October 27, 2009 10:09Better to look at a function that returns a query, or use a hose to treat your cursor returned, because the APEX at the moment can NOT handle the sliders in reports...
Thank you
Tony Miller
Webster, TX
Maybe you are looking for
-
Could not set the connection Wi - Fi on Satellite click mini L9W
I just news click on mini L9WWiFi connection was created without difficulty editing - it was later lost during the day, perhaps when the integrated anti virus has been activatedRe-established connection using Windows network & sharing Center - connec
-
Digital speedometer on an FPGA
I'm trying to implement a simple digital tachometer on a machine. Its a proximity detector and a disc with several holes. I want to check the disk rotates and don't care (at least for now) how fast. I use a digital camera on my FPGA 9074 and just wan
-
System moves like a turtle :(
I can't understand why my computer has decided to launch so slow on Windows XP. I did everything possible. It is not lack of memory, no virus. I use Internet Explorer. Any ideas?
-
Bluescreen error message usbechi.sys while trying to watch TV.
Original title: blue screen error message usbechi.sys. I have windqws xp media edition sp3. I installed a tv card nova t win 500 dvb t a few months ago, I was getting a bsod with error message about usbechi.sys. I found a Microsoft patch, saying that
-
BlackBerry Smartphones Can I have a blackberry and not pay for all the internet services?
Hi I'm new on this and my t-mobile phone that I broke and I looking to upgrade to something that will help me to stay a bit more organized, but are unwilling to pay for the service package that comes with the purchase of a blackberry from t-mobile. I