How to Unwrap Wrapped PL/SQL Packages? - oracle

For Oracle 12C+ versions, we are wrapping code now . How do we make sure that the correct version of PL/SQL Packages have been deployed. Before we had dba source to check , but after the wrapping of code , it is almost not possible. Is there any good way to know the amendment of the packages/functions ?
Any suggestions on how do people confirm if the correct module has been deployed ?

Probably I would create own static function with this
like
...
function version
return varchar2
as
constant ver varchar2:= '{#ver}';
begin
return $$PLSQL_UNIT||':'||ver;
end;
...

Related

dbms_output.put_line in PLSQL Developer fails with ORA-06502 for strings longer than 32512 chars

This script fails in PLSQL Developer version 14.0.0.1961 (error ORA-06502: PL/SQL: numeric or value error: character string buffer too small):
declare
v varchar2(32767) := rpad('x',32513,'x');
begin
dbms_output.enable(null);
dbms_output.put_line(v);
end;
/
If 32513 is replaced by higher value, it fails too.
If 32513 is replaced by lower value, it works (i.e. prints text without failure).
In SQL*Plus and Toad it works for up to 32767 (this is expected).
In Intellij Idea it works for up to 32766, for 32767 it does not raise exception though prints nothing.
How can I explain such behaviour? The 32512 seems to be interesting constant (I found it in some APEX question, question about blobs and is also mentioned in JDBC tutorial but I miss any connection to described problem.)
Looks like a PL/SQL Developer bug.
In 2013, they said they'll fix it:
it's a bit of a low-level issue, so his may need to wait until version 11.0.
Which version do you use?

Change PDF out put file name dynamically in oracle reports

Please guide how to change output PDF file name at run time
I am using below code in after parameter form trigger but its not working :
:DESNAME := 'INVOICE_'||:P_CLIENT||'.PDF';
Please guide me..
You didn't mention which Reports version you use; up to 6i program that is used to create reports was called "Reports Builder", while later versions use name "Reports Developer". Doesn't really matter, but - if you open Reports Online Help System (navigate to "Help" menu) and search for DESNAME, you'll find which executables can be used to set DESNAME's value. RWBUILDER is not among them. And yes, rwbuilder is Builder's and/or Developer's EXE name.
It means that you're out of luck, at least regarding the way you're trying to set DESNAME's value. You can't set it in any of Reports' triggers. I mean, you can, but it won't take any effect.
However, if you call the report from, for example, a form developed by Oracle Forms, then you'd use RWRUN which can specify DESNAME value and yes, you can dynamically create it.
For some more info, do read Help I pointed you to previously.
Among several ways of calling Reports from Forms, i can suggest you to use adding RP2RRO.pll to your Form :
And then, add parameters related to this pll :
And you may call your reports by this code :
Pr_Print_Rp2Rro('Rep_Invoice','|Prm1|Prm2|','|'||:Prm1||'|'||:Prm2||'|','no','INVOICE_'||:P_Client||'.PDF');
assuming you have two user defined parameters namely : Prm1 & Prm2. And Pr_Print_Rp2Rro is a procedure with the following code :
Procedure Pr_Print_Rp2Rro(
i_rep_name varchar2,
i_prm_name varchar2,
i_prm_val varchar2,
i_param_frm varchar2, -- 'Yes','No'
i_desname varchar2,
i_destype varchar2 default 'FILE'
) Is
plist ParamList;
arr_prm_name owa.vc_arr;
arr_prm_val owa.vc_arr;
Begin
plist := Get_Parameter_List('REPPARAM');
if not Id_Null(plist) then
Destroy_Parameter_List('REPPARAM');
end if;
plist := Create_Parameter_List('REPPARAM');
Add_Parameter(plist, 'PARAMFORM', Text_Parameter, i_param_frm);
Rp2rro.SetDestype(i_destype);
Rp2rro.SetDesname(i_desname);
for i in 1..100
loop
arr_prm_name(i) := substr(i_prm_name,instr(i_prm_name,'|',1,i)+1,instr(i_prm_name,'|',1,1+i)-instr(i_prm_name,'|',1,i)-1);
arr_prm_val(i) := substr(i_prm_val,instr(i_prm_val,'|',1,i)+1,instr(i_prm_val,'|',1,1+i)-instr(i_prm_val,'|',1,i)-1);
if length(arr_prm_name(i)) > 0 then
Add_Parameter( plist, arr_prm_name(i) , Text_Parameter, arr_prm_val(i) );
end if;
end loop;
Rp2rro.Rp2rro_Run_Product(Reports, i_rep_name, Synchronous, Runtime,Filesystem, plist,null);
End ;
As you may have noticed this procedure contains a method Rp2rro.SetDesname(i_desname) which you could use and manage your task to create Report names spesific to your customer, unless you set your Destype parameter as CACHE.

How to find the error causing ora-06575?

