Creating a package to store common varchars in table inserts
I have multiple tables that have default values for columns instead of null. They occur frequently in multiple tables so I assume the best and easiest solution would be to create a package. However i get this error when doing the follow:
ORA-06553: PLS-221: 'DEFAULT_TBD' is not a procedure or is undefined
CREATE OR REPLACE PACKAGE Globals
IS
var1 VARCHAR2(40);
END Global_variables;
CREATE OR REPLACE PACKAGE BODY Globals
IS
BEGIN
var1 := 'n/a';
END Global_variables
Create table temp (
names VARCHAR2(40)
insert into temp values (Global_variables.var1) <<<< causes error
Or is it better to specify default values during table creationThis is the best approach for a number of reasons. Firstly, it is the standard approach, so anybody else who has to work on your database knows where to find the default values...
SQL> create table tab23 (id number, usr varchar2(10) default 'APC')
2 /
Table created.
SQL> select column_name, data_default from user_tab_columns where table_name = '
TAB23';
COLUMN_NAME DATA_DEFAULT
ID
USR 'APC'
SQL>Secondly, the whole point about default values is not having to include them in the INSERT statement....
SQL> insert into tab23 (id) values (1)
2 /
1 row created.
SQL> select * from tab23
2 /
ID USR
1 APC
SQL>
im not sure if this is a bad idea hardcoding the value incase it were to change.Change is easy enough to handle....
SQL> alter table tab23 modify usr default 'DAD'
2 /
Table altered.
SQL>
SQL> insert into tab23 (id) values (2)
2 /
1 row created.
SQL> select * from tab23
2 /
ID USR
1 APC
2 DAD
SQL>Cheers, APC
blog: http://radiofreetooting.blogspot.com
Similar Messages
-
Create a file and store it in the database using UTL_FILE package
Hello.
I'm using UTL_FILE package to store data from a table into an excel file but I don't know how to store this file in a table with a BLOB field the database at the same time. I want do do this because I will use it in a Oracle Portal.
Anybody has any idea how to do this?
Thanks & Regards,
AlexandraFrom Asktom
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:232814159006 -
Another controversy: Where to store common application parameters?
For higher flexibility, application parameters are usually set. For intranet applications, I used to store these parameters with my Oracle database. Now I'm developing a web-based internet applications, would you please advise for the following questions:
1) The place to store common application parameters (How to set and how to retrieve?)
(Currently, I have put such application parameters into a class file. Although it should be faster than retrieval from database, it means that I need to re-compile in case of any changes are made for those parameters. Can I set up some global constant for my application with my JDeveloper? How to set and how to retrieve?).
2) The place to store the application configuration and application package string
(As you see, if you have many Jsp page, it's not convenient to change the <jbo:ApplicationModule ... Configuration="MyConfig"... /> all the time. It may be better if it could be generalized by a variable. I have found the configuration in the "web.xml" file, but i don't know how to retrieve the value from it. Currently, I have made use of my old approach mentioned in Question 1 - place the configuration string in a common class ... the drawback has already been mentioned as above ... any better solutions?)
Thanks for replying!Curt,
To create an AM using the definition in the cpx file:
JUApplication app = JUMetaObjectManager.createApplicationObject("Project2.am");
ApplicationModule am = app.getApplicationModule();.
This is the same call used by JClient application.
Here is the story with BC4J runtime params:
jbo.default.language
This parameter is used in localization.
jbo.default.country
This parameter is used in localization.
DeployPlatform
The platform on which the business components are deployed:
LOCAL - The web module of Oracle 9iAS
EJB_IAS - The EJB module or Oracle 9iAS
VB - A VisiBroker CORBA server
WLS - a WebLogic application server
Connection Mode
For business components deployed to VisiBroker, the connection
mode used:
1 - colocate mode
2 - remote mode
3 - IOR mode
4 - bind mode
For more information, see the VisiBroker documentation.
HostName
For all deployment platforms except LOCAL, the name of the
application server hosting the business components.
ConnectionPort
For all deployment platforms except LOCAL, the port of the
application server hosting the business components.
ApplicationPath
For all deployment platforms except LOCAL, the JNDI path to the
business components.
java.naming.security.principal
For all deployment platforms except LOCAL, the username for the
IIOP connection to the business components.
jbo.use.pers.coll
Setting this to true enables view row spillover. If you are working
with large rowsets and memory is a problem, this property should be
true. For more information, see the Oracle JDeveloper documentation.
jbo.pers.max.rows.per.node
The maximum size of a node for view row spillover.
jbo.pers.max.active.nodes
The maximum number of nodes that will be cached in memory for view
row spillover.
jbo.fetch.mode
AS.NEEDED causes view objects to only fetch rows when they are
requested. ALL causes them to fetch the entire results of their
queries.
MetaObjectContextFactory
The default value uses the business components framework's
MetaObjectContext Factory, which stores business components metadata
in XML. If you want to use a different format for business components
metadata, you can implement your own MetaObjectContext Factory.
IsLazyLoadingTrue
For all deployment platofrms except LOCAL, setting this property to
true will cause business componetns metadata to be loaded into memory
only as needed, whereas setting it to false will cause all metadata
to be loaded into memory immediately. Lazy loading is mandatory in
LOCAL mode.
Factory-Substitution-List
The list of business components to substitute out. See the Oracle
JDeveloper documentation for more information on substituting
business components.
jbo.project
The project containing business components to be substituted for old
ones, if Factory-Substitution-List is not empty.
jbo.max.cursors
The maximum number of cursors the business components may have open.
The framework will clean up free JDBC statements as the number of
cursors approaches this number.
do.failover
This property is true if application module failover is enabled.
Setting this property to false provides better performance at the
expense of reliability.
jbo.doconnectionpooling
This property is true if application modules are allowed to share
connections. For more information about connection pooling, see the
Oracle JDeveloper documentation.
jbo.recyclethreshold
The recycle threshold for application module pooling. When the number
of application modules in the pool reaches this level, the pool
begins to recycle application modules in stateful mode. Monitoring
the application module pool statistics may help you decide on a good
value for this field.
jbo.ampool.highwatermark
The maximum number of application modules allowed in the pool. If
this high-water mark is reached, clients must wait for the next
available application module.
jbo.ampool.resetnontransactionalstate
If this property is false, application modules will preserve their
non-transactional state (properties and dynamically added view
object, view link, and nested application module members) even when
they are checked in in stateless mode. If the property is true,
non-transactional state will be reset.
jbo.ampool.sessioncookiefactoryclass
This class creates the session cookies that allow clients to retrieve
application modules in stateful mode. Change this value only if you
need to implement your own custom session cookie factory. See the
Oracle JDeveloper documentation for more information.
jbo.ampool.connectionstrategyclass
This class manages the connection strategy for the application module
pool. Change this value only if you need to implement your own custom
connection strategy. See the Oracle JDeveloper documentation for
more information.
jbo.passivationstore
When an application module is released in stateful mode, its state is
saved when the application module is recycled (or immediately if
failover is enabled). If this property is 'null' or 'database', the
state is saved to the database. If the property is 'file', the state
is saved to a local file.
RELEASE_MODE
The release mode--Stateless, Stateful, or Reserved--used by data web
beans. Other clients specify their own release mode.
jbo.maxpoolcookieage
The maximum age of the browser cookies used to help clients retrieve
stateful application modules. If these cookies do not time out, the
value is -1.
PoolClassName
The class that implements the application module pool. Do not change
this value unless you are using a custom application module pool
implementation. For more information, see the Oracle JDeveloper
documentation.
jbo.maxpoolsize
The maximum size of the JDBC connection pool. If this number is
exceeded, an application module will have to wait for a connection if
none is available.
jbo.initpoolsize
The number of JDBC connections automatically created in the
connection pool, before any requests.
jbo.poolrequesttimeout
The amount of time, in milliseconds, an application module will wait
for an available connection before failing.
jbo.assoc.consistent
If this property is true, the entity rowsets retrieved through
association accessors will include rows that have been added, even if
these changes have not been posted to the database. This property can
reduce performance and so should be turned off if not needed.
jbo.viewlink.consistent
If this property is true, the view object rowsets retrieved through
view link accessors will include rows that have been added, even if
these changes have not been posted to the database. This property can
reduce performance and so should be turned off if not needed.
jbo.SQLBuilder
The SQL flavor generated by view objects:
Oracle - for the Oracle8i or Oracle9i database
OLite - for the Oracle Lite database
SQL92 - for any SQL92-compliant database
DB2 - IBM DB2 Universal Database
jbo.ConnectionPoolManager
The class that manges the connection pool. Do not change this value
unless you are using a custom application module pool manager
implementation. For more information, see the Oracle JDeveloper
documentation.
jbo.TypeMapEntries
The type mappings used by business components:
Oracle - for the Oracle8i or Oracle9i database
OLite - for the Oracle Lite database
SQL92 - for any SQL92-compliant database
oracle.jbo.defineColumnLength
If this is false, business components will not by default define
column length for CHAR and VARCHAR2 columns. In general, this should
only be set to false for NLS applications.
jbo.tmpdir
You can use this parameter to specify a directory for temporary files.
jbo.server.internal-connection
Specifies a connection to use when application module state is saved
to the database. By default, the application module pool will use the
application module's JDBC connection.
SessionClass
The class which implements the oracle.jbo.Session interface, used to
load and store session context throughout a client's lifetime. By
default, the framework uses oracle.jbo.server.SessionImpl. Do not
change this value unless you have implemented a custom session
implementation class.
TransactionFactory
The class responsible for creating database transactions. By default,
the framework uses oracle.jbo.server.DatabaseTransactionFactory. Do
not change this value unless you have implemented a custom
transaction factory class.
jbo.debugoutput
If this property is set to 'console', debug information is displayed
on the console. If the property is set to 'silent', debug information
is not displayed.
jbo.logging.show.timing
Whether to show the time elapsed between debug calls.
jbo.logging.show.function
Whether to show the name of the method that triggered a debugger
call. Setting this property to true will degrade performance.
jbo.logging.show.level
Show the trace level of debugger messages. The lower the trace level,
the more important the message.
jbo.logging.show.linecount
Number the lines of debugger output.
jbo.logging.trace.threshold
Lower this number to display only the most important debugger
messages; raise it to display a larger portion of debugger messages.
jbo.jdbc.driver.verbose
If this property is true, the JDBC driver will run in verbose mode.
For more information, see the JDBC documentation.
jbo.ejb.txn.timeout
For EJB deployment configurations, the number of seconds after the
last database access before the EJB transaction expires.
jbo.ejb.txntype
For EJB deployment configurations, the transaction type:
global - use the JTA UserTransaction interface
local - use straight JDBC
jbo.xml.validation
If true, the XML parser uses strict XML validation.
Charles. -
Creating a Package for Constant Variables
Hi
I expect this should be an easy question for some of you, but I am fairly new to PL/SQL!
Anyhow, I would like to create an PL/SQL Script as a package, which holds a list of Constant Variables, which will be common across a number of PL/SQL Packages rather than having to repeat the constants again and again over a number of files and then having the worry of trying to maintain them all.
Can someone please advise me how to create such a package?
ThanksYou can create the package this way:
create or replace package myconst is
const1 number := 0;
const2 number := 2;
end;
/And you can optionally initialize your constants this way:
create table myconstTable (c1 number, c2 number);
insert into myconstTable values (1,2);
create or replace package body myconst is
begin
Select c1,c2
into const1,const2
from myConstTable;
end;
/And finally you can use it this way:
set serverout on
exec dbms_output.put_line(myconst.const1);
1Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com/2009/12/18/table-elimination-oppure-join-elimination-lottimizzatore-si-libera-della-zavorra/] -
Create a package with one function - Error Ora-00907
Hello,
I want to create a package which should store one function.
The code looks like this:
Package Header:
CREATE OR REPLACE
PACKAGE "PCK_REPORT" AS
TYPE t_varchar2 IS TABLE OF VARCHAR2(4000);
FUNCTION f_tabtostring(i_varchar2 IN t_varchar2) RETURN VARCHAR2;
END;Package Body:
CREATE OR REPLACE PACKAGE BODY "PCK_REPORT" AS
FUNCTION f_tabtostring (i_varchar2 IN t_varchar2) RETURN VARCHAR2 IS
o_string VARCHAR2(32767);
BEGIN
FOR i IN 1 .. i_varchar2.COUNT LOOP
IF i != i_varchar2.FIRST THEN
o_string := o_string || ', ';
END IF;
o_string := o_string || i_varchar2(i);
END LOOP;
RETURN o_string;
END f_tabtostring;
END;Comilation works fine, but when I try to use the function with the following example:
SELECT pck_report.f_tabtostring(CAST(COLLECT(mytable.col1) as t_varchar2)) as column1
FROM mytable;it only returns an error ORA-00902: Unknown datatype.
When I add the package name to the datatype at the cast in the sql statement, it returns an error ORA-00903.
What is my misstake?
Thanks,
Thomascreate a global type, and not in the package :
1* create or replace type t_varchar2 is table of varchar2(100)
SQL> /
Type created.
1 CREATE OR REPLACE PACKAGE "PCK_REPORT" AS
2 FUNCTION f_tabtostring(i_varchar2 IN t_varchar2) RETURN VARCHAR2;
3* END;
SQL> /
Package created.
1 CREATE OR REPLACE PACKAGE BODY "PCK_REPORT" AS
2 FUNCTION f_tabtostring (i_varchar2 IN t_varchar2) RETURN VARCHAR2 IS
3 o_string VARCHAR2(32767);
4 BEGIN
5 FOR i IN 1 .. i_varchar2.COUNT LOOP
6 IF i != i_varchar2.FIRST THEN
7 o_string := o_string || ', ';
8 END IF;
9 o_string := o_string || i_varchar2(i);
10 END LOOP;
11 RETURN o_string;
12 END f_tabtostring;
13* END;
SQL> /
Package body created.
SQL> select col1 from mytable;
COL1
test1
test2
test3
test4
test5
test6
test7
test8
test9
test10
10 rows selected.
SQL> select pck_report.f_tabtostring(cast(collect(mytable.col1) as t_varchar2)) as col1 from mytable
COL1
test1, test2, test3, test4, test5, test6, test7, test8, test9, test10 -
How to create credential in Credential Store Framework?
Hi,
I have a WebLogic 11gR1 installation (on Windows Server 2012 with Oracle backend) and is trying to create credential using Credential Store Framework following steps described in http://www.redheap.com/2013/06/secure-credentials-in-adf-application.html
I tried to do it with WLST and get the following error:
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
wls:/offline> connect('weblogic', '*******', 't3://localhost:7001');
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'SitesDomain'.
Warning: An insecure protocol was used to connect to the server. To ensure on-the-wire security, the SSL port orAdmin port should be used instead.
wls:/SitesDomain/serverConfig> createCred(map="claytablet.sample", key="TestKey"
, user="TestUser", password="blah", desc="First test key");
Traceback (innermost last):
File "<console>", line 1, in ?
NameError: createCred
What do I miss here?
Thanks,
Yu
P.S.: I did not try the other method described in the post which uses Fusion Middleware Control web interface, as I do not seem to have access to that web interface. The "Admin Server Console" that I can access (at http://localhost:7001/console) does not have the link to Domain > Security > Credentials as described in the post.Specifically which bundle of 11gR1 did you download and install? (there are 3 11gR1 download packages here: http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-for-dev-1703574.html)
Its likely that the version you are using does not have JRF (Java Required Files) - if you can confirm the specific bundle of 11gR1 you downloaded and installed. -
Hi,
I have a WebLogic 11gR1 installation (on Windows Server 2012 with Oracle backend) and is trying to create credential using Credential Store Framework following steps described inhttp://www.redheap.com/2013/06/secure-credentials-in-adf-application.html
I tried to do it with WLST (from under Oracle\Middleware\oracle_common\common\bin) and get the following error:
wls:/WcsDomain/serverConfig> createCred(map="ClayTablet.Sample",key="TestKey",user="TestUser",password="blah",desc="Test Key");
Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
For more help, use help(domainRuntime)
COMMAND FAILED due to an unknown reason, Check the stack trace for details
Traceback (innermost last):
File "<console>", line 1, in ?
File "C:\Oracle\MIDDLE~1\ORACLE~1\common\wlst\jpsWlstCmd.py", line 522, in createCred
File "C:\Oracle\MIDDLE~1\ORACLE~1\common\wlst\jpsWlstCmd.py", line 504, in createCredImpl
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:237)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:223)
at javax.management.remote.rmi.RMIConnectionImpl_1036_WLStub.invoke(Unknown Source)
at weblogic.management.remote.common.RMIConnectionWrapper$16.run(ClientProviderBase.java:918)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java: 146)
at weblogic.security.Security.runAs(Security.java:61)
at weblogic.management.remote.common.RMIConnectionWrapper.invoke(ClientProviderBase.java:916)
at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(RMIConnector.java:993)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
javax.management.InstanceNotFoundException: javax.management.InstanceNotFoundException: com.oracle.jps:type=JpsCredentialStore
Thanks,
Yu
P.S. I was using WLST command under Oracle\Middleware\wlserver_10.3\common\bin to do the same and got a different error NameError: createCred and posted a question about that under How to create credential in Credential Store Framework?
After searching for the same error message in the community I tried to switch to WLST under Oracle\Middleware\oracle_common\common\bin and got the error posted here.After extending my domain with JRF and JRF WebService Asynchronous services, I was able to execute "createCred" and "listCred" and so on.
Yu -
How do I create a new apple store account when my phone tells me that I have exceeded the maximum limit on this phone
http://support.apple.com/kb/HT4627
-
My friend created me an itunes store account with his credit card , his credit card is about to expire and they are asking me to re-enter the credit card and security card number .... I don't have these numbers ... How can i create new itunes account without credit card?????
Why do you need to create a new account?
Just change the payment method.
http://support.apple.com/kb/ht1918 -
I have an iMac with 2 internal drives and a multiple user account set-up. Hw do I create a path to store data files on the second drive within an application?
This is the Mac mini forum not the iMac forum however...
Applications written for average users like Photoshop, Word, i.e. GUI based applications provide a 'Save' dialog box which while allow selecting second drives or any drive. The dialob box initially shown might be in the simple mode but you just need to click on the triangle to show the full set of options. You should then see the different drive names amongst other options.
If your referring to an application your writing yourself then you need to build a pathname. This can be in one of two styles depending on the programming system your using. This could be a POSIX style path or a Mac style path.
POSIX = /Volumes/volname/foldername
Mac style = Volname:foldername: -
Is there a way to create my own app store that I can share with employees? I'm thinking apps that we've identified as important or needed, all in one place.
Not exactly your own app store, but close. Apple has an App Store Volume Purchasing Program for Business > http://www.apple.com/business/vpp/
It allows you to purchase apps in any quantity you desire and pay using a company credit card. You will receive a spreadsheet of redeem codes which you distribute to your emloyees. The program guide has complete information > http://images.apple.com/business/docs/VPP_Business_Guide_US.pdf -
Error while creating a package
When I am creating a package which has 3 procedures(x,y,z) I am getting an error saying "Subprogram or Cursor "y" is declared in a package specification and must be defined in the package body. I have put the code in the package body script but I keep getting this error. Please Help.
Surely we will if you can paste the code and the error that you get. Remember to paste the code between[b] [pre] and [/pre] tags to retain the format.
Cheers
Sarma. -
Version error while creating info package of data source 0fi_gl_10
Dear Friends,
I have replicated the data source 0fi_gl_10 into sap bw but while creating info package i am getting error " The DataSource 0FI_GL_10(E01CLNT200) does not exist in object version A". IS the manual activation always should be done for that ?
Regards
NileshHi,
Please check if the veriosn of DataSource is A or not. Sometimes it shows as active but if you open the datasource then it might be in modified version only. Do activate it manually, it will serve your purpose to create a infopackge.
Regards,
Anjum. -
How to check error whilce creating a package
Hi,
I am getting an error while creating a package, individually query is running ok but in package it is showing an error. is there any way to check the error. I am using in TOAD Quest ScriptrunnerWhat kind of error you got? A syntactical one or a logical one? Your schema should have following rights to debug package:
GRANT DEBUG CONNECT SESSION,
DEBUG ANY PROCEDURE TO <Your_Schema><i>
I am using in TOAD Quest Scriptrunner</i>
You can refer the user manual or contact Quest for queries regarding Quest Scriptrunner
*009*
Edited by: 009 on Nov 3, 2010 12:09 AM -
How to create a package in ECC 6.0.
Hi,
Can you tell me how to create a package in ECC 6.0 system?
Thanks in advance,
Regards,
Arnab.Hi,
Thank you for your replies.
Can you tell me the difference and uses of the two types of package I can create from SE21.
i.e. : Package and package interface. any sap link would also be helpful. I need to know where i can use what and what would be helpful for my case.
Regards,
Arnab.
Maybe you are looking for
-
Can't move items in dock -tried several solutions
My problem: I move a dock item to where I want it to be, a moment later the dock moves it down to the end of the dock. I've searched the forums and tried the following solutions to no avail: -Shift dragging items in the dock. -Dragging dock items alo
-
Dear All, We are running icm 7.2.4. from last couple of days we have started getting these errors on our router process. following are the errors that we are getting 11:30:24 rb-rtr Translation route timeout for controller ABC_VRUPG8 (ID 5007), route
-
11g ADF Business Component Browser + ADF BC security
Hi gang I was hoping somebody could help me out with the ADF BC security features as outlined section 28.4.3 of the Fusion Developer's Guide for JDev 11g. 1) I note once you've defined a Policy Store via the ADF Security wizard, each time you run the
-
Hi Experts, I have one Multi provider and under this i have 2 cubes, now as per my requirment i need to build this in another server so how can i Build transports of all the objects, and how to import to another server. and below things are i need to
-
How to downgrade iPod 5g? (IOS 7.1 - IOS 7.0.6)
Ok so I don't really like the IOS 7.1 update so just wondering how I can downgrade iPod 5g from IOS 7.1 to IOS 7.0.6 or something. Thx