Need percentage of values used in an identity column
Hi All,
I am very thankful to all of you for the supprt provided at all times.
I am asked to provide the following details about an identity column for a table:
- Database name
- Table name
- Identity column
- Used number of identity values(max of identity values)
- Percentage of used values
- Next identity value to be generated
- Remaining identity value
I was able to get all these information from the global variables in sybase and with some calculations I was able to find all the identity related information as well but it takes time. For istance, the max of the column need to be found before calculating the percentage of used identity values. Since, these tables are huge(smallest table is 95 GB - bad design) the max computation itself takes time. Our Senior production DBA was able to get it with some system stored procedure which he doesn't want to disclose to us. We have requested him to at least guide us in the right direction but we are going nowhere.
I checked all the sybase documentation but did not get much help.
I sincerely request everyone to suggest me the most efficient and simple way to retrieve all this information.
Sybase ASE version is 12.5.3
Identity column
precision - 12
scale - 0
Table size is 95 GB
Table has a unique clustered index on five column and the identity column is one among them.
Please let me know if any information is required.
Thanks a lot in advance.
Regards
Nanda Kumar K
Try this bit of SQL code. Basicallly it leverages the "next_identity" function to determine which value is next to occur for the column and computes the other derived values from that. This also assumes that identity values are uniformly used (ie, no gaps). That's a big assumption but it seems built-in to your question.
select "dbname"=db_name()
,"tablename"=so.name
,"identcol"=sc.name
,"usedvals"=convert(int,next_identity(so.name)) - 1
,"pctused"=str(100.00 *
((convert(int,next_identity(so.name)) - 1))
/ convert(numeric(32),power(convert(numeric(32),10),sc.prec)-1)
,6,2)
,"nextident"=next_identity(so.name)
,"remainident"=convert(numeric(32),power(convert(numeric(32),10),sc.prec)-1) - convert(int,next_identity(so.name)) + 1
from sysobjects so
inner join
syscolumns sc
on so.id = sc.id
where so.sysstat2 & 64 = 64 -- table has identity column
and sc.status & 128 = 128 -- column is an identity column
order by so.name
Similar Messages
-
Initialize the value for an identity column - HANA SPS8?
Can initialize the value for the sequence (_SYS_SEQUENCE_) used for an identity column?
Thank youGot it.
There are two ways a sequence can be reset:
alter sequence "UADMIN_USER"."_SYS_SEQUENCE_210253_#0_#" restart with 1
During a restart of the database, the system automatically executes the RESET BY statement and the sequence value is restarted with the value determined from the RESET BY subquery.
This sequence name I got from
But I also got the following error message when trying the first approach:
CREATE COLUMN TABLE TEST_TABLE (ID integer GENERATED BY DEFAULT AS IDENTITY(start with 2),COL2 VARCHAR(2));
select '"' || SCHEMA_NAME || '"."' || SEQUENCE_NAME || '"' AS SEQUENCE_NAME from SEQUENCES WHERE RESET_BY_QUERY LIKE '%TEST_TABLE%';
INSERT INTO TEST_TABLE(COL2) VALUES('r1');
INSERT INTO TEST_TABLE(COL2) VALUES('r2');
alter sequence "UADMIN_USER"."_SYS_SEQUENCE_210253_#0_#" restart with 1
Could not execute 'alter sequence "UADMIN_USER"."_SYS_SEQUENCE_210253_#0_#" restart with 1' in 259 ms 481 µs .
SAP DBTech JDBC: [383] (at 29): invalid identifier: _sys_ prefix not allowed: _SYS_SEQUENCE_210253_#0_#: line 1 col 30 (at pos 29)
Let me know if you find something better.
Regards,
Pablo Silva -
Equivalent to SQL Server IDENTITY columns in Oracle 8i?
Under SQL Server, my app frequently keys tables using IDENTITY columns which are also used as the only column in the tables primary key. After an INSERT, I typically retrieve the value assigned to the IDENTITY column using:
SELECT @@IDENTITY
I need to port my app to Oracle 8i and wonder if there is a similar concept available. I checked out ROWID and UROWID but they don't sound quite right.
Any idea?You can use the sequence directly in your insert
without use a trigger
For example:
SQL> Create table nn ( c1 number, c2 varchar2(34));
Table created.
SQL>
SQL> CREATE SEQUENCE customers_seq
2 START WITH 5
3 INCREMENT BY 1
4 NOCACHE
5 NOCYCLE;
Sequence created.
SQL>
SQL> insert into nn values (customers_seq.nextval, 'jjj');
1 row created.
SQL> insert into nn values (customers_seq.nextval, 'mmm');
1 row created.
SQL> select * from nn;
C1 C2
5 jjj
6 mmm
SQL>
[email protected]
Joel P�rez -
Error when inserting in a table with an identity column
Hi,
I am new to Oracle SOA suite and ESB.
I have been through the Oracle training and have worked for about 2 months with the tooling.
We have a Database adabter that inserts data in 5 Tables with relations to each other.
Each table has his own not NULL Identity column.
When running/ testing the ESB service we get the error at the end of this post.
From this we learned that the Database adapter inserts the value NULL in the identity column.
We cannot find in the documentation how to get the database adabter to skip this first column and ignore it.
Is this possible within the wizard? Our impression is no
Is this possible somwhere else/
And if so How can we do this?
If anyone can help it would be greatly appreciated
Pepijn
Generic error.
oracle.tip.esb.server.common.exceptions.BusinessEventRejectionException: An unhandled exception has been thrown in the ESB system. The exception reported is: "org.collaxa.thirdparty.apache.wsif.WSIFException: esb:///ESB_Projects/GVB_PDI_PDI_Wegschrijven_Medewerkergegevens/testurv.wsdl [ testurv_ptt::insert(VastAdresCollection) ] - WSIF JCA Execute of operation 'insert' failed due to: DBWriteInteractionSpec Execute Failed Exception.
insert failed. Descriptor name: [testurv.VastAdres]. [Caused by: Cannot insert explicit value for identity column in table 'VastAdres' when IDENTITY_INSERT is set to OFF.]
; nested exception is:
ORABPEL-11616
DBWriteInteractionSpec Execute Failed Exception.
insert failed. Descriptor name: [testurv.VastAdres]. [Caused by: Cannot insert explicit value for identity column in table 'VastAdres' when IDENTITY_INSERT is set to OFF.]
Caused by Uitzondering [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070608)): oracle.toplink.exceptions.DatabaseException
Interne uitzondering: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert explicit value for identity column in table 'VastAdres' when IDENTITY_INSERT is set to OFF.Foutcode: 544
Call:INSERT INTO dbo.VastAdres (ID, BeginDatum, Einddatum, Land, Plaats, Postcode, VolAdres) VALUES (?, ?, ?, ?, ?, ?, ?)
bind => [null, 1894-06-24 00:00:00.0, 1872-09-04 00:00:00.0, Nederland, Wijdewormer, 1456 NR, Oosterdwarsweg 8]
Query:InsertObjectQuery(<VastAdres null />).Hi,
Click on the resources tab in the ESB system/ Project to see the ESB system design and all the components in it.
Click on the Database adapter that you want to edit..and make the necesary changes..
Check this link.
http://download-uk.oracle.com/docs/cd/B31017_01/core.1013/b28764/esb008.htm for "6.8.2 How to Modify Adapter Services" section.
If you are calling a database procedure which inturn makes the insert, you will have to make changes in the database and you job would be much simpler. It seems there are limitations on what you can change in the Database adapter once it is created. Please check the link for further details.
Thanks,
Rajesh -
I need to pass value for Actual GI date field in VL01N t code, I am using BAPI_DELIVERYPROCESSING_EXEC. can any one tell me how can i pass vaule ?
Hi Abdul,
Sorry for my unprecise answer, but you talk about a tcode, but you're using a BAPI Call. Maybe you want to call the transaction in batch mode?
http://help.sap.com/saphelp_erp60_sp/helpdata/de/fa/09715a543b11d1898e0000e8322d00/content.htm
Regards,
Franz -
I need to know how to change the identity (email address) used for the iTunes store as I no longer use that email.
Settings > iTunes & App store.
Tap AppleID, sign out then sign back in.
The Apple ID is right everywhere else. I've synced the phone. I've reset it in Settings on the phone. I've changed it at Apple.
When you write, "I've changed it at Apple, this means you updated yoru old AppleID or you ceated a new AppleID? -
How to use identity column in table which value always start from one?
Hi all,
Hope doing well,
sir i created one table which has id with number datatype
for which i created sequence and stored procedure so suppose
i inserted two row there it's inserting and id is showing 1, 2
again i truncate that table and again i inserted value there now the id is starting from 3 , 4
so my question is that after truncating table can't it insert from 1 in id column?
thanks,>
sir i created one table which has id with number datatype
for which i created sequence and stored procedure so suppose
i inserted two row there it's inserting and id is showing 1, 2
again i truncate that table and again i inserted value there now the id is starting from 3 , 4
so my question is that after truncating table can't it insert from 1 in id column?
>
Oracle does not have 'identity' columns.
Oracle sequences are NOT gap free.
Oracle sequences are independent objects and not associated with any other table or object.
If you are wanting a gap-free sequnece of numbers, which is not recommended, you will have to create your own functionality. And that functionality will not be scalable or perform well. -
Error inserting a row into a table with identity column using cfgrid on change
I got an error on trying to insert a row into a table with identity column using cfgrid on change see below
also i would like to use cfstoreproc instead of cfquery but which argument i need to pass and how to use it usually i use stored procedure
update table (xxx,xxx,xxx)
values (uu,uuu,uu)
My component
<!--- Edit a Media Type --->
<cffunction name="cfn_MediaType_Update" access="remote">
<cfargument name="gridaction" type="string" required="yes">
<cfargument name="gridrow" type="struct" required="yes">
<cfargument name="gridchanged" type="struct" required="yes">
<!--- Local variables --->
<cfset var colname="">
<cfset var value="">
<!--- Process gridaction --->
<cfswitch expression="#ARGUMENTS.gridaction#">
<!--- Process updates --->
<cfcase value="U">
<!--- Get column name and value --->
<cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
<cfset value=ARGUMENTS.gridchanged[colname]>
<!--- Perform actual update --->
<cfquery datasource="#application.dsn#">
UPDATE SP.MediaType
SET #colname# = '#value#'
WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
</cfquery>
</cfcase>
<!--- Process deletes --->
<cfcase value="D">
<!--- Perform actual delete --->
<cfquery datasource="#application.dsn#">
update SP.MediaType
set Deleted=1
WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
</cfquery>
</cfcase>
<cfcase value="I">
<!--- Get column name and value --->
<cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
<cfset value=ARGUMENTS.gridchanged[colname]>
<!--- Perform actual update --->
<cfquery datasource="#application.dsn#">
insert into SP.MediaType (#colname#)
Values ('#value#')
</cfquery>
</cfcase>
</cfswitch>
</cffunction>
my table
mediatype:
mediatypeid primary key,identity
mediatypename
my code is
<cfform method="post" name="GridExampleForm">
<cfgrid format="html" name="grid_Tables2" pagesize="3" selectmode="edit" width="800px"
delete="yes"
insert="yes"
bind="cfc:sp3.testing.MediaType.cfn_MediaType_All
({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
onchange="cfc:sp3.testing.MediaType.cfn_MediaType_Update({cfgridaction},
{cfgridrow},
{cfgridchanged})">
<cfgridcolumn name="MediaTypeID" header="ID" display="no"/>
<cfgridcolumn name="MediaTypeName" header="Media Type" />
</cfgrid>
</cfform>
on insert I get the following error message ajax logging error message
http: Error invoking xxxxxxx/MediaType.cfc : Element '' is undefined in a CFML structure referenced as part of an expression.
{"gridaction":"I","gridrow":{"MEDIATYPEID":"","MEDIATYPENAME":"uuuuuu","CFGRIDROWINDEX":4} ,"gridchanged":{}}
ThanksIs this with the Travel database or another database?
If it's another database then make sure your columns
allow nulls. To check this in the Server Navigator, expand
your DataSource down to the column.
Select the column and view the Is Nullable property
in the Property Sheet
If still no luck, check out a tutorial, like Performing Inserts, ...
http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/index.jsp
John -
How do you use an entity bea that uses an identity column?
I am using an mssql database. I need to create an entity bean for a table that uses an identity column. I want to use the identity column as the Primary key in the entity bean.
I assumed that I should not pass in a paramter for the identity column into the create method of the Home interface or the create method of the Bean ejbCreate method. But when I try using the entitity bean to create a new row in the table I get the following error.
Cannot insert explicit value for identity column in table 'PropsTableIdentity when IDENTITY_INSERTis set to OFF.
I didn't think I was doing anything to explicitly insert anything into the identity column.
Anyways here are my programs if anybody cares to take a look.
PropsIdentity.java
package propsIdentity;
// File generated by Desiderata Software's Blazix entity bean wizard
// Thu May 05 08:20:44 MDT 2005
// Remote interface for entity bean "PropsIdentity"
import javax.ejb.*;
import java.rmi.*;
public interface PropsIdentity extends javax.ejb.EJBObject {
int getKey() throws java.rmi.RemoteException;
java.lang.String getValue() throws java.rmi.RemoteException;
void setValue( java.lang.String value ) throws java.rmi.RemoteException;
// TBD: Add any additional remote method interfaces
PropsIdentityHome.java
package propsIdentity;
// File generated by Desiderata Software's Blazix entity bean wizard
// Thu May 05 08:20:44 MDT 2005
// Home interface for entity bean "PropsIdentity"
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
public interface PropsIdentityHome extends javax.ejb.EJBHome {
PropsIdentity create(
java.lang.String value
) throws javax.ejb.CreateException, java.rmi.RemoteException;
PropsIdentity findByPrimaryKey( java.lang.Integer pkey ) throws javax.ejb.FinderException, java.rmi
.RemoteException;
}PropsIdentityHome.java
code]
package propsIdentity;
// File generated by Desiderata Software's Blazix entity bean wizard
// Thu May 05 08:20:44 MDT 2005
// Home interface for entity bean "PropsIdentity"
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
public interface PropsIdentityHome extends javax.ejb.EJBHome {
PropsIdentity create(
java.lang.String value
) throws javax.ejb.CreateException, java.rmi.RemoteException;
PropsIdentity findByPrimaryKey( java.lang.Integer pkey ) throws javax.ejb.FinderException, java.rmi
.RemoteException;
PropsIdentityBean.java
package propsIdentity;
// File generated by Desiderata Software's Blazix entity bean wizard
// Thu May 05 08:20:44 MDT 2005
// Home interface for entity bean "PropsIdentity"
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
public interface PropsIdentityHome extends javax.ejb.EJBHome {
PropsIdentity create(
java.lang.String value
) throws javax.ejb.CreateException, java.rmi.RemoteException;
PropsIdentity findByPrimaryKey( java.lang.Integer pkey ) throws javax.ejb.FinderException, java.rmi
.RemoteException;
}PropsIdentityBean.java
// Thu May 05 08:20:44 MDT 2005
// Bean class for entity bean "PropsIdentity"
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
public class PropsIdentityBean implements javax.ejb.EntityBean {
//Instance member variables.
public int key = 0;
public java.lang.String value = null;
// Entity context, can be used to obtain handles etc
javax.ejb.EntityContext ejbEntityContext = null;
//Getter/setter methods
public int getKey() throws java.rmi.RemoteException
return key;
public java.lang.String getValue() throws java.rmi.RemoteException
return value;
public void setValue( java.lang.String value ) throws java.rmi.RemoteException
this.value = value;
// TBD: Add implementations for any additional remote method interfaces
// The default ejbCreate method.
public java.lang.Integer ejbCreate(
java.lang.String value
throws javax.ejb.CreateException, java.rmi.RemoteException
this.value = value;
return null;
// TBD: If any other ejbCreate's are added manually to the home interface, define them.
// Other methods required in an entity bean
public void setEntityContext( javax.ejb.EntityContext ejbEntityContext )
throws RemoteException
this.ejbEntityContext = ejbEntityContext;
public void unsetEntityContext()
throws RemoteException
this.ejbEntityContext = null;
public void ejbPostCreate(
java.lang.String value
// TBD: Do any post-instance-creation processing here
public void ejbRemove()
throws java.rmi.RemoteException, javax.ejb.RemoveException
// TBD: Do any processing here when instance is being removed
public void ejbActivate()
throws java.rmi.RemoteException
// TBD: Do any processing here when instance is activated
public void ejbPassivate()
throws java.rmi.RemoteException
// TBD: Do any processing here when instance is being passivated
public void ejbLoad()
throws java.rmi.RemoteException
// TBD: Load any data needed by instance
// in addition to the container-managed data.
public void ejbStore()
throws java.rmi.RemoteException
// TBD: Store any data used by instance
// in addition to the container-managed data.
} Script used to create table in mssql
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PropsTableIdentity]') and OBJE
CTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[PropsTableIdentity]
GO
CREATE TABLE [dbo].[PropsTableIdentity] (
[key] [int] IDENTITY (1, 1) NOT NULL ,
[value] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GOAnybody have any clue on how to figure the entity bean to work with the identity column?Hi,
CAN THIS BE DONE? This would be a good enhancement if not...???
If I write a PL/SQL loop and want to add it to the utilities... IS THERE A WAY? -
Need to restrict values in F4 help for Batch Characteristic
Hi,
I need to restrict values in F4 Help for a batch characteristic based on values entered for another characteristic. I could not find any BADI or Exit for this purpose. There is a BADI CACL_VALUE which is triggered after an entry is selected from dropdown list but nothing when we press F4. I thought of using Object Dependency but I need to write a programming logic for the requirement. Please let me know if there is any way to write program in Object Dependency or any other way for this requirement.
Regards,
NikhilHi nikhil simha,
first of all, find out which search help is called.
[Hierarchy of the Search Help Call|http://help.sap.com/saphelp_nw70/helpdata/en/0b/32e9b798da11d295b800a0c929b3c3/frameset.htm]
may help you.
If you know the search help, you may enhance it, but first of all you should check the where-used-list and make sure that the search help shows the requested behavior only in the context where you want it to.
If it is your own program, you may be better off to create your own search help and define the triggering fields as search help interface input fields. Then you can use the values to filter results.
Regards
Clemens -
Need to convert values into coma separated
Need to convert values into coma separated
I have a string value that stores data like 'NYK,IND,SGP,GER'
FOR EXAMPLE
V_CITY_CODE = 'NYK,IND,SGP,GER'
When I query
select * from city where city_code = V_CITY_CODE;I get no rows, this is because V_CITY_CODE has all city code as single code.
I need a function to search , and replace with ','.
I tried using instr and replace but was unable to convert it.
could some one pls assist me.
thanks in advance
SazLooking for this?
SQL> select * from emp
2 /
EMPNO DEPTNO ENAME SAL DOJ JOB
1 1 Karthick 80 03-DEC-11
2 1 Karthick_1 90 23-NOV-11
3 2 Ram 80 03-DEC-11
4 2 Ram_1 90 23-NOV-11
SQL> var v_ename varchar2(1000)
SQL> exec :v_ename := 'Karthick,Karthick_1'
PL/SQL procedure successfully completed.
SQL> select *
2 from emp
3 where ename in (
4 select regexp_substr(val, '[^,]+', 1, level)
5 from (select :v_ename val from dual)
6 connect by level <= length(val) - length(replace(val, ','))+1
7 )
8 /
EMPNO DEPTNO ENAME SAL DOJ JOB
1 1 Karthick 80 03-DEC-11
2 1 Karthick_1 90 23-NOV-11 -
Hi everyone,
I need help with inserting values using merge.
* I need to check all the units in a parent category. For example, NF_ARTICLECATEGORYID = 7462 is a parent category.
* Im going to compare all the units in the parent category(7642) to the units in a subcategory (8053).
* If the units in parent category(7642) is not present in the subcategory(8053) then the units will be inserted in the same table.
table structure:
Table name : ARTICLECATEGORYACCESS
Fields: IP_ARTICLECATEGORYACCESSID
NF_ARTICLECATEGORYID
NF_UNITID
NF_USERID
N_VIEW
N_EDIT
Sample data:
CREATE TABLE articlecategoryaccess (
IP_ARTICLECATEGORYACCESSID NUMBER(5),
NF_ARTICLECATEGORYID NUMBER (10),
NF_UNITID NUMBER (10),
NF_USERID NUMBER (10)
N_VIEW INT,
N_EDIT INT);
INSERT INTO articlecategoryaccess VALUES (255583, 7642, 29727, NULL, 1 ,1);
INSERT INTO articlecategoryaccess VALUES (243977,7642,29728, NULL, 1 ,1);
INSERT INTO articlecategoryaccess VALUES (240770,7642,29843, NULL, 1 ,1);
INSERT INTO articlecategoryaccess VALUES (243413,7642,29844, NULL, 1 ,1);
INSERT INTO articlecategoryaccess VALUES (274828,7642,44849, NULL, 1 ,1);
INSERT INTO articlecategoryaccess VALUES (274828,8053,44849, NULL, 1 ,1);
Units ID 29727, 29728, 29843, 29844, 44849 has access to parent category 7642.
The units id 29727, 29728, 29843, 29844 dont have access to subcategory 8053.
29727, 29728, 29843, 29844 should be inserted in the same table and will have an access to 8053.
After they are inserted, it should look like this
IP_ARTICLECATEGORYACCESSID NF_ARTICLECATEGORYID NF_UNITID NF_USERID N_VIEW N_EDIT
255583 7642 29727 null 1 1
243977 7642 29728 null 1 1
240770 7642 29843 null 1 1
243413 7642 29844 null 1 1
274828 7642 44849 null 1 1
new value 8053 44849 null 1 1
new value 8053 29843 null 1 1
new value 8053 29844 null 1 1
new value 8053 29728 null 1 1
new value 8053 29727 null 1 1
NOTE: IP_ARTICLECATEGORYACCESSID is a sequence and it should be unique
DECLARE
BEGIN
MERGE INTO articlecategoryaccess b
USING (SELECT *
FROM articlecategoryaccess c
WHERE nf_articlecategoryid = 7642
MINUS
SELECT *
FROM articlecategoryaccess c
WHERE nf_articlecategoryid = 8053) e
ON (1 = 2)
WHEN NOT MATCHED THEN
INSERT (b.ip_articlecategoryaccessid, b.nf_articlecategoryid, b.nf_unitid, b.NF_USERID, b.N_VIEW, b.N_EDIT)
VALUES (articlecategoryaccessid_seq.nextval, 8053, e.nf_unitid, null, 1, 1);
END;
i got an error after running the script:
*Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.
For Trusted Oracle configured in DBMS MAC mode, you may see
this message if a duplicate entry exists at a different level.
*Action: Either remove the unique restriction or do not insert the key.
why would it be duplicated? its a sequence and its unique.. I dont know, maybe there is something wrong my script..
Any help is appreciated..
EdEd,
1. What is the current value of the Sequence? Does the current value of sequence exist in the table? If yes, then increment the sequence to a value that is not present in the Table.
2. Do you have any unique constraint on any of the columns that you are inserting?
I have to ask you again, Why are you insisting on Merge statement when a simple Insert can do the job for you? Don't you feel that the below specified Merge statement is making things look more Complicated than they actually are, do you?
Think on it and then proceed. I hope these pointers help you to resolve the issue.
Regards,
P. -
Hey Guys
I'm trying to find a way to get multiple values using the following method
HttpSession.getAttribute(java.lang.String)
Here's the scenerio. Its a already written application and now i'm trying to make some changes. earlier in the jsp page a combo box was used and value was retrieved in the servlet using the getAttribute method of Session. Now I'm using a html multiple selection list and have to retrieve all the values selected in the list in the servlet. Can anyone please suggest me how to do that. HTTPRequest class has a method getParameterValues which will let me do that but i have to do is using HTTPSession.
Thanks for your time to read thisI'm not sure what you are trying to do. You can only use session.getAttribute to retrieve something that has already been stored in the session with a previous setAttribute. If you need to store multiple values under one attribute name using setAttribute, you can store an array, or an ArrayList or whatever type of Collection you want. The request.getParameterValues method is the only way you can retrieve form parameters than can have multiple values. If the servlet hasn't already processed these parameters and put them into the session for you, you have to use request.getParameterValues.
-
Need to insert values into a table from a XML file
Hi,
I'm an Oracle 9i/10g DBA with quite a few years experience, but I'm new to XML and dealing with it in database terms. I've been given a project that entails pulling XML values out of a file (or 100's of them) and storing them in the database so that they are searchable by end-users. The project is classified as secret so I'm unable to upload the specific XML or any info relating to the structire of the XML or the table I will use to insert the values into - sorry!! So, I've created an XML file with a similar structure to help people understand my predicament.
The end-users only need to search on a subset of the total amount of columns from the table I'll insert data into, although the XML file has a lot more, so I dont need to store the other values - but I will need to store the name of the XML file (or a pointer to it so I know what XML file a particular set of values belong to) in another column of the table along with its associated values.
I've been using the XMLTABLE function with some degree of success, although I had better succes using the XMLSEQUENCE function. However, I found out this is deprecated in 10g and replaced with XMLTABLE, so I guess it's better if I use this in case we ever need to upgrade to 11g.
The main problem I've been having is that some elements in the XML files have multiple values for the one record when all the other records are the same. In terms of storing this in the database, I guess it would mean inserting multiple rows in the table for each element where the value differs. Here is a dumbed down XML file similar to what I've got along with the other SQL I've used:
+<?xml version="1.0" encoding="UTF-8"?>+
+<House>+
+<Warehouse>+
+<WarehouseId>1</WarehouseId>+
+<WarehouseName>+
+<Town>Southlake</Town>+
+<State>Texas</State>+
+</WarehouseName>+
+<Building>Owned</Building>+
+<Area>25000</Area>+
+<Docks>2</Docks>+
+<DockType>Rear load</DockType>+
+<WaterAccess>true</WaterAccess>+
+<RailAccess>N</RailAccess>+
+<Parking>Street</Parking>+
+<VClearance>10</VClearance>+
+</Warehouse>+
+<Warehouse>+
+<WarehouseId>2</WarehouseId>+
+<WarehouseName>+
+<Town>Poole</Town>+
+<State>Dorset</State>+
+</WarehouseName>+
+<WarehouseName>+
+<Town>Solihull</Town>+
+<County>West Midlands</State>+
+</WarehouseName>+
+<Building>Owned</Building>+
+<Area>40000</Area>+
+<Docks>5</Docks>+
+<DockType>Rear load</DockType>+
+<WaterAccess>true</WaterAccess>+
+<RailAccess>N</RailAccess>+
+<Parking>Bay</Parking>+
+<VClearance>10</VClearance>+
+</Warehouse>+
+<Warehouse>+
+<WarehouseId>3</WarehouseId>+
+<WarehouseName>+
+<Town>Fleet</Town>+
+<County>Hampshire</County>+
+</WarehouseName>+
+<Building>Owned</Building>+
+<Area>10000</Area>+
+<Docks>1</Docks>+
+<DockType>Side load</DockType>+
+<WaterAccess>false</WaterAccess>+
+<RailAccess>N</RailAccess>+
+<Parking>Bay</Parking>+
+<VClearance>20</VClearance>+
+</Warehouse>+
+</House>+
CREATE TABLE xmltest OF XMLTYPE;
INSERT INTO xmltest
VALUES(xmltype(bfilename('XML_DIR', 'test.xml'), nls_charset_id('AL32UTF8')));
Consequently, I need to...
1) Retrieve the results from the XML file for all 3 warehouses where multiple values for the same sub-element are shown as 2 rowsthe result set. (I am guessing there will be 4 rows returned as warehouse sub-2 has 2 different elements for <WarehouseName>.
2) Build a case statement into the query so that regardless of the sub-element name (i.e State or County), it is returned into the 1 column, for instance County.
So, if I run a query similar to the following...
select y.WarehouseId, y.Town, y.County, y.Area
from xmltest x, xmltable('/House/Warehouse' .......
I would like to get results back like this...
ID Town County Area
1 Southlake Texas 25000
2 Poole Dorset 40000
2 Solihull West Midlands 40000
3 Fleet hampshire 10000
Sorry for the non-formatting but I hope this all makessense to someone out there with what I'm trying to do.
I appreciate any help whatsoever because, as i said before, I'm totally new to XML and trying to read the vast amount of information there is out there on XML is all a bit daunting.
Many thanks in advance,
Shaun.Hi again,
Thanks for keeping the post open for me. I've had a look at the post illustrating the XFileHandler package, and tried to alter it to make it fit with my XML files. To help explain things, my XML file looks like this:
<?xml version="1.0"?>
<!DOCTYPE CMF_Doc SYSTEM "CMF_Doc.dtd">
<House>
<Warehouse>
<WarehouseId>1</WarehouseId>
<WarehouseName>
<Town>Southlake</Town>
<State>Texas</State>
</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>House
<WarehouseId>2</WarehouseId>
<WarehouseName>
<Town>Poole</Town>
<State>Dorset</State>
</WarehouseName>
<WarehouseName>
<Town>Solihull</Town>
<County>West Midlands</County>
</WarehouseName>
<Building>Owned</Building>
<Area>40000</Area>
<Docks>5</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>3</WarehouseId>
<WarehouseName>
<Town>Fleet</Town>
<County>Hampshire</County>
</WarehouseName>
<Building>Owned</Building>
<Area>10000</Area>
<Docks>1</Docks>
<DockType>Side load</DockType>
<WaterAccess>false</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>20</VClearance>
</Warehouse>
</House>
<?xml version="1.0" encoding="UTF-8"?>
<House>
<Warehouse>
<WarehouseId>4</WarehouseId>
<WarehouseName>
<Town>Dallas</Town>
<State>Texas</State>
</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>5</WarehouseId>
<WarehouseName>
<Town>Dorchester</Town>
<State>Dorset</State>
</WarehouseName>
<WarehouseName>
<Town>Solihull</Town>
<County>West Midlands</County>
</WarehouseName>
<Building>Owned</Building>
<Area>40000</Area>
<Docks>5</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>6</WarehouseId>
<WarehouseName>
<Town>Farnborough</Town>
<County>Hampshire</County>
</WarehouseName>
<Building>Owned</Building>
<Area>10000</Area>
<Docks>1</Docks>
<DockType>Side load</DockType>
<WaterAccess>false</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>20</VClearance>
</Warehouse>
</House>
<?xml version="1.0" encoding="UTF-8"?>
<House>
<Warehouse>
<WarehouseId>7</WarehouseId>
<WarehouseName>
<Town>Southlake</Town>
<State>Texas</State>
</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>8</WarehouseId>
<WarehouseName>
<Town>Bournemouth</Town>
<State>Dorset</State>
</WarehouseName>
<WarehouseName>
<Town>Shirley</Town>
<County>West Midlands</County>
</WarehouseName>
<Building>Owned</Building>
<Area>30000</Area>
<Docks>5</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>9</WarehouseId>
<WarehouseName>
<Town>Clapham</Town>
<County>London</County>
</WarehouseName>
<Building>Owned</Building>
<Area>10000</Area>
<Docks>1</Docks>
<DockType>Side load</DockType>
<WaterAccess>false</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>20</VClearance>
</Warehouse>
</House>And the XFilehandler package looks like this (I'm just trying to do a simple select only on WarehouseId & WaterAccess for the time being to keep things simple):
create or replace package XFileHandler as
TYPE TRECORD IS RECORD (
WID NUMBER(2)
, WACCESS VARCHAR2(5)
type TRecordTable is table of TRecord;
function getRows (p_directory in varchar2, p_filename in varchar2) return TRecordTable pipelined;
end;
create or replace package body XFileHandler is
function getRows (p_directory in varchar2, p_filename in varchar2)
return TRecordTable pipelined
is
nb_rec number := 1;
tmp_xml clob;
tmp_file clob;
rec TRecord;
begin
DBMS_LOB.CREATETEMPORARY(TMP_FILE, TRUE);
tmp_file := dbms_xslprocessor.read2clob(p_directory, p_filename);
LOOP
tmp_xml := regexp_substr(tmp_file, '<\?xml[^?]+\?>\s*<([^>]+)>.*?</\1>', 1, nb_rec, 'n');
exit when length(tmp_xml) = 0;
--dbms_output.put_line(tmp_rec);
nb_rec := nb_rec + 1;
select y.WID, y.WACCESS
into rec.WID, rec.WACCESS
from xmltable('/House' passing xmltype(tmp_xml)
columns WID NUMBER(2) PATH 'Warehouse/WarehouseId',
WACCESS VARCHAR2(5) PATH 'WaterAccess') y;
pipe row ( rec );
end loop;
dbms_lob.freetemporary(tmp_file);
return;
end;
end;Now, when I run the query:
select * from table(XFileHandler.getRows('XML_DIR', 'XFileHandler_test.xml'));I get the error: ORA-00600: internal error code, arguments: [17285], [0x5CFE8DC8], [4], [0x45ABE1C8], [], [], [], []
I had a look in the dump file for anything obvious, but nothing really stands out. Is there anything obvious in my code that I'm missing or something else which you may think could be causing this error, e.g in the regular expression regexp_substr?
Many thanks,
Shaun. -
Looking for an example from app gallery that uses WAAD for identity
I'm looking for an example from the app gallery (http://azure.microsoft.com/en-us/gallery/active-directory/) that uses WAAD for identity. I need one the show our business what the process would look like for an organization signing up for a SaaS offering
via the App Gallery. I know all the Microsoft applications use WAAD but I was hoping to find a third-party example. What I mean is an app where all tenant and user identity is done using WAAD as opposed to federated identity.I doubt that what you are looking for exists yet.
Cheers,
Markus
Markus Vilcinskas, Knowledge Engineer, Microsoft Corporation
Maybe you are looking for
-
How do I get my "new" computer to recognize my iPhone 4 as a primary device
I used my laptop(Vista) to back-up/update/sync/everything with my iPhone 4 but it recently died. On my desktop PC(Windows 7) I once used it for an iPod which has since been lost. I authorized my desktop, transferred purchases, backed the phone up and
-
Missing PARTNO field in Write Optimized DSO
Hi, I have a write optimized DSO, for which the Partition has been deleted (reason unknown) in Dev system. For the same DSO, partition parameters exists in QA and production. Now while transporting this DSO to QA, I am getting an error "Old key field
-
Unable to install SAP webAS on Windows 2003
Hi Everyone , I am trying to install SAP WebAS Java 6.4. We use an Oracle Database and i want to deploy our web apps on the SAP WebAS . I get this error during installation : ERROR 2004-11-09 15:00:39 CJS-00081 Assertion failed: in function sapdb_sql
-
Regarding BDLR, SXDB and BMVO Tcodes
Hello, I want to know if there is any standard method to upload material master, customer master, vendor master and finance master data into SAP system. I am not referring to LSMW's, BDC's and using BAPI's. I am aware of standard programs like RMDATI
-
Can someone tell me how we can convert an ALV report to PDF and send it as an attachment to the external emial. Please help me. Thanks, Sneha Singh.