Rashmi Dupati

Greenhorn
+ Follow
since Mar 05, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rashmi Dupati

Hi There,

please see the below code(it is MYSQL) but i need the query in oracle.


In this table for each “id_no” there is one or more “items” identified. Each record contains a single “item” value. I will use the code listed below to populate the above table:
- Hide quoted text -
-- create example table
CREATE TABLE Example2(id_no int not null, item varchar(20) not null)
-- populate the example table
INSERT INTO Example2 VALUES (1, 'Skiing')
INSERT INTO Example2 VALUES (1, 'Diving')
INSERT INTO Example2 VALUES (2, 'Diving')
INSERT INTO Example2 VALUES (2, 'Skiing')
INSERT INTO Example2 VALUES (2, 'Hunting')
INSERT INTO Example2 VALUES (2, 'Fishing')
INSERT INTO Example2 VALUES (4, 'Sailing')
INSERT INTO Example2 VALUES (4, 'Skiing')
INSERT INTO Example2 VALUES (5, 'Skiing')
The next code snippet returns a record set that contains a single record for each “id_no”, followed by a comma delimited string that concatenates each “item” value together into a single column value:
-- declare local variables
declare @p varchar(1000)
declare @i char(5)
declare @sm int
declare @m int
-- Print Report Heading
print 'id_no' + ' items'
print '----- ' + '------------------------------------------'
set @p = ''
-- set @m to the first id number
select top 1 @m = id_no from Example2
order by id_no
set @sm = 0
-- Process each id_no until no more items
while @m <> @sm
begin
set @sm = @m
-- string together all items with a comma between
select @i = id_no, @p = case when @p = '' then item else @p + ', ' + item end
from Example2 a
where id_no = @m
-- print id_no, and comma delimited string
print @i + ' ' + @p
-- increment id number
select top 1 @m = id_no from Example2
where id_no > @sm
order by id_no
set @p = ''
end
-- remove example table
drop table Example2
When I run this code against my Example2 table I get the following output:
id_no items
----- ------------------------------------------
1 Skiing, Diving
2 Diving, Skiing, Hunting, Fishing
4 Sailing, Skiing
5 Skiing
Let me explain how this code works. This code iteratively process each “id_no” value using a WHILE loop. Each pass through the WHILE loop strings together all the “item” values for a given “id_no”. The variable @m contains the value of the “id_no” for the records being collapsed into a single record. The following SELECT statement does all the work to collapse all the records for a given “id_no” value into a single row in the output:
select @i = id_no, @p = case when @p = '' then item else @p + ', ' + item end
from Example2 a
where id_no = @m


Declare @Description varchar(4000)
select @Description = coalesce(@Description + ',' , '') + Description
FROM ud_LookupMGR_Data where dataid in (81,82,83,84)

Thanks & Regards
Rashmi
Hi All,

Please give a sample query for Displaying a Single Record with a Comma Separated Column from Multiple Records using Oracle.

the output should be like this:

id items
----- ------------------------------------------
1 Skiing, Diving
2 Diving, Skiing, Hunting, Fishing
4 Sailing, Skiing
5 Skiing

thanks in advance

Regards
Rashmi
Hello all

Can we pass null parameter to a meathod?

test(null);

like this for the method

public static void test(String str){
//some code goes here
}

Thanks in advance

Regards
Rashmi
13 years ago
Thanks And i have some doubts in the below code:

1.can we pass null parameter in the super constructor?
2.serialNo is a final variable.can we assign getNextSerialNo() method to a final variable?is this valid?




Thanks in advance

Regards
Rashmi
[edit]Add code tags. CR[/edit]
[ October 09, 2008: Message edited by: Campbell Ritchie ]
13 years ago
Hello all

I have some doubts in coding.please answer my queries.below is a sort of code can we use the code like this.

protected Concept( String anId )
8 {
9 if ( anId == null )
10 {
11 throw new NullPointerException( "id must not be null" );
12 }
13
14 id = anId;
15 }

thanks in advance

Regards
Rashmi
13 years ago
Hello all

I have 4 classes that 'll be the package com.result.exam.a.Please correct it .if it has any syntax error.