Recently I had to write an oracle function, and the error ora-06575 popped up awfully a lot.
Usually it was because of missing colon from assignment, such as: z = 5 (vs. z := 5)
Or a missed ';' at the end of a statement.
Anyway, I was able to create the function, but it failed during execution with that error, and gave no hint as to where the problem was (except that it was in the function).
I wrote same function in MSSQL and Sybase, and both of those actually tried to point me to the place of any errors. So I figure I'm doing something wrong in Oracle - it can't just tell me 'there's an error'.
In oracle I have a statement like this:
CREATE OR REPLACE
FUNCTION...
I'm compiling the function from SQL developer by selecting the function, and pressing F9.
When I select a statement which executes the function, and press F9, I get the ora-06575 error.
If I press F5 to compile the function, it tells me:
ORA-24344: success with compilation error
Compiled.
So I found this website: http://www.dba-oracle.com/t_ora_24344_success_with_compilation_error.htm
But I can't seem to run 'show errors'. When I run it, I get no output that I can see.
Can that only work from sqlplus? I'm using SQL developer, I'd prefer to stick to SQL developer.
Is there something I'm missing? I want it to tell me where the error is.
SHOW ERRORS is a sql*plus command
You can also query the USER_ERRORS view
SELECT line, position, text
FROM user_errors
WHERE name = '<<your_object_name>>'
SHOW ERRORS works in SQL*Developer too (at least in the versions I've used recently, certainly 3.1). You mentioned in a comment that you're connected as SYS, so I really hope you're creating your function explicitly in another schema - I'd avoid this anyway just in case you forget one day, and modifying any of the pre-built schemas (SYS, SYSTEM etc.) is a bad idea. If so you need to prefix the errored object with the schema too:
create or replace function my_schema.x return number is
begin
return sysdate;
end;
/
show errors my_schema.x
When run as a script (F5) this says:
FUNCTION X compiled
Warning: execution completed with warning
3/8 PLS-00382: expression is of wrong type
3/1 PL/SQL: Statement ignored
The first two lines of the output come from the function compilation, the last two from show errors. You can also run the two statements separately with F9 to see the same results.
But I'm not sure how you're getting the ORA-24344, so maybe you're on an earlier version; and it's possible that won't work. A.B.Cade's solution will work whatever your client though.

Oracle SQL Developer - Help for debugging

I am trying to debug a package with in the SQL Developer. The method that i am trying to debug takes 2 parameters
PROCEDURE procedure_name (dblink IN CHAR, bDebug IN BOOLEAN DEFAULT FALSE)
When i click on "Debug" icon, it asks for inputs that i need to give to this procedure. I give
dblink:='linkname';
bDebug:=TRUE;
but when it starts debugging, I see the value of dblink as
'linkname
'
i.e. linkname, lots of spaces and then the ending quote. so when in code i try to do this
`strSrc VARCHAR(120) := 'tablename'||dblink;`
it gives me error that buffer is to small, which makes sense. but why SQL Developer is doing so? how to fix it?
I am guessing your padding is coming from how SQL Developer is defining its variable to bind with (it is probably defining it as a CHAR(4000)). For now, you should be able to get around this in your test code by putting trim() around the dblink variable:
strSrc VARCHAR(120) := 'tablename'||trim(dblink);
Note that this would normally not be needed if the procedure was passed a literal (or a correctly sized CHAR variable, a VARCHAR, etc), like the production code is probably doing.
For debugging purposes, create a wrapper procedure that accepts a VARCHAR2 parameter, then passes it to your procedure; then you debug it in SQL Developer by calling your wrapper.

Oracle "SQL Error: Missing IN or OUT parameter at index:: 1"

I have an Oracle script that looks like the following:
variable L_kSite number;
variable L_kPage number;
exec SomeStoredProcedureThatReturnsASite( :L_kSite );
exec SomeStoredProcedureThatAddsAPageToTheSite( :L_kSite, :L_kPage );
update SiteToPageLinkingTable
set HomePage = 1
where kSite = :L_kSite and kPage = :L_kPage;
Supposedly the last statement is a valid use of a bind variable but when I try to run the script I get this on the last line:
SQL Error: Missing IN or OUT parameter at index:: 1
I'm not sure how to proceed here as I'm not especially proficient in Oracle.
I had a similar error on my side when I was using JDBC in Java code.
According to this website (the second awnser) it suggest that you are trying to execute the query with a missing parameter.
For instance :
exec SomeStoredProcedureThatReturnsASite( :L_kSite );
You are trying to execute the query without the last parameter.
Maybe in SQLPlus it doesn't have the same requirements, so it might have been a luck that it worked there.
Based on the comments left above I ran this under sqlplus instead of SQL Developer and the UPDATE statement ran perfectly, leaving me to believe this is an issue in SQL Developer particularly as there was no ORA error number being returned. Thank you for leading me in the right direction.
I think its related with jdbc.
I have a similar problem (missing param) when I have a where condition like this:
a = :namedparameter and b = :namedparameter
It's ok, When I have like this:
a = :namedparameter and b = :namedparameter2 (the two param has the same value)
So it's a problem with named parameters.
I think there is a bug around named parameter handling, it looks like if only the first parameter get the right value, the second is not set by driver classes. Maybe its not a bug, only I don't know something, but anyway I guess that's the reason for the difference between the SQL dev and the sqlplus running for you, because as far as I know SQL developer uses jdbc driver.
I got the same error and found the cause to be a wrong or missing foreign key. (Using JDBC)
I had this error because of some typo in an alias of a column that contained a questionmark (e.g. contract.reference as contract?ref)
I had issue in SQL Developer because I was using binds incorrectly. Was using this, copied from log:
variable = ?
should be
variable = :variable
Now SQL Developer prompts me for values.
I got the same error sporadically appearing on some user setup, while others were content with the same report. I had my parameters written in altered case and with nordic letters, for example: Henkilö. I changed them to HENKILO, using only upper case and no nordics, and it did the trick.
The driver is some unknown or varying JDBC version to Oracle.
My error desc was originated from some 3rd party bin:
Excel Plugin Error: Failed executing statement (Missing IN or OUT parameter at index:: 4)
SQL Statement failed. Please verify and correct it!

Resources