How do I compile a new function created inside a package in plsql, to see syntactical error and so on
You can't compile a single function - compile the whole package.
If your concern is about invalidating the whole package in case that function has errors, then
create a standalone function (i.e. outside of the package)
debug it
once it is OK (doesn't have syntax errors, returns result as expected), include it into the package
In addition to #Littefoot's advise I'd say: use a proper GUI. Oracle has a free tool called sql developer. It has a great interface for editing database objects (packages/functions/procedures/triggers). It highlights errors and is very well documented (https://www.thatjeffsmith.com/sql-developer/). Note that is does not point out syntax errors - but once you're a bit used to working with pl/sql they become obvious very quickly.
In Oracle, after compiling a procedure/function/package. If there is an error then the command will return with the message:
ORA-24344: success with compilation error
You can then use:
SHOW ERRORS
or
SELECT * FROM USER_ERRORS;
or, for example, for errors with packages in a specific schema:
SELECT *
FROM ALL_ERRORS
WHERE owner = 'SCHEMA_NAME'
AND type IN ( 'PACKAGE', 'PACKAGE BODY');
Which will list the errors (complete with line numbers and error messages) and you can then debug the procedure/function/package and recompile it.
fiddle
Related
got error when calling package
error is
Error starting at line : 1 in command -
PKG_Generate_GRNo.GenerateGR(TO_NUMBER(:P164_APP_ID,
'9999999'),:APP_USER,:P164_FIRST_NAME,:P164_LAST_NAME,:P164_EMAIL,:P164_SKYPE_ID,:P164_COUNTRY,:P164_DATE_OF_BIRTH)
Error report - Unknown Command
PKG_Generate_GRNo.GenerateGR(TO_NUMBER(:P164_APP_ID,
'9999999'),:APP_USER,:P164_FIRST_NAME,:P164_LAST_NAME,:P164_EMAIL,
:P164_SKYPE_ID,:P164_COUNTRY,:P164_DATE_OF_BIRTH);
Session state protection violation is definitely an Apex error, relating to your page settings. It seems your package is trying to change the state of a read-only page. See this other question.
The item identifier in the error message P164_COURSECOUNT has the same prefix as the parameters you pass to the package (:P164_APP_ID) so presumably they relate to the same page. We know nothing about your application or its architecture, so it's hard to offer concrete advice. Maybe you need to change the page or item settings, maybe you need to change what the package does. Only you can tell the right course of action.
As you didn't post the whole command, a note: you have to enclose it into begin-end block, e.g.
BEGIN
PKG_Generate_GRNo.GenerateGR (TO_NUMBER ( :P164_APP_ID, '9999999'),
:APP_USER,
:P164_FIRST_NAME,
:P164_LAST_NAME,
:P164_EMAIL,
:P164_SKYPE_ID,
:P164_COUNTRY,
:P164_DATE_OF_BIRTH);
END;
/
I have downloaded wxWidgets-3.0.2 and am trying to create a simple FRAME from the main program.
Unfortunately I am receiving multiple errors that are all to do with wxWidgets, NOT my code. This is odd as I am lead to believe wxWidgets should work.
Here are some of the errors I am getting:
*\msw\chkconf.h(19): Error! E080: col(10) "wxUSE_ACTIVEX must be defined."
\msw\chkconf.h(394): Error! E080: col(13) "wxUSE_DATAOBJ requires wxUSE_OLE"
\msw\chkconf.h(414): Error! E080: col(13) "wxMediaCtl requires wxActiveXContainer"
\chkconf.h(1630): Error! E080: col(13) "wxRearrangeCtrl requires wxCheckListBox"
\vector.h(197): Error! E148: col(71) access to private member 'reverse_iterator::m_ptr' is not allowed
\vector.h(187): Note! N392: col(21) definition: 'wxToolTip * * wxVector<wxToolTip *>::reverse_iterator::m_ptr'*
Why am I receiving these messages when wxWidgets is supposed to be ready to go?
Have you configured properly? If not try this link to configure on Windows. Also, you can try to use Linux. It is much easier to set up WxWidgets.
High level steps to installing wxWidgets:
Download ( you appear to have done this )
Build library ( I cannot tell if you have done this )
-OR-
Download binary built libraries if available for your compiler ( what compiler are you using - you haven't told us! )
Build one or two of the sample programs ( It really does not look like you have done this )
NOT UNTIL you have completed all these steps are you "ready to go"
I just wanted to know about some invalid objects which are from Oracle ebs 12.1.3. The list is
CST_LAYER_ACTUAL_COST_DTLS_V
IGW_BUDGET_CATEGORY_V
IGW_REPORT_PROCESSING
FV_FACTS_TBAL_TRX
FV_FACTS_TRX_REGISTER
FV_SF133_ONEYEAR
FV_SF133_NOYEAR
FV_FACTS_TRANSACTIONS
FV_FACTS_TBAL_TRANSACTIONS
ENI_DBI_CO_OBJIDS_MV
PJI_TIME_PA_RPT_STR_MV
POA_MID_BS_J_MV
POA_IDL_BS_J_MV
POA_ITEMS_MV
GL_ACCESS_SET_LEDGERS
LNS_LOAN_DTLS_ALL_MV
OZF_CUST_FUND_SUMMARY_MV
FV_SLA_FV_PROCESSING_PKG
OE_ITEMS_MV
PA_DEDUCTIONS_W
PA_DEDUCTIONS_PUB
PA_DEDUCTIONS_PUB
PA_DEDUCTIONS_W
PA_DCTN_APRV_NOTIFICATION
--object types--
CST_LAYER_ACTUAL_COST_DTLS_V VIEW
IGW_BUDGET_CATEGORY_V VIEW
IGW_REPORT_PROCESSING
PACKAGE BODY FV_FACTS_TBAL_TRX PACKAGE BODY
FV_FACTS_TRX_REGISTER PACKAGE BODY
FV_SF133_ONEYEAR PACKAGE BODY
FV_SF133_NOYEAR PACKAGE BODY
FV_FACTS_TRANSACTIONS
PACKAGE BODY FV_FACTS_TBAL_TRANSACTIONS PACKAGE BODY
ENI_DBI_CO_OBJIDS_MV MATERIALIZED VIEW
PJI_TIME_PA_RPT_STR_MV MATERIALIZED VIEW
POA_MID_BS_J_MV MATERIALIZED VIEW
POA_IDL_BS_J_MV MATERIALIZED VIEW
POA_ITEMS_MV MATERIALIZED VIEW
GL_ACCESS_SET_LEDGERS MATERIALIZED VIEW
LNS_LOAN_DTLS_ALL_MV MATERIALIZED VIEW
OZF_CUST_FUND_SUMMARY_MV MATERIALIZED VIEW
FV_SLA_FV_PROCESSING_PKG PACKAGE BODY
NIB_MV_TB MATERIALIZED VIEW
OE_ITEMS_MV MATERIALIZED VIEW
PA_DEDUCTIONS_W PACKAGE
PA_DEDUCTIONS_PUB PACKAGE
PA_DEDUCTIONS_PUB PACKAGE BODY
PA_DEDUCTIONS_W PACKAGE BODY
PA_DCTN_APRV_NOTIFICATION PACKAGE BODY
So I wanted to know that If I keep them invalid what problem they can cause?
Steps I took to know myself:-
I have searched over Oracle support and google by object name but the only thing i get there is patch no to resolve the issue or in some case that ignore these objects they will do nothing.
If anyone have information about these object and what problem they can cause in application. Please do share.
Thanks in Advance!!!
Tom Kyte, a noted Oracle expert, says
They will fix themselves as they are executed or accessed. I never
worry about some invalid objects -- you'll almost always have some
somewhere.
This is usually true as long as:
the database was installed correctly
patches and upgrades have been installed correctly
you have not changed oracle front end code or oracle database code
data that is being entered remains within expected ranges
Invalid materialized views are not usually significant. In 9, 10 and 11 they appear to become invalid as soon as new data is added to the underlying tables. They can still be used even if they are invalid.
Invalid views are compiled on access and if there are no errors become usable.
The same is true of packages and package bodies: if there are no errors they are compiled on access. How your front end handles the error message before the compilation is not the same for all applications. If you try and access a package that cannot compile due to a code error then you will not get any results and a PL/SQL error is returned.
To see what the cause of your problem is:
compile all invalid objects manually or use dbms_utility.compile_schema( 'YourSchema' );
for anything that will not compile you can find out more with the query
select * from all_errors:
If you find errors in Oracle supplied objects you then have to determine the source:
incorrect install or patching
known Oracle bug that should be patched
known Oracle bug that can be ignored
other cause which is beyond the scope of the question
In Powerbuilder I am trying to update a table (Oracle) with blob but get sqlerror, "Database statement must refer to blob variable". My declaration and updateblob statements are as follows:
blob lblob_newxml
long llong_subid
UPDATEBLOB RP_XML_FORMS SET XML_DOC = :lblob_newxml
WHERE SUBMISSION_ID = :llong_subid
USING SQLCA;
Does anybody know why it is happening and or how to solve this problem? Thanks.
To get more information on this problem and the possible causes, I'd run with one of the database traces turned on. (You can check out database trace options in the Connecting to Your Database manual; link may not be appropriate for your PB version, which you haven't mentioned yet.) This may or may not tell you more, but it tracks everything between the app and when the PB drivers pass the commands "over the wall" to the database's driver.
Good luck,
Terry.
"The PowerBuilder VM can get the SQL syntax for the following types of errors, and passes it to the Transaction object’s DBError event for the following types of errors: ..." (see this page).
If your lblob_newxml is null then use this update statement instead:
UPDATE RP_XML_FORMS SET XML_DOC = NULL
WHERE SUBMISSION_ID = :llong_subid
USING SQLCA;
Please have a look at the following code
Formula.ads
package Formula is
procedure CalculateFormula;
end Formula;
Formula.adb
with Ada.Text_IO; use Ada.Text_IO;
with Formula; use Formula;
package body Formula is
procedure CalculateFormula is
package fom_io is new Ada.Float_Text_IO(Float);
use fom_io;
u : Float;
t : Float;
a : Float;
answer : Float;
begin
put_line("Enter 'U'");
get(u);
put_line("Enter 'T'");
get(t);
put_line("Enter 'A'");
get(a);
answer = (u*t)+ 0.5(a(t*t));
put("Answer is: ");
put(answer,Fore => 1,Aft => 1,Exp => 1);
end CalclualeFormula;
end Formula;
When I run this code, I get the following error
gnatmake -d -PC:\Users\yohan\Documents\Ada\Formula\formula.gpr
gcc -c -I- -gnatA C:\Users\yohan\Documents\Ada\Formula\formula.ads
cannot generate code for file formula.ads (package spec)
gnatmake: "C:\Users\yohan\Documents\Ada\Formula\formula.ads" compilation error
[2013-04-06 03:18:22] process exited with status 4 (elapsed time: 00.22s)
I am very new to Ada. Started coding few hours back. Please help me to get rid of the above issue. Thank you.
EDIT
formula.gpr
project Formula is
for Main use ("formula.ads");
end Formula;
The GPR file shows that you are trying to use a package specification as a main program unit - that doesn't work.
Two ways to fix this: The simplest one is to make "CalculateFormula" a standalone main program in a file "calculateformula.adb" and set this in your project file:
for Main use ("calculateformula.adb");
But if you want to see how packages work, there is a "better" way (in that it gets you to understand what packages are for and how they are used...)
Packages are reusable components : the package spec is all you need to see in order to use them ... but you actually use them in another program. So in this case you would create a main program
with Formula; use Formula;
procedure MyMain is
begin
CalculateFormula;
end MyMain;
and in the .gpr file,
for Main use ("mymain.adb");
And then the compiler will automatically compile the correct packages and find the other issues that Shark has pointed out.
You really don't need a separate Main here, as the "hello world" example showed. However such trivial "main subprograms" (in the correct Ada lingo) are not so unusual, especially for purposes like unit testing packages to be used in more complex apps later.
This is puzzling because there are some big errors that the compiler should be flagging, like:
package fom_io is new Ada.Float_Text_IO(Float);
which isn't withed, and
answer = (u*t)+ 0.5(a(t*t));
because:
= is not the assignment operator; you need :=.
0.5(XXXX) isn't valid multiplication.
Also, there's exponentiation in Ada, so t**2 can replace t*t.
formula.adb
with
Ada.Float_Text_IO,
Ada.Text_IO;
use
Ada.Text_IO;
package body Formula is
procedure CalculateFormula is
use Ada.Float_Text_IO;
u, t, a, answer : Float;
Procedure Prompt( Item : out Float; Name : String ) is
begin
put_line("Enter '"& Name &"'");
get(Item);
end prompt;
begin
prompt( u, "U" );
prompt( t, "T" );
prompt( a, "A" );
answer:= (u*t) + 0.5*( a*t**2 );
put("Answer is: ");
put(answer,Fore => 1,Aft => 1,Exp => 1);
New_Line;
end CalculateFormula;
end Formula;
This corrects the syntax errors you had. The other answer seems right in that this ["cannot generate code for" error] seems to be a problem with the gpr-file rather than the source itself.