com/result/exam/a/Concept.java
1package com.result.exam.a;
2
3public abstract class Concept
4{
5 private String id;
6
7 protected Concept( String anId )
8 {
9 if ( anId == null )
10 {
11 throw new NullPointerException( "id must not be null" );
12 }
13
14 id = anId;
15 }
16
17 public String getId()
18 {
19 return id;
20 }
21
22 public void setId( final String id )
23 {
24 id = id;
25 }
26
27 public boolean equals( Object other )
28 {
29 return other != null && other.getClass().equals( getClass() ) && id.equals( ( (Concept) other ).id );
30 }
31
32 public String toString()
33 {
34 return "Concept(" + id + ")";
35 }
36}
com/result/exam/a/ConceptA.java
1package com.result.exam.a;
2
3public class ConceptA extends Concept
4{
5 private final Concept parent;
6
7 public ConceptA( String anId, Concept aParent )
8 {
9 super( anId );
10
11 parent = aParent;
12 }
13
14 public Concept getParent()
15 {
16 return parent;
17 }
18
19 public String toString()
20 {
21 return "ConceptA{" + getId() + ", parent=" + parent + '}';
22 }
23}
com/result/exam/a/ConceptB.java
1package com.result.exam.a;
2
3import java.util.Set;
4import java.util.HashSet;
5import java.util.Iterator;
6
7public class ConceptB extends ConceptA
8{
9 private final Set children;
10
11 public ConceptB( final String anId, final Concept aParent )
12 {
13 super( anId, aParent );
14
15 children = new HashSet();
16 }
17
18 public int getCount()
19 {
20 return children.size();
21 }
22
23 public void addChild( Concept aChild )
24 {
25 children.add( aChild );
26 }
27
28 public void removeChild( Concept aChild )
29 {
30 children.remove( aChild );
31 }
32
33 public Iterator getChildren()
34 {
35 return children.iterator();
36 }
37
38 public int getFamilySize()
39 {
40 int count = children.size();
41
42 for ( Iterator iter = getChildren(); iter.hasNext(); )
43 {
44 count += ( (ConceptB) iter.next() ).getFamilySize();
45 }
46
47 return count;
48 }
49
50 public int getAncestorCount()
51 {
52 int count = 0;
53 Concept ancestor = getParent();
54
55 while ( ancestor != null )
56 {
57 count++;
58 if ( ancestor instanceof ConceptA )
59 {
60 ancestor = ( (ConceptA) ancestor ).getParent();
61 }
62 else
63 {
64 ancestor = null;
65 }
66 }
67
68 return count;
69 }
70
71 public String toString()
72 {
73 return "ConceptB{" + getId() + ", parent=" + getParent() + ", children=" + children.size() + "}";
74 }
75}
com/result/exam/a/ConceptC.java
1package com.result.exam.a;
2
3public class ConceptC extends ConceptA
4{
5 private static int nextSerialNo = 0;
6
7 public static int getNextSerialNo()
8 {
9 return nextSerialNo++;
10 }
11
12 private final int serialNo;
13
14 public ConceptC( String anId )
15 {
16 super( anId, null );
17
18 serialNo = getNextSerialNo();
19 }
20
21 public int getSerialNo()
22 {
23 return serialNo;
24 }
25
26 public String toString()
27 {
28 return "ConceptC(" + getId() + ", " + serialNo + ")";
29 }
30}

Thanks in advance.

Regards
Rashmi
13 years ago
Hello

Can you please answer my questions:

1.What is the difference between Abstact classes and Interfaces.in program how we are going to decide which one to create?and when to use interfaces and when to use absract classes?(In programmatically)

2.can we declare variables in interface?

thanks & regards
Rashmi
13 years ago
Hello

I have some doubt in serialization :

1.What is the purpose of serialization ?
2.why static variables are not seriazed?

Thanks & Regards
Rashmi
13 years ago
Hello

Can you please tell me the directory structure and procedure to develop,deploy and run a simple EJB application in Eclipse IDE?

where to write the code for Interfaces and bean classes?

and Using Jboss server how to run the application?

i am bit confusing about this,whether XDoclet is required to run the EJB in Eclipse.

Thanks in Advance
how to use plugins?can you please tell me regarding how plugins support EJB?what are the plugins used for EJB?

Thank you
Thank you very much for your guidance.
Thanks for your response.

For servlets and jsp i am using eclipse IDE.you are telling IDE's don't run EJB.then where to write the code for Home interface,remote interface,bean and client application(servlets,jsp or an applet).

please give the procedure to run a simple EJB application.that means where to install the server and what are the required components to run EJB.where to store all these files(remote,home interface,bean class,client application).and deployment descriptor.

and you told EJB 3 is better.what is mean by JPA?which is best site to learn EJB 3.?

Thanks in advance
Hello

I am new to this technology.please give the information about EJB.

1.which IDE is better for to run EJB.?
2.which server is good for EJB.?
3.what are the main things to learn in EJB.?

I knew some basic information about EJB:Home and remote interfaces and one client class(Servlet or JSP).but i am confusing about questions that have written above.please suggest me.

Thanks in advance.
Hello

please check the code and give the solution to my problem.

<%@ page import="java.util.*" %>
<jsp:useBean id="dbBean" scope="application" class="burnaby.DbBean"/>
<%
String base = (String) application.getAttribute("base");
%>
<TABLE CELLSPACING="0" CELLPADDING="5" WIDTH="150" BORDER="0">
<TR>
<TD BGCOLOR="F6F6F6">
<FONT FACE="Verdana">Search</FONT>
<FORM>
<INPUT TYPE="HIDDEN" NAME="action" VALUE="search">
<INPUT TYPE="TEXT" NAME="keyword" SIZE="10">
<INPUT type="SUBMIT" VALUE="Go">
</FORM>
</TD>
</TR>
<TR>
<TD BGCOLOR="F6F6F6"><FONT FACE="Verdana">Categories:</FONT></TD>
</TR>
<TR VALIGN="TOP">
<TD BGCOLOR="F6F6F6">

(up to this working fine the below scriplet is not working.it's not displaying categories accessing from database)

<%
Hashtable categories = dbBean.getCategories();
Enumeration categoryIds = categories.keys();
while (categoryIds.hasMoreElements()) {
Object categoryId = categoryIds.nextElement();
out.println("<A HREF=" + base + "?action=browseCatalog&categoryId=" +
categoryId.toString() + ">" +
categories.get(categoryId) +
"</A><BR>");
}
%>
</TD>
</TR>
</TABLE>


and see the DbBean code also

public Hashtable getCategories() {
Hashtable categories = new Hashtable();
try {
Connection connection = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
System.out.println("got connection"+dbUrl);
Statement s = connection.createStatement();
String sql = "SELECT categoryId, category FROM Categories" +
" ";
System.out.println("executing");
ResultSet rs = s.executeQuery(sql);
while (rs.next()) {
categories.put(rs.getString(1), rs.getString(2) );
}
rs.close();
s.close();
connection.close();
}
catch (SQLException e) {}
return categories;
}


thanks in advance
14 years ago
JSP
Thanks for your reply..

that problem got solved.but it's showing some more warning like this.

Type safety: The method put(Object, Object) belongs to the raw type Hashtable. References to
generic type Hashtable<K,V> should be parameterized

please give the solution to this problem.

which are the things i need to set for this.