This plsql function is considered ok?
This plsql function is considered ok? The reason that I ask is that the results are different when called within a packet vs appeal during a procedure. I don't know if this is a bug or if it is illegal.
CREATE OR REPLACE package body test as function test return varchar2 is begin htp.prn('ABCDEF'); return 'xyz'; end; end;
When this function is called inside a package, the string 'ABCDEF' will appear out of sequence. I think it's because of the in-Lining, 11 g the function at compile time.
Whereas, when the function is called during a procedure the string 'ABCDEF' appears in the browser html properly.
The service is technically do stuff how to output data from htp.prn, then Oracle can judged illegal. I have a very good reason for wanting this feature, so before you take a different approach, I wanted to ask around.
The question is how the statements are executed by the PL/SQL engine.
Consider the statement:
HTP.p (' test1 ' |) FuncTest() ' | 'test2');
To run it, all nested 'objects' must be resolved and executed first. Think of the execution path inside-to-outside.
If FuncTest() is executed first. He puts a string into the buffer of HTP. The result of the function is concatenated and created a unique string literal. This literal is now the parameter in the call to htp.p (). Who then adds, after FuncTest(), a string to the buffer of HTP.
I disagree with your statement that it behaves differently in the procedures as packages. I created 3 test cases for the foregoing. Anonymous block (run immediately the text code execution). Individual objects (separate procedure and function). Single object (procedure and function wrapped in a box).
Each product, as expected, the same result.* how the engine of PL/SQL treats the path of execution of instructions, does not change because the statement is in a packed and not a stand-alone procedure.
* 11.2.0.2 using SST 11 g Server (Apache v2 and v2 mod_plsql).
Tags: Database
Similar Questions
-
PLSQL function to return the result of the query
Dear all,
Oracle Database SE1 11.2.0.1
I need to create a plsql function which should accept SQL as a parameter, execute it and return the result set.
Is this possible?
Madhu.149 wrote:
I need to create a plsql function which should accept SQL as a parameter, execute it and return the result set.
Be careful - results games indicate a set of data stored in memory. This is not what are sliders. This isn't how Oracle should be used.
Imagine that you implement such a result set function - which, on average, requires 1 MB of memory (private server) to store the results of the SQL query. A 100 users mean a 100 MB of memory required server. This is not suitable. Not at all. Never.
The correct back 'thing' is a handle to SQL cursor (called a ref cursor in this case). A SQL cursor is a "program" - that the appellant runs via the fetch command and generates one or more lines accordingly. Appellant repeatedly runs this slider through calls to fetch until this slider found and returns all rows affected (using consistent readings).
If you want an abstraction interface that the client can call via PL/SQL code in the database, so this crafting optimal SQL interface, creates the SQL cursor and returns the handle of the cursor (via the ref cursor data type) to the client.
-
error in calculation PLSQL function
Hi friends,
I have the plsql function below that throw error.
The function below is written in Apex, if kindly let me know how to solve this error
The following query checks the existing value and null assigns a value to the select statement. otherwise will assign it to the variable. I don't get how to set dynamically using the select statement
Function:
BEGIN
IF
: P1_VARIABLE_NAME IS NULL THEN: P1_VARIABLE_NAME: = select... from... (which returns a string)
ON THE OTHER
: P1_VARIABLE_NAME
END
END
Error:
Met the "SELECT" symbol when awaits one of the following numbers: (- + case mod new avg not null current County exists prior min max sql stddev sum variance execute forall time timestamp interval date fusion pipe)Hi Pradeep,
Have you used the suggestion in the post above?
(Do not use the PL/SQL only the suggested above query block)
Did you put a semicolon after the query?
And you always use the PL/SQL code?Could you post details of calculation?
Kind regards
Kiran -
ERR-9131 error in the body of PLSQL function for default code point, the point =
Hi all
I am filling a field element of text in two different ways, but on the same page:
1 - the page is called to change the values inside-> value of the element comes from field of database
2 - the page is called to insert new values-> value of the element comes from a calculated function that returns a default value
Point features:
Source->
always replace any existing value in session state
database column
-> Default
-----------------------------------------------------------------------------------------------------------------------------
default value
------------------------------------------------------------------------------------------------------------------------------
DECLARE
NUMBER OF THE LINHA;
gene number;
i_emp varchar2 (32000);
v_sql2 varchar2 (32000);
BEGIN
i_emp: =: P62_EMP_COD;
IF: P62_RDD_LIN IS NULL THEN
LINHA: = 1;
ON THE OTHER
LINHA: =: P62_RDD_LIN;
END IF;
v_sql2: =' select '. i_emp |'. Grh_1_utils. GRHFU_RUB_DEFAULT ('|: P62_ENT_COD |', 'R' ' |: P62_REM_COD |', 1, 1000000, to_date null, "D", ("' |: P62_DAT_INI |")) (', "DD/MM/YYYY"),' | LINHA |') the double ';
EXECUTE IMMEDIATE v_sql2 INTO gene;
COMMIT;
return deciphered;
end;
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
default value - body of the PL/SQL function
The error I get is:
ORA-00936: lack of expression
ERR-9131 error in PLSQL function for default code point body, item = ITEM_TO_POPULATE
Something is wrong with my function or is a different, better way to do this?
Cordially Pedro.Hello
You can do some tests?
(1) try to make this code first (to make sure that the P62_EMP_COD is not null when running):DECLARE LINHA NUMBER; defeito number; i_emp varchar2(32000); v_sql2 varchar2(32000); BEGIN i_emp := :P62_EMP_COD; IF :P62_RDD_LIN IS NULL THEN LINHA:=1; ELSE LINHA := :P62_RDD_LIN; END IF; v_sql2:='select '||i_emp||'.Grh_1_utils.GRHFU_RUB_DEFAULT('||:P62_ENT_COD||',''R'','||:P62_REM_COD||', 1 , 1000000,''D'',null,to_date('''||:P62_DAT_INI||''',''DD/MM/YYYY''),'||LINHA||') from dual'; EXECUTE IMMEDIATE v_sql2 INTO defeito; COMMIT; return defeito; end;
(2) then you can try to change your source, by changing 'replacement always of value that exists in the session state' "only when null.
(3) enter your variable dynamic SQL code and check it out:
DECLARE LINHA NUMBER; defeito number; i_emp varchar2(32000); v_sql2 varchar2(32000); BEGIN i_emp := :P62_EMP_COD; IF :P62_RDD_LIN IS NULL THEN LINHA:=1; ELSE LINHA := :P62_RDD_LIN; END IF; v_sql2:='select '||i_emp||'.Grh_1_utils.GRHFU_RUB_DEFAULT('||:P62_ENT_COD||',''R'','||:P62_REM_COD||', 1 , 1000000,''D'',null,to_date('''||:P62_DAT_INI||''',''DD/MM/YYYY''),'||LINHA||') from dual'; return v_sql2; EXECUTE IMMEDIATE v_sql2 INTO defeito; COMMIT; return defeito; end;
(4) prevent your run immediate code of SQL Injections using the link:
DECLARE LINHA NUMBER; defeito number; i_emp varchar2(32000); v_sql2 varchar2(32000); BEGIN i_emp := :P62_EMP_COD; IF :P62_RDD_LIN IS NULL THEN LINHA:=1; ELSE LINHA := :P62_RDD_LIN; END IF; v_sql2:='select '||i_emp||'.Grh_1_utils.GRHFU_RUB_DEFAULT(:1,''R'',:2, 1 , 1000000,''D'',null,to_date(:3,''DD/MM/YYYY''),:4) from dual'; EXECUTE IMMEDIATE v_sql2 INTO defeito USING :P62_ENT_COD, :P62_REM_COD, :P62_DAT_INI, LINHA; COMMIT; return defeito; end;
Best regards, Kostya Proskudin
-
When I'm on a Youtube video that is running and I want to move to a different tab, Ctrl + < number of tab > doesn't work, is this intended functionality?
This can happen when the video player (Flash plugin) has focus.
In this case the plugin consumes all key presses.
You will need to click with the mouse on the page or in the UI to work keyboard shortcuts. -
New user trying to create this simple function of Xcode
I'm a programmer windows trying to learn Xcode / swift.
How can I get this simple function to work?
He complains about the pi in the line "access to".
I hope this is enough information.
Thank you
disp_to_acceleration Func (freq: Float, disp: Float)-> {Float
Let pi = M_PI
Let accel = disp * 2 * powf (freq * pi, 2.0)
Back to accel
}
Oops error in the post "Let's accel.
-
Is there a default value for the color management in PSE10? Beautiful photos from iPhoto, but blur with elements. I need help with this before as I consider that the upgrade to PSE13 and beyond.
Printing which forms an angle seems ok, but one that is horizontally seems faded, incomplete.
I was wondering if I saved a layer somewhere and set it as a default value.
If you group the layers, you will be left with a single layer, thus spreading your concern.
Suggest that you do the following:
- Make sure you have the latest drivers for your printers
- Reset the default preferences.
Hold the Alt, Ctrl + Shift keys when you click the icon to open the items. When asked if you want to delete the settings file, say Yes.
Items nearby and let regenerate the file.
-
Validation - PLSQL function Boolean return bug?
Request Express 4.1.1.00.23 (and all earlier versions I've ever used)
When you use the wizard to create a Validation of type "Function PLSQL return Boolean", why is - this mandatory to enter a value in the field "Error" on the screen that follows? This message is never used because the message actually comes from a PLSQL return statement.
PaulPHello
Well, there is still this red asterisk, you cannot enter anything in the text of the error.
If you leave the field blank, Assistant does not raise any validation error.I think that asterisk is just because they have reuse same wizard page.
Kind regards
Jari
-----
My Blog: http://dbswh.webhop.net/htmldb/f?p=BLOG:HOME:0
Twitter: http://www.twitter.com/jariolai -
Call the function C external plsql - function of mapping error ORA-06521
Dear all,
I have the following C code:
I created the library (.so) shared, created the library in Oracle DB, set up the extproc earphone and etc.class Factorial { public: int getVal (int a); }; #include "Factorial.h" int Factorial::getVal (int a){ if(a!=1){ return(a * getVal(a-1)); } else return 1; }
Also, I created the following plsql code:
When I am trying to run this function always get ORA-06521. I changed the types of data - but nothing has changed.CREATE OR REPLACE PACKAGE c_pack AS function factorial_func(x in pls_integer) return pls_integer; END; / CREATE OR REPLACE PACKAGE BODY c_pack AS function factorial_func(x in pls_integer) return pls_integer as language c library sys.c_factorial name "getVal"; END; /
Help, please.
Just in case, listener.ora
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) ADR_BASE_LISTENER = /u01/app/oracle SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=/u01/app/oracle/product/c_lib/factorial.so, LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib") ) )
[oracle@db admin]$ lsnrctl status listener LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-FEB-2013 21:24:36 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias listener Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 04-FEB-2013 21:23:37 Uptime 0 days 0 hr. 0 min. 58 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/db/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully [oracle@db admin]$
Hi 952942,
The following code works fine:
int getVal (int a){ if(a!=1){ return(a * getVal(a-1)); } else return 1; }
Compile and create the shared library:
gcc -fPIC -c factorial.c gcc -shared -o factorial.so factorial.o
Package:
CREATE OR REPLACE PACKAGE c_pack AS function factorial_func(x in binary_integer) return binary_integer; END; / CREATE OR REPLACE PACKAGE BODY c_pack AS function factorial_func(x in binary_integer) return binary_integer as language c library sys.c_factorial name "getVal"; END; /
It works:
begin dbms_output.put_line(c_pack.factorial_func(5)); end; 120
Best regards
Gena -
Need help with rewrite PLSQL function EVALUATE
Hi all
I'm trying to convert some PLSQL (from Discoverer) in a column of answers and I can't seem to get the correct formula.
The original formula:
MIN (Processed_Date) MORE (SCORE OF Business_Area, product, Serial_No)
I guess that this must be done in an evaluation function, but I can't work on the correct syntax.
This formula:
Evaluate ('MIN (%1) OVER (PARTITION OF 2%, 3%, 4%)) ", Business_Area, Processed_Date, Serial_No, product)
Has generated this error:
[nQSError: 10058] A general error occurred. [nQSError: 22027] Union of incompatible types. (HY000)
I do not know what causes the error, and tried casting explicitly throughout the column, but still getting errors.
I am open to any suggestion.
Thank you.
Published by: jasonr on Dec 14, 2010 09:54Jasonr,
highlighted in bold is the change
Try this EVALUATE ('MIN (%1) OVER (PARTITION OF 2%, 3%, 4%)) AS the DATE, Processed_Date, Business_Area, product, Serial_No)
update if it solved your problem.-bifacts
http://www.obinotes.com
JPublished by: bifacts on December 14, 2010 21:52
-
unexpected problem with the permission of type plsql function scheme
Hello
I created a schema authorization function plsql type returning a Boolean. Authorization scheme is for pages only. p2_user_priviledge is a textbox control on the home page that retrieves privilege (list of the pagenos) to the user of the database connection. Homepage has no required permissions. SCHEMA AUTHORIZATION always returns false. I am not able to trace problem in my code. same code works fine for failure to the 'c' of return area.
-CODE OF AUTHORIZATION SCHEME-
declare
PageID varchar2 (10);
VARCHAR2 (300) of privilege;
c number (3);
Start
PageID: = ": P" | to_char(:app_page_id) |': '; -NUMPAGE stored in format *: P2: *
privilege: = trim(:p2_user_priviledge); ++-List contain privileges like: P2:P13:P67:P23: etc +++ select instr (privilege, pageid) in c to double;
If c > 0 then
Returns true;
on the other
Returns false;
end if;
end;
------------------------------------------------------------------------------------------------------------------------------------------
Another problem is again related to the authorization scheme.
I created an application and schema of an authorization (auth_aug), which worked fine. Then, after a few days, I added more than 10 pages for the same application, but now autho_aug always returned false for new pages. Then I copied the code from the "autho_aug" to the new "autho_sept" regime, and it worked for new pages. I do not understand if code is the same for both system, why had to use two different schemas.
Now, I've added a few pages more enforcement and problem mentioned earlier.
any solution to the two problems...Hello
You can create a component of demand through the shared components in your application, elements of Application option. All you do here is to create a new item and give it a name.
Once this is done, the element can be used as if it were a page element. You can use an Application (also available through shared components) calculation to set the value of this element in the list of page numbers and the value can then be retrieved in a SQL statement or PL/SQL.
You cannot use the popup window Session to change elements from page or application - you will need to create a calculation or process to do.
Andy
-
On Windows XP, there is a search function to search for a string in any kind of files on your computer. You are looking for a specific name was easy, if you fogort what kind of file, this name occurred in or what it was named.
On Windows 7 it only allows searching for a name of a file. How to search for strings in file names? 29/12/12 Paul Figueroa
Oh, what you want is the content property.
content: ~ = Figueroa
[Update: apparently special search symbols such as ~ = do not work with the content when property indexed research places, but work during the search in unindexed locations.]
I should mention that Windows 7 Search is not case sensitive, so it makes no difference to try to find upper or lower case letters. In addition, Windows 7 Search is not able to search the contents of files that have no file extension. There is also a weird question having to watch in Indexing Options to determine which file extensions are defined for content, research, where you have a type of unusual file that is not defined for the content of the search.
-
Hello
I have problems with calling function in CO as follows:
This function takes sysdate as parameter with the data type date and logical in CO as
Date of convertedDate = AM.getOADBTransaction () .getCurrentDBDate ();
System.out.println ("convertedDate" + convertedDate);
If (convertedDate! = null)
{
[Serializable] param = {convertedDate};
String caseno = AM.invokeMethod ("callPlSqlFunction", param) m:System.NET.SocketAddress.ToString ();
throw new OAException (caseno, OAException.INFORMATION);
} else {}
throw new OAException ("Please select sysdate.",
OAException.ERROR);
}
Am:
public String callPlSqlFunction (Date convertedDate) {}
String caseInfo = "";
String stmt = ' START: 1: = UTIL_PKG.caseno_fiscal(:2); end; « ;
CallableStatement cs =
getOADBTransaction () .createCallableStatement (stmt, 1);
try {}
cs.registerOutParameter (1, Types.VARCHAR);
cs.setDate (2, convertedDate);
CS. Execute();
caseInfo = cs.getString (1);
CS. Close();
} catch (Exception e) {}
e.printStackTrace ();
}
Return caseInfo;
}
The issue is at cs.setDate (2, convertedDate)... He does not accept this condition for some reason any.
Help, please.
Thank you
You have this job?
-
Hi all
I have the java as code: -.package com.demo.test; import java.util.ArrayList; import java.util.List; public class ListTest { public List<String> getList() { List listA = new ArrayList(); listA.add("element 1"); listA.add("element 2"); listA.add("element 3"); listA.add("element 4"); listA.add("element 5"); listA.add("element 6"); listA.add("element 7"); return listA; } }
I create the function to call java: -.
create or replace FUNCTION get_list return varchar2 as language java name 'com.demo.test.ListTest.getList() return java.lang.String';
I want to call above function in plsql and I out like: -.
Element1
item2
3
Item4
element5
element6
Element7
Please help me.
Thank you
Xandotcreate or replace and compile java source named ListTestSrc as package com.demo.test; import java.util.ArrayList; import java.util.List; import java.sql.*; import oracle.sql.*; public class ListTest { public static ARRAY getList() throws SQLException { List listA = new ArrayList(); listA.add("element 1"); listA.add("element 2"); listA.add("element 3"); listA.add("element 4"); listA.add("element 5"); listA.add("element 6"); listA.add("element 7"); Connection conn = DriverManager.getConnection("jdbc:default:connection:"); ArrayDescriptor dsc = ArrayDescriptor.createDescriptor("VARCHAR2_TABLE", conn); return new ARRAY(dsc, conn, listA.toArray()); } }
create or replace type varchar2_table as table of varchar2(4000); / create or replace function get_list return varchar2_table as language java name 'com.demo.test.ListTest.getList() return oracle.sql.ARRAY'; /
SQL> select * from table(get_list); COLUMN_VALUE --------------------------------------- element 1 element 2 element 3 element 4 element 5 element 6 element 7 7 rows selected.
If you want to use the collection in a SQL query (as above) and if the collection is large, you can do in pipeline.
See a similar example here: Re: Re: how to select csv data stored in a BLOB column as if it were an external table?
Otherwise, just use it directly into the PL/SQL code:
SQL> set serverout on SQL> SQL> declare 2 v_list varchar2_table := get_list(); 3 begin 4 for i in 1 .. v_list.count loop 5 dbms_output.put_line(v_list(i)); 6 end loop; 7 end; 8 / element 1 element 2 element 3 element 4 element 5 element 6 element 7 PL/SQL procedure successfully completed.
-
Call the PLSQL function - ORA-31013: XPATH not valid expressioon
I tried the following SQL statement. When I called the function, it in error.
Select *.
Since the release of v$.
----
1 Oracle Database 10 g Enterprise Edition release 10.2.0.3.0 - 64bi 2 PL/SQL version 10.2.0.3.0 - Production 3 CORE 10.2.0.3.0 Production 4 AMT for Linux: release 10.2.0.3.0 - Production 5 NLSRTL Version 10.2.0.3.0 - Production function READ_SYSTEM_RESPONSE (PARAM IN CLOB)
RETURN NUMBER
AS
" l_namespace varchar2 (1000): =' xsi: schemaLocation =" http://www.UNECE.org/CEFACT/namespaces/StandardBusinessDocumentHeader ' PackageProxy.xsd '
xmlns:sh=" http://www.UNECE.org/CEFACT/namespaces/StandardBusinessDocumentHeader "
xmlns:ef=" http://www.efatura.gov.tr/package-namespace "
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "';
XmlType x
: = XMLTYPE ("<?") XML version = "1.0" encoding ="UTF - 8"? >
" < sh: StandardBusinessDocument xsi: schemaLocation =" http://www.UNECE.org/CEFACT/namespaces/StandardBusinessDocumentHeader ' PackageProxy.xsd '
xmlns:sh=" http://www.UNECE.org/CEFACT/namespaces/StandardBusinessDocumentHeader "
xmlns:ef=" http://www.efatura.gov.tr/package-namespace "
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance ">
< sh: StandardBusinessDocumentHeader >
< sh: HeaderVersion > 1.0 < / sh: HeaderVersion >
< / sh: StandardBusinessDocumentHeader >
(< / sh: StandardBusinessDocument > ');
Ana CURSOR IS
SELECT 1 - EXTRACTVALUE (VALUE (p),'/ sh: StandardBusinessDocumentHeader/sh: HeaderVersion', l_namespace) AS IMZA
TABLE (XMLSEQUENCE (EXCERPT of (x,'/ sh: StandardBusinessDocument', l_namespace))) p;
BEGIN
FOR ana IN r
loop
dbms_output.put_line ('-');
end loop;
RETURN 1;
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line (SQLERRM);
RETURN 0;
END;
Delete this l_namespace chain, it has nothing to do there, it is not a namespace declaration:
"xsi: schemaLocation ="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader PackageProxy.xsd
As a general rule, simply declare the or - prefixes or by default - you need resolve the XPath expression.
Once you correct this part, you will discover that your query returns null.
This is because the XPath expression is not point to any node.
Try this instead:
SELECT EXTRACTVALUE)
VALUE (p)
, ' / sh: StandardBusinessDocument/sh: StandardBusinessDocumentHeader/sh: HeaderVersion'
l_namespace
) AS IMZA
TABLE)
XMLSEQUENCE)
EXTRACT (x, ' / sh: StandardBusinessDocument', l_namespace)
)
) p
;
Maybe you are looking for
-
Can satellite L550 - I put the CPU?
Hello The L550 model is to come up with a core duo T6500 2.1 Ghz intel processor. I was wondering if I could replace the processor by a more a veloce as: Pentium Dual - Core E6600 @ 3.06GHz? Complies with the power and cooling system? Concerning
-
error 0x800106ba my windows defender is turned off and turns back on
Why doesn't windows Defender back on?
-
I can't remove all shortcuts... Help, please
I can't delete shortcuts on my desktop... "" When I try it says "fichier file in use, close the file and try again ' no files are open? Please help my office is full of random shortcuts
-
was a Director but lost? Why &#62; how do I get it back? __
now have a standard account and an account invited but lost my original administrative account! How can I get rid of the standard and comments and retrieve my admin? I am alone here! Chris Brandon
-
NAC does not insert the CASE.
Hello I have a problem when going to insert a Nac server in our manager of the NAC, the message that appears is "failed to add the server: Maximum limit for access servers own supported has been reached", but I Don t no matter what server do not have