Function of PL/SQL return statement IMG
APEX 4.0.2
I have a SQL command that it generate statements of IMG. It looks a bit like this-
SELECT blah blah blah
(CASE
"WHEN p.person_id IS NULL THEN ' < img alt ="nophoto"src =" #WORKSPACE_IMAGES #nophoto.png "/ >"
"ELSE ' < img alt ="photo"src =" #WORKSPACE_IMAGES #photo.png "/ >"
END) "PHOTO."
abwapps.er.GetReviewImage (e.thirty_day_due, e.thirty_day_done, e.sixty_day_due, e.sixty_day_done, e.ninety_day_due, e.ninety_day_done) "REVIEW_OVERDUE_IMAGE."
blah blah blah
'PHOTO' and 'REVIEW_OVERDUE_IMAGE' are defined as Standard report columns.
'PHOTO' is displayed correctly. "REVIEW_OVERDUE_IMAGE" displays the REPLACEMENT text.
I confirmed that getreviewimage to create the IMG statement correctly by making the field to display as text. The IMG statement seems good.
Then I took among the mentions IMG generated and hard-coded in the SQL statement. In other words changed the SQL statement as follows
SELECT blah blah blah
(CASE
"WHEN p.person_id IS NULL THEN ' < img alt ="nophoto"src =" #WORKSPACE_IMAGES #nophoto.png "/ >"
"ELSE ' < img alt ="photo"src =" #WORKSPACE_IMAGES #photo.png "/ >"
END) "PHOTO."
' < img alt = "blah" src = "#WORKSPACE_IMAGES #blah.png" / > "" REVIEW_OVERDUE_IMAGE",
blah blah blah
bla displayed instead of blah.png. Firebug shows that #WORKSPACE_IMAGES # is not converted to REVIEW_OVERDUE_IMAGE.
I don't know what is happening here.
Walt K wrote:
APEX 4.0.2
I have a SQL command that it generate statements of IMG. It looks a bit like this-
SELECT blah blah blah
(CASE
WHEN p.person_id IS NULL THEN ''
ELSE ''
END) "PHOTO."
abwapps.er.GetReviewImage (e.thirty_day_due, e.thirty_day_done, e.sixty_day_due, e.sixty_day_done, e.ninety_day_due, e.ninety_day_done) "REVIEW_OVERDUE_IMAGE."
blah blah blah
'PHOTO' and 'REVIEW_OVERDUE_IMAGE' are defined as Standard report columns.
'PHOTO' is displayed correctly. "REVIEW_OVERDUE_IMAGE" displays the REPLACEMENT text.
I confirmed that getreviewimage to create the IMG statement correctly by making the field to display as text. The IMG statement seems good.
Then I took among the mentions IMG generated and hard-coded in the SQL statement. In other words changed the SQL statement as follows
SELECT blah blah blah
(CASE
WHEN p.person_id IS NULL THEN ''
ELSE ''
END) "PHOTO."
"" "REVIEW_OVERDUE_IMAGE"
blah blah blah
bla displayed instead of blah.png. Firebug shows that #WORKSPACE_IMAGES # is not converted to REVIEW_OVERDUE_IMAGE.
I don't know what is happening here.
Probably you create image src
reference in the GetReviewImage
works by using the substitution string "#WORKSPACE_IMAGES #"? This will not be overridden when used outside of a block in the APEX. To refer to integrated units of DB program APEX session state and the substitution string values, you must use the syntax of PL/SQL function:
''
However, I highly recommend the use of HTML phrases in order to remove the literal HTML from report queries and PL/SQL program units whenever it is possible to do.
Tags: Database
Similar Questions
-
Hey guys,.
I'm using version 4.2.6 apex. The theme is 26.
IM also using Listener Oracle APEX.
I can print my classic report in PDF or CSV format.
But I need to export it as a .xls extension.
Report type: SQL (body of function from PL/SQL returning the SQL) query
I need is like this cause my 'where' clause type is dynamic.
Look at using this method: Tom's Blog: a non-standard export excel 2010 (.xlsx)
I do something similar for downloads to excel in my projects...
Thank you
Tony Miller
Software LuvMuffin
Ruckersville, WILL -
SQL (body of function from PL/SQL returning the SQL) query when you use to_char
We are trying to build a page of Type SQL Query report (body of function from PL/SQL returning SQL query).
our request is simple, to extract the month of the column recording_date.
declare
l_query varchar2 (1000);
Start
l_query: = 'select to_char (recording_date, 'MM') of re_productive;
Return l_query;
end;
but we would like the following for this query problem
Function returning SQL query: query cannot be parsed in the generator. If you believe that your query is syntactically correct, check the box of generic columns below the source of the region without analysis.
(ORA-06550: line 4, column 42: PLS-00103: encountered the symbol "MY" what awaits one of the following values:.) (* @ % & = - +; <>/ at is mod remains not rem <>or! = or ~ = > = < = <>and or as between | multiset Member SUBMULTISET_ the symbol ".") was inserted before 'MY' to continue.)
Notes:
1 - the request is correct and it has been tested under sqlplus and toad.
2. we tried option use generic name (analysis of query runtime only) column, but we get the same problem.
any quick help please.Hello
You have not escaped your quote in the string. Try this...
DECLARE l_query VARCHAR2(32767); BEGIN l_query:= 'select to_char(recording_date,''MM'') from re_productive'; RETURN l_query; END;
See you soon
Ben
-
Graph based on the function of PL/SQL returning the sql query
Hello, is it possible to have a chart based on PL/SQL return SQL function as with the reports.
If I need to present data that is based on the graph and the graph itself, and the report is based on the function PL/SQL, SQL back then how I do the table if this is not possible? Also, is there a way to specify which columns in the report to use for the chart instead of having to specify the same question again on the list - this seems a bit redundant.Ah, OK - one HTML table does not offer the possibility of using the PL/SQL (I don't know why, if)
However, you can create a collection (using the APEX_COLLECTION. Function CREATE_COLLECTION_FROM_QUERY) from your vSQL of string and then basing the chart on that?
Andy
-
function body pl/sql return SQL query - if with in the select statement
Hi all
I have a condition where, when the summary field is checked, only we see the this column for users in the report. IF statement is possible in this case? I gave the code below... is possible to write something like below, or y at - it another way to do it?
\
v_sql: = ' select TBLCASES. INVESTIGATOR as an INVESTIGATOR,';
v_sql: = v_sql | "TBLCASES. CASENUMBER as CASENUMBER,';
v_sql: = v_sql | "TBLCASES. OPENDATE as OPENDATE,';
v_sql: = v_sql | "TBLCASES. ESTCOMPLETE as DATE_CIBLE,';
v_sql: = v_sql | "TBLCASES. STATUS of STATUS ';
v_sql: = v_sql | "TBLCASES. Case CODE case CODE as,';
v_sql: = V_sql | "TBLCASES. FAIR_HOTLINE as FAIRHotline,';
v_sql: = v_sql | "TBLCASES. NYSIG as NYSIGCase,';
v_sql: = v_sql | "TBLCASES. The REGION';
IF: P44_INCLUDE_SUMMARY_FIELD is not null THEN
v_sql: = v_sql | "TBLCASES. SUMMARY,';
END IF;
v_sql: = v_sql | "TBLCASES. PROGAREA as PROGArea ';
v_sql: = v_sql | ' from TBLCASES where 1 = 1';
.. \Hi Lucie,.
You are adding and removing a column in a report, so it may be useful to have the extra on the end of the query.
You get an error? If so, paste it in...BUT - that I would put a condition on the column where ': P44_INCLUDE_SUMMARY_FIELD is not null '
It under 'Attributes of the column' report select the change column icon, and there a breadcrumb "Condition."
Select "In Expression 1 point value is not Null" and put the P44_INCLUDE_SUMMARY_FIELD in the Expression 1 text box.And I have to make it more readable like that when I do the dynamic SQL code:
IF: P44_INCLUDE_SUMMARY_FIELD is not null THEN
v_INCLUDE_SUMMARY_FIELD: = ' TBLCASES. SUMMARY summary ';
END IF;v_sql: = ' select TBLCASES. RESEARCHER, researcher,
TBLCASES. CASENUMBER as CASENUMBER
TBLCASES. OPENDATE as OPENDATE,
TBLCASES. ESTCOMPLETE as DATE_CIBLE,
TBLCASES. STATUS of STATUS,
TBLCASES. Case CODE case CODE as,
TBLCASES. FAIR_HOTLINE as FAIRHotline,
TBLCASES. NYSIG as NYSIGCase,
TBLCASES. REGION as the region,
TBLCASES. PROGAREA as PROGArea,' |
v_INCLUDE_SUMMARY_FIELD |
' from TBLCASES where 1 = 1; ';It will be useful,
BRITISH COLUMBIA -
Irregular data loss - function from PL/SQL returning data using Ref Cursor
Database Version: 10.2.0.4.0 (node 2 CARS)
The high-level process flow is as below:
(1) insert records in a few tables & commit the same
(2) call the pl/sql function to extract files (on certain conditions with joins with other tables) of the tables which are filled in step 1.
-> It uses the ORDER BY clause to queries inline & line number 5000 records return for each call.
Sense - if inline query is supposed to return 1,00,000 records then 20 calls to the same function. This, because the application cannot contain records beyond number.
(3) the data returned by the ref cursor is then processed by application (Tibco BW) to generate the flat file.
We are facing the problem of data loss in the file and there is no fixed model. It happens once between 200-300 calls process.
Resolution: When the problem occurs, triggering the process and in almost every time re-outbreak of the process provides required data.
Guidance on what could be the reason?
* Examples of Code for the function:
CREATE OR REPLACE FUNCTION FUNC_GET_HRCH_TOTAL_DATA)
outinstrid in NUMBERS
outinstrkey in NUMBERS
rownumberstart in NUMBERS
rownumbereend in NUMBERS
err_code OUT VARCHAR2,
err_msg OUT VARCHAR2)
RETURN PACK_TYPES. HRCH_TOTAL_CURSOR
IS
REF_HRCH_TOTAL_CURSOR PACK_TYPES. HRCH_TOTAL_CURSOR;
BEGIN
OPEN FOR REF_HRCH_TOTAL_CURSOR
SELECT *.
FROM (SELECT A.HIERARCHY_KEY, B.KEY, B.VAL_KEY, A.KEY_NEW, C.ITEMID, B.VAL_TAG, B.sort_order, ROWNUM ROWNUMBER
OF AOD_HRCH_ITEM A, AOD_HRCH_ATTR B, AOD_HRCH_ITEMS C
WHERE A.outputid = B.outputid
AND A.outputid = C.outputid AND A.outputkey = B.outputkey
AND A.outputkey = C.outputkey AND A.outputid = outinstrid
AND A.outputkey = outinstrkey AND A.ITEM_SEQ = B.ITEM_SEQ
AND A.ITEM_SEQ = C.ITEM_SEQ AND A.HIERARCHY_LEVEL_ORDER = B.SORT_ORDER
ORDER BY A.HIERARCHY_LEVEL_ORDER DESC)
WHERE ROWNUMBER < rownumbereend
AND ROWNUMBER > = rownumberstart;
RETURN REF_HRCH_TOTAL_CURSOR;
EXCEPTION
WHILE OTHERS
THEN
err_code: = x_progress | ' - ' || SQLCODE;
err_msg: = SUBSTR (SQLERRM, 1, 500);
END FUNC_GET_HRCH_TOTAL_DATA;
/
Published by: meet_sanc on February 16, 2013 10:42Your SELECT statement is almost certainly incorrect
SELECT * FROM ( SELECT A.HIERARCHY_KEY, B.KEY, B.VAL_KEY, A.KEY_NEW, C.ITEMID, B.VAL_TAG, B.sort_order,ROWNUM ROWNUMBER FROM AOD_HRCH_ITEM A, AOD_HRCH_ATTR B, AOD_HRCH_ITEMS C WHERE A.outputid = B.outputid AND A.outputid = C.outputid AND A.outputkey = B.outputkey AND A.outputkey = C.outputkey AND A.outputid = outinstrid AND A.outputkey = outinstrkey AND A.ITEM_SEQ = B.ITEM_SEQ AND A.ITEM_SEQ = C.ITEM_SEQ AND A.HIERARCHY_LEVEL_ORDER = B.SORT_ORDER ORDER BY A.HIERARCHY_LEVEL_ORDER DESC) WHERE ROWNUMBER < rownumbereend AND ROWNUMBER >= rownumberstart;
Since the ORDER BY is applied after the ROWNUM is assigned in this case, your query is requested for a period of 5000 lines any arbitrariness. It would be perfectly valid for a single line to return in each of your 200 different calls or for a line to return in any of them.
You definitely want to do something in the sense of the canonical askTom wire
select * from ( select a.*, rownum rnum from ( YOUR_QUERY_GOES_HERE -- including the order by ) a where rownum <= MAX_ROWS ) where rnum >= MIN_ROWS
That said, it seems inconceivable that Tibco is unable to manage a cursor that returns more than a certain number of lines. You do a ton of work to return the data pages that are certainly not necessary. Unless you're saying that you somehow paralyzed your installation of Tibco giving him a ridiculously small amount of memory to process, something doesn't look good. A slider is just a pointer - it holds that no data - so the number of lines that you can extract a slider should have no impact on the amount of memory on the client application needs.
As others have already pointed out, your exception handler is almost certainly do more harm than good. Return the error codes and error messages as from the OUT parameters, instead of simply allowing the exception to propagate deletes a ton of useful information (such as the mistake of the stack) and makes your process much less robust.
Justin
-
pl/sql returning a Boolean?
I don't know what the problem with this code:
as part of the State of the button = "function from pl/sql returning a Boolean"...declare l_return boolean ; begin if 1 =1 then l_return := TRUE ; end if; RETURN l_return ; end;
It produces:ORA-06550: line 9, column 1: PLS-00372: In a procedure, RETURN statement cannot contain an expression ORA-06550: line 9, column 1: PL/SQL: Statement ignored 7. end;
Initialize the variable to FALSE;
Boolean l_return: = false;
-
catch the collection returned by the function in a SQL statement
I have a select like query: (I need all the values returned by the function in the select list)
Select t1.col1, t2.col2, (by selecting t.a, t.b., t.c in fn (t2.col3) t)
Of
T1, t2
where t1.col1 = t2.col2;
My function is like:
FN (T2.col3) returns an array in format of the object
Here, I was able to select only one value from the table returned by the funcation both. If I select all of the values as above, she gave too much error vales.
Please someone help me in thisuser13044793 wrote:
I have a select like query: (I need all the values returned by the function in the select list)Select t1.col1, t2.col2, (by selecting t.a, t.b., t.c in fn (t2.col3) t)
Of
T1, t2
where t1.col1 = t2.col2;No specific reason for this? It adds additional complexity to the projection of SQL, and there are additional costs of failover for the motor of PL/SQL (per line) of context. Overall - not your typical approach and one that should have sound justification.
With regard to the basic method - the SQL multiset() function should be used to create a collection. Here is an example of the approach:
SQL> create or replace type TFoo as object( 2 id number, 3 bar varchar2(5) 4 ); 5 / Type created. SQL> SQL> create or replace type TFooSet as table of TFoo; 2 / Type created. SQL> SQL> create or replace function GetSomeFoo( n number ) return TFooSet is 2 foo TFooSet; 3 begin 4 foo := new TFooSet(); 5 foo.Extend( 5 ); 6 7 for i in 1..5 8 loop 9 foo(i) := new TFoo( n+i-1, to_char(i-1,'0000') ); 10 end loop; 11 12 return( foo ); 13 end; 14 / Function created. SQL> SQL> select 2 object_id, 3 object_name, 4 cast( 5 multiset( select * from table(GetSomeFoo(object_id)) ) as TFooSet 6 ) as FOO 7 from all_objects 8 where owner = 'SYS' 9 and rownum <= 5; OBJECT_ID OBJECT_NAME FOO(ID, BAR) ---------- ------------------------------ -------------------------------------------------- 27538 /1000e8d1_LinkedHashMapValueIt TFOOSET(TFOO(27538, ' 0000'), TFOO(27539, ' 0001') , TFOO(27540, ' 0002'), TFOO(27541, ' 0003'), TFOO (27542, ' 0004')) 28544 /1005bd30_LnkdConstant TFOOSET(TFOO(28544, ' 0000'), TFOO(28545, ' 0001') , TFOO(28546, ' 0002'), TFOO(28547, ' 0003'), TFOO (28548, ' 0004')) 11718 /10076b23_OraCustomDatumClosur TFOOSET(TFOO(11718, ' 0000'), TFOO(11719, ' 0001') , TFOO(11720, ' 0002'), TFOO(11721, ' 0003'), TFOO (11722, ' 0004')) 30094 /100c1606_StandardMidiFileRead TFOOSET(TFOO(30094, ' 0000'), TFOO(30095, ' 0001') , TFOO(30096, ' 0002'), TFOO(30097, ' 0003'), TFOO (30098, ' 0004')) 684122 /1023e902_OraCharsetUTFE TFOOSET(TFOO(684122, ' 0000'), TFOO(684123, ' 0001 '), TFOO(684124, ' 0002'), TFOO(684125, ' 0003'), TFOO(684126, ' 0004')) SQL> SQL> with dataset as( 2 select 3 object_id, 4 object_name, 5 cast( 6 multiset( select * from table(GetSomeFoo(object_id)) ) as TFooSet 7 ) as FOO 8 from all_objects 9 where owner = 'SYS' 10 and rownum <= 5 11 ) 12 select 13 d.object_id, 14 d.object_name, 15 f.id, 16 f.bar 17 from dataset d, 18 table(d.foo) f 19 / OBJECT_ID OBJECT_NAME ID BAR ---------- ------------------------------ ---------- --------------- 217 DUAL 217 0000 217 DUAL 218 0001 217 DUAL 219 0002 217 DUAL 220 0003 217 DUAL 221 0004 268 SYSTEM_PRIVILEGE_MAP 268 0000 268 SYSTEM_PRIVILEGE_MAP 269 0001 268 SYSTEM_PRIVILEGE_MAP 270 0002 268 SYSTEM_PRIVILEGE_MAP 271 0003 268 SYSTEM_PRIVILEGE_MAP 272 0004 271 TABLE_PRIVILEGE_MAP 271 0000 271 TABLE_PRIVILEGE_MAP 272 0001 271 TABLE_PRIVILEGE_MAP 273 0002 271 TABLE_PRIVILEGE_MAP 274 0003 271 TABLE_PRIVILEGE_MAP 275 0004 274 STMT_AUDIT_OPTION_MAP 274 0000 274 STMT_AUDIT_OPTION_MAP 275 0001 274 STMT_AUDIT_OPTION_MAP 276 0002 274 STMT_AUDIT_OPTION_MAP 277 0003 274 STMT_AUDIT_OPTION_MAP 278 0004 815 RE$NV_LIST 815 0000 815 RE$NV_LIST 816 0001 815 RE$NV_LIST 817 0002 815 RE$NV_LIST 818 0003 815 RE$NV_LIST 819 0004 25 rows selected. SQL>
-
How to the return type of function from PL/SQL
Hello
I need to create a function that returns a list of ID, which is stored in a type T_IDs, something like:
search function (searchstring in varchar2) return to T_IDs
I have a little problem with the type within the body of the function using a select statement and filling
Select the id of the table where the text as searchstring.
which is to select a list of IDS corresponding to the where clause. Is it possible to use select in or should I go for another mechanism?
Thanks for all the ideas.Bulk Collect works for me...
SQL> create type t_ids as table of number; 2 / Type created. SQL> ed Wrote file afiedt.buf 1 create or replace function get_ids(deptno in number) return t_ids is 2 ids t_ids; 3 begin 4 select empno 5 bulk collect into ids 6 from emp 7 where deptno = get_ids.deptno; 8 return ids; 9* end; SQL> / Function created. SQL> select * from table(get_ids(10)); COLUMN_VALUE ------------ 7782 7839 7934
However, I would rarely use such a data collection, as it fills with PGA in memory and passing a lot of data between SQL and PL/SQL. I must have a just cause and justified in wanting to do things this way.
-
Field validation through pl/sql returning a Boolean
Hello
I do a validation of date entered based on a value in the other field of the form. The function returns Boolean values (TRUE / FALES) based on the date of entry if it falls within the specific range of dates.
Here is the example.
However, after sending them, I get the error message like -.
Processing of validation error.
ORA-06550: line 1, column 44: PLS-00221: 'F_CHECK_DATE' is not a procedure or is undefined ORA-06550: line 1, column 44: PL/SQL: statement ignored
I'm doing something wrong here? Help, please.
Thank you
-Anand
anand_gp wrote:
Hello
I do a validation of date entered based on a value in the other field of the form. The function returns Boolean values (TRUE / FALES) based on the date of entry if it falls within the specific range of dates.
Here is the example.
However, after sending them, I get the error message like -.
Processing of validation error.
ORA-06550: line 1, column 44: PLS-00221: 'F_CHECK_DATE' is not a procedure or is undefined ORA-06550: line 1, column 44: PL/SQL: statement ignored
I'm doing something wrong here? Help, please.
Thank you
-Anand
The index is in the validation type: function returning a Boolean
The expression of validation for validation of Boolean function return must be in the form of a function with at least one accessible body
return
statement that returns a Boolean value:...
return
; or
return to_date(:p11_event_date, 'DD/MM/YYYY') > sysdate;
in this case:
return my_package.f_check_date(:p11_season, :p11_event_date);
However, because the function returns a Boolean value anyway, you might as well use a validation Of PL/SQL Expression and save some typing:
my_package.f_check_date (: p11_season,: p11_event_date);
-
function() nested in the select statement
Oracle 11g. Try to nest a function within the select statement. Goal: get the average customer rating for each of the qualified user.
Select user_name, f_get_avg_cust_rating() "Notation.
of u, OTHER_TABLES o TAB_USER
where u.id = o.id and another condition matched;
How Oracle would deal with the sql. Is it
(1) first of all display records based on the where clause, then call the f_get_avg_cust_rating() for each of the selected records OR
(2) for the analysis in tables, the f_get_avg_cust_rating() will be called for each record met?
Thank you
Scott
Words of Frank, I created two functions with dbms_output and used a function in where clause in select another function. See the bottom of the unit tests. Everyone says, where first clause then select...
-Where function clause
SQL > CREATE or REPLACE FUNCTION ret_empno
2 RETURN NUMBER
3 AS
4 BEGIN
5 DBMS_OUTPUT. Put_line (' where Clause Function');
6 RETURN 7839;
7 END;
8.
The function is created.
-Select the function
SQL > CREATE or REPLACE FUNCTION ret_1
2 RETURN NUMBER
3 AS
4 BEGIN
5 DBMS_OUTPUT. Put_line ('Select function');
6 RETURN 1;
7 END;
8.
The function is created.
SQL > SELECT empno, ename,ret_1
2 FROM emp
3. WHERE empno = ret_empno;
EMPNO, ENAME RET_1
---------- ---------- ----------
7839 KING 1
Where the function Clause
Select the function
-
Authorisation scheme: poll from function from PL/SQL Boolean value
Hello
I use with authorisation schemes on page 2 as function of PL/SQL to return a Boolean.
The value of P1_PREF is from page1 (search) report box, driven model type (< class td = "t12data" >#PREF # < table >)
--(lien hypertexte pref) to page 2 P2_PREF.
I tried passing the value (: P2_PREF or: P1_PREF) but it does not work. If I assign (where pref = "100") or any other value it works fine.
Is it to do with sessions or to store the value in a variable prior to authorization of the page. Please notify.
DECLARE
v_userrole VARCHAR2 (400) DEFAULT NULL;
v_staffaccess VARCHAR2 (400) DEFAULT NULL;
BEGIN
Select USER_ROLE IN v_userrole
to userrole
where (upper (USER_LOGIN) = upper(:APP_USER)
or (upper (:APP_USER)) = 'TEST');
Select staff_access in the v_staffaccess of sm
where pref = "P2_PREF";
IF INSTR (v_userrole, 'A') > 0
THEN
RETURN TRUE;
END IF;
IF (((v_userrole) = "SP" OR (v_userrole) = 'U') and nvl (upper (v_staffaccess), 'x') do not ("SUPER %')) THEN)
RETURN TRUE;
ELSE RETURN FALSE;
END IF;
END;
Please advise on the passage of the value.
Thank you very much
HarinderHi Harinder
There are many ways this can be achieved. It seems to me that your problem is that the value passed to page 2 is not be updated at each visit?
So how about this (as only one way to do it).
Page 1 to P1_PREF
You press a button or link to go to page 2, that SUPPORTS THE PAGE (important)
You have a hidden item P2_PREF on page2, who has...Source used - always replace any existing value in session state
Source - point TypeAnd then refer to P1_PREF.
Or you can create a calculation that sets the value of P2_PREF to the value of P2_PREF on the laundry front header.
Or your button on page 1 could create a branch to page 2 using "defined these elements" "with these values" options in the industry...
See you soon
Ben
-
Cannot write the recursive function in PL/SQL
I'm down to the following without interest in PL/SQL script:
Set serveroutput on;
Set feedback off;
DECLARE
recursion_counter NUMBER: = 0;
function countNum (OUT int counter) return a Boolean value is
Start
dbms_output.put_line (Counter);
If counter > 10 then
Returns true;
on the other
counter: = counter + 1;
countNum (counter);
end if;
end countNum;
BEGIN
dbms_output.put_line (case when countNum (recursion_counter) then end if 'false' to 'true');
END;
I get the following error:
PLS-00221: 'COUNTNUM' is not a procedure or is not defined
and I would really like to know why. The error refers to this line:
countNum (counter);
DECLARE
recursion_counter NUMBER: = 0;
function countNum (int counter) return a Boolean value is
Start
dbms_output.put_line (Counter);
If counter > 10 then
Returns true;
on the other
Return countNum (counter + 1);
end if;
end countNum;
BEGIN
dbms_output.put_line (case when countNum (recursion_counter) then end if 'false' to 'true');
END;
/
0
1
2
3
4
5
6
7
8
9
10
11
true
SQL >
SY.
-
How to "end" to the function definition in SQL like?
I'm using Oracle 11 g and SQL Plus.
I'm trying to define a function and return to the SQL command prompt, but it is simply not to leave the function definition.
SQL > create function dept_count (dept_name varchar (20))
2 returns whole
3. start
4 declare entire d_count;
5. select count (*) in d_count
6 the instructor
7 where instructor.dept_name = dept_name
8 return d_count;
9 end
10;
11
12
13
14
15
16.
end 17 dept_count;
18;
19
20; <-I expect the SQL > invite here, but it is not.
What should I do? Help, please. Thank you.Try this please
. . . SQL> end ; SQL> /
-
NULL in PL/SQL SELECT statement..
Hi all
I need to use as a result of a SELECT statement in my function to get PCODE from the table. Cur_rec here. CODE comes from cursor that runs before the declaration.
SELECT PCODE in v_pcode TABLE_XYZ where CODE = cur_rec. CODE and PCODE = 'VIEW '.
Now the problem is the part of the CODE has all the information in the table TABLE_XYZ. In this case, it triggers an error NO_DATA_FOUND. To solve it, I can put a part of the EXCEPTION and handle it. But I think in another way...
If there is no data for a CODE, the default value of v_pcode would be 'No Code'. I tried to use the NVL function, but it does not work here as a SQL SELECT statement.
Can someone give an idea how to achieve this?Hello
declare ... v_cnt number; begin SELECT count(*) into v_cnt from TABLE_XYZ where CODE = cur_rec.CODE and PCODE='SEE'; if v_cnt=0 then v_pcode = 'No code'; else v_pcode = 'SEE'; end if; end;
Bartek
Maybe you are looking for
-
MacBook Pro crashed after update to macOS Sierra
After I tried to update my MacBook Pro for macOS Sierra, this screen came: In case you can't read it, it says "apple.com/support-1007F'. After restart my MacBook Pro, he asked for my Wi - Fi connection information, so I typed in it and it showed a lo
-
He repeats to me follows her, ' there's a problemwith a previous purchase.» Update your payment method. But there is nothing wrong with my card? (so I can't download apps or update even tho it free it says purchase)
-
I can't update the Skype. It shows the error code 1638. I can't uninstall Skype because I can't find the Skype program in Control Panel. The computer is running windows 7, 64 bit.
-
Event time missing in iCalendar El captain
Since the upgrade to El Cap", apparently I have more option of > iCal Preferences > General > Show events time. Is there a work around for the time of the event see according to iCal monthly? All entries received with gratitude - thanks in advance
-
I am installing lightroom, but it keeps failing and gives me the following error:ERROR: DF014: unable to create the symbolic link to '\\fs01\folderredirect$\e009278\Documents\... \Desktop\Adobe Lightroom.lnk "(Seq 6641).". "I tried several facilities