Beggining SQL Question Package Question
After creating this bit of code for c_Pi
SQL> create or replace package MATH_CONSTANTS is
c_Pi constant number := 3.14159265; end MATH_CONSTANTS;
Create an unnamed block of code which prompts the user for a single numeric parameter, v_radius. This module should calculate the area of a circle using a radius equal to the inputted value along with c_Pi from the MATH_CONSTANTS package and subsequently display this information in a meaningful manner to the user.
Essentially how would I be able to take the user input and put it in a manner meaningful to the user (i.e. show it in a DBMS_OUTPUT.PUT_LINE(V_radius))
Also
For this following code, will it work and if not how should it be changed around?
Create or Replace Package OCTOBER12LAB As
procedure CONVERT(convID IN NUMBER, Measure IN NUMBER); end OCTOBER12LAB;
Create or Replace Package Body OCTOBER12LAB As
Procedure convert(convID IN NUMBER, Measure IN NUMBER) Is
V_Output Varchar2(50);
Begin
If convID = 1 Then
V_Output := FeetToYards(Measure);
elsIf convID = 2 Then
V_Output := YardsToFeet(Measure);
End If;
DBMS_OUTPUT.PUT_LINE(V_Output);
End convert;
Function FeetToYards(Measure IN NUMBER) return varchar2 Is
V_Total NUMBER(30,10); V_Output Varchar2(50);
Begin V_Total := Measure/3; V_Output := Measure || ' Feet equals ' || V_Total || ' Yards'; Return V_Output; End FeetToYards;
Function YardsToFeet(Measure IN NUMBER) return varchar2 Is
V_Total NUMBER(30,10); V_Output Varchar2(50);
Begin V_Total := Measure * 3; V_Output := Measure || ' Yard(s) equals ' || V_Total || ' Feet'; Return V_Output; End YardsToFeet;
End OCTOBER12LAB;
Begin
OCTOBER12LAB.convert(1,3);
OCTOBER12LAB.convert(2,2);
OCTOBER12LAB.convert(1,5); End;
Thanks in advance for your help.
Hi
Welcome to the forum!
966784 wrote:
After creating this bit of code for c_Pi
SQL> create or replace package MATH_CONSTANTS is
c_Pi constant number := 3.14159265; end MATH_CONSTANTS;
Create an unnamed block of code which prompts the user for a single numeric parameter, v_radius. This module should calculate the area of a circle using a radius equal to the inputted value along with c_Pi from the MATH_CONSTANTS package and subsequently display this information in a meaningful manner to the user.
Essentially how would I be able to take the user input and put it in a manner meaningful to the user (i.e. show it in a DBMS_OUTPUT.PUT_LINE(V_radius))If this is a homework assignment, ask your teacher for clarification of what this means.
PL/SQL has no mechanism for promting the user and getting keyboard input. You'll have to do that through your front end. If you're using SQL*Plus, you can use the SQL*Plus ACCEPT command to prompt the user, get input and store it in a substitution variable.
Also
For this following code, will it work Try it and see.
and if not how should it be changed around?
Create or Replace Package OCTOBER12LAB As
procedure CONVERT(convID IN NUMBER, Measure IN NUMBER); end OCTOBER12LAB;
Create or Replace Package Body OCTOBER12LAB As
Procedure convert(convID IN NUMBER, Measure IN NUMBER) Is
V_Output Varchar2(50);
Begin
If convID = 1 Then
V_Output := FeetToYards(Measure);
elsIf convID = 2 Then
V_Output := YardsToFeet(Measure);
End If;
DBMS_OUTPUT.PUT_LINE(V_Output);
End convert;
Function FeetToYards(Measure IN NUMBER) return varchar2 Is
V_Total NUMBER(30,10); V_Output Varchar2(50);
Begin V_Total := Measure/3; V_Output := Measure || ' Feet equals ' || V_Total || ' Yards'; Return V_Output; End FeetToYards;
Function YardsToFeet(Measure IN NUMBER) return varchar2 Is
V_Total NUMBER(30,10); V_Output Varchar2(50);
Begin V_Total := Measure * 3; V_Output := Measure || ' Yard(s) equals ' || V_Total || ' Feet'; Return V_Output; End YardsToFeet;
End OCTOBER12LAB;Never write, let alone post, unfomatted code.
Which do you think is easier to read and understand? The package spec you posted above, or the version below? Which do you think will result in fewer bugs? If there are bugs, which do you think will be help you find them better? Which do you think will encourage people on this form to read and understand your questions?
Create or Replace Package Body OCTOBER12LAB As
Procedure convert ( convID IN NUMBER
, Measure IN NUMBER
Is
V_Output Varchar2(50);
Begin
If convID = 1 Then
V_Output := FeetToYards (Measure);
elsIf convID = 2 Then
V_Output := YardsToFeet (Measure);
End If;
DBMS_OUTPUT.PUT_LINE(V_Output);
End convert;
Function FeetToYards ( Measure IN NUMBER)
return varchar2
Is
V_Total NUMBER (30, 10);
V_Output Varchar2 (50);
Begin
V_Total := Measure / 3;
V_Output := Measure || ' Feet equals '
|| V_Total
|| ' Yards';
Return V_Output;
End FeetToYar;
Function YardsToFeet ( Measure IN NUMBER)
return varchar2
Is
V_Total NUMBER (30, 10);
V_Output Varchar2 (50);
Begin
V_Total := Measure * 3;
V_Output := Measure || ' Yard(s) equals '
|| V_Total
|| ' Feet';
Return V_Output;
End YardsFeet;
End OCTOBER12LAB;The difference between what you posted and what I posted is merely whitespace; I didn't change your code at all except for adding spaces and newlines.
Indent your code to show the extent of structural statements, like BEGIN and IF, and also to make long expressions (such as the multi-part || operations) easier to read and debug.
Noramlly, all functions are included in the package spec. If you didn't want users calling a function directly (say, for security reasons) then you include the function in the package body only. Is there any reason not to include these functions in the package spec?
When using dbms_output, remember to SET SERVEROUTPUT ON.
Begin
OCTOBER12LAB.convert(1,3);
OCTOBER12LAB.convert(2,2);
OCTOBER12LAB.convert(1,5); End;
Thanks in advance for your help.Edited by: Frank Kulash on Oct 21, 2012 6:54 PM
Similar Messages
-
SQL Question Bank and Answers for Practise
Dear Readers:
Does any one have any recommendation on SQL question bank and answers where I could practice my SQL.
I have developed some basic knowledge of SQL thanks to the MS community, but I am looking for some additional Questions or textbook recommendations which has questions and answers to queries for practice.
Best Wishes,
SQL75Hi,
Refer below post.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/446b2247-5124-49c1-90c9-b7fea0aa4f83/sql-dba-books?forum=sqlgetstarted
Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
Praveen Dsa | MCITP - Database Administrator 2008 |
My Blog | My Page -
Sql question : TRUNCATE vs Delete
hi
this is sql question, i don't know where i should post it, so here it is.
i just want to know the best usage of each. both commands delete records in a table, one deletes all, and the other can do the same plus option to delete specified records. if i just want to purge the table. which one is better and why? thanksthis is crucial to my design, i need to be able to
rollback if one of the process in the transaction
failed, the whole transaction should rollback. if
truncate does not give me this capability, then i have
to consider Delete.From the Oracle manual (sans the pretty formatting):
TRUNCATE
Caution: You cannot roll back a TRUNCATE statement.
Purpose
Use the TRUNCATE statement to remove all rows from a table or cluster. By default,
Oracle also deallocates all space used by the removed rows except that specified by
the MINEXTENTS storage parameter and sets the NEXT storage parameter to the size
of the last extent removed from the segment by the truncation process.
Removing rows with the TRUNCATE statement can be more efficient than dropping
and re-creating a table. Dropping and re-creating a table invalidates the table?s
dependent objects, requires you to regrant object privileges on the table, and
requires you to re-create the table?s indexes, integrity constraints, and triggers and
respecify its storage parameters. Truncating has none of these effects.
See Also:
DELETE on page 16-55 and DROP TABLE on page 17-6 for
information on other ways to drop table data from the database
DROP CLUSTER on page 16-67 for information on dropping
cluster tables
Prerequisites
To truncate a table or cluster, the table or cluster must be in your schema or you
must have DROP ANY TABLE system privilege. -
Urgent SQL question : how to flip vertical row values to horizontal ?
Hello, Oracle people !
I have an urgent SQL question : (simple for you)
using SELECT statement, how to convert vertical row values to horizontal ?
For example :
(Given result-set)
MANAGER COLUMN1 COLUMN2 COLUMN3
K. Smith ......1
K. Smith ...............1
K. Smith ........................1
(Needed result-set)
MANAGER COLUMN1 COLUMN2 COLUMN3
K. Smith ......1 .......1 .......1
I know you can, just don't remeber how and can't find exactly answer I'm looking for. Probably using some analytic SQL function (CAST OVER, PARTITION BY, etc.)
Please Help !!!
Thanx !
Steve.scott@ORA92> column vice_president format a30
scott@ORA92> SELECT f.VICE_PRESIDENT, A.DAYS_5, B.DAYS_10, C.DAYS_20, D.DAYS_30, E.DAYS_40
2 FROM (select t2.*,
3 row_number () over
4 (partition by vice_president
5 order by days_5, days_10, days_20, days_30, days_40) rn
6 from t2) f,
7 (SELECT T2.*,
8 row_number () over (partition by vice_president order by days_5) RN
9 FROM T2 WHERE DAYS_5 IS NOT NULL) A,
10 (SELECT T2.*,
11 row_number () over (partition by vice_president order by days_10) RN
12 FROM T2 WHERE DAYS_10 IS NOT NULL) B,
13 (SELECT T2.*,
14 row_number () over (partition by vice_president order by days_20) RN
15 FROM T2 WHERE DAYS_20 IS NOT NULL) C,
16 (SELECT T2.*,
17 row_number () over (partition by vice_president order by days_30) RN
18 FROM T2 WHERE DAYS_30 IS NOT NULL) D,
19 (SELECT T2.*,
20 row_number () over (partition by vice_president order by days_40) RN
21 FROM T2 WHERE DAYS_40 IS NOT NULL) E
22 WHERE f.VICE_PRESIDENT = A.VICE_PRESIDENT (+)
23 AND f.VICE_PRESIDENT = B.VICE_PRESIDENT (+)
24 AND f.VICE_PRESIDENT = C.VICE_PRESIDENT (+)
25 AND f.VICE_PRESIDENT = D.VICE_PRESIDENT (+)
26 AND f.VICE_PRESIDENT = E.VICE_PRESIDENT (+)
27 AND f.RN = A.RN (+)
28 AND f.RN = B.RN (+)
29 AND f.RN = C.RN (+)
30 AND f.RN = D.RN (+)
31 AND f.RN = E.RN (+)
32 and (a.days_5 is not null
33 or b.days_10 is not null
34 or c.days_20 is not null
35 or d.days_30 is not null
36 or e.days_40 is not null)
37 /
VICE_PRESIDENT DAYS_5 DAYS_10 DAYS_20 DAYS_30 DAYS_40
Fedele Mark 35473 35209
Fedele Mark 35479 35258
Schultz Christine 35700
South John 35253
Stack Kevin 35701 35604 35402 35115
Stack Kevin 35705 35635 35415 35156
Stack Kevin 35706 35642 35472 35295
Stack Kevin 35707 35666 35477
Stack Kevin 35667 35480
Stack Kevin 35686
Unknown 35817 35698 35596 35363 35006
Unknown 35702 35597 35365 35149
Unknown 35724 35599 35370 35155
Unknown 35600 35413 35344
Unknown 35601 35451 35345
Unknown 35602 35467
Unknown 35603 35468
Unknown 35607 35475
Unknown 35643 35508
Unknown 35644
Unknown 35669
Unknown 35684
Walmsley Brian 35725 35598
23 rows selected. -
Oracle equivalent of SQL DTS package
In process of migrating SQL database to Oracle database what is Oracle equivalent of SQL DTS package???
Data transformation services are something totally different, that have nothing to do with migration process. Can you please be more specific with your question? If you really want an answer, then you can consider the conversion phase....
But, again, there is no reason to compare these two.
If you want you can read about Oracle's data warehouse concepts, probably ETL is the true answer to your question -
How to find type of PL/SQL in package
Hi All,
I want to find all procedures/ Functions in package specification along with their type.
Eg. if there is procedure p1 and function f1 in package pk1 i want a query that will return
Package Proc/Function_name Type
pk1 p1 procedure
pk1 f1 function
from user procedures i can get only procedure/funtion name bur not its type.Hi,
Yes, I think metzguar got one.
Package dropped.
SQL> create package p1
as
function f
return number;
procedure p;
function f(x number)
return number;
procedure p(x number);
end;
Package created.
SQL> select package_name, object_name, case min(position)
when 0 then 'FUNCTION'
when 1 then 'PROCEDURE'
end
method_type
from user_arguments
where package_name = 'P1'
and nvl(overload, 1) = 1
group by package_name, object_name
PACKAGE_NAME OBJECT_NAME METHOD_TY
P1 P PROCEDURE
P1 F FUNCTION
2 rows selected.Regards
Peter -
Trying to install a new version of SQL 2014 Std 64 or x86. Installing on Windows 8.1Pro 64bit machine.
I get:
"TITLE: SQL Server Setup failure.
SQL Server Setup has encountered the following error:
The SQL Server product key is not valid. To proceed, re-enter the product key values from the Certificate of Authenticity (COA) or SQL Server packaging.
Error code 0x858C0017."
I looked at the summary log and that is the only error.
I made sure there were no other instances of SQL on this machine. Uninstalled all VS2013 and sql instances just in case. IF there is somewhere to check if a previous version or license is causing the issue, i would be glad to check.
Any help would be appreciated.Hi,
Please read this thread with similar issue
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/bdd94577-515c-49fa-be44-008eacece057/installing-sql-server-2012-on-a-new-vm-error-code-0x858c0017?forum=sqlsetupandupgrade
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
My Technet Articles -
Basic PL/SQL Question about running context
We are trying to create some generalized tools with PL/SQL procedures that would be used by a number of different Oracle Users/Schema. The idea was to store them in an administrative schema (call it ADMIN), create public synonyms for them, and grant execute to public. Then we could run them from the user schema (call it USER) to do the work.
It was my assumption, that while the procedures were stored in ADMIN, when they were run by USER they would run in the USER context. EG, a table (call it MYTABLE) that was referenced in the procedure without a schema reference (SELECT * FROM MYTABLE) would expect to find MYTABLE in the context of the schema which called the procedure. In other words, call the procedure from USER, I expected the procedure to look for MYTABLE in USER. However, we are getting errors that indicate that even though the procedure is called from USER, it is looking for the table in ADMIN (the procedures creation context), no in USER (the running context).
QUESTIONS: How is PL/SQL supposed to operate in this situation? Are there any options/parameters that can be set so the procedure will use the runtime context for table lookup, or do we have to write dynamic SQL which will fully qualify the table with the owner schema?
Thanks for your help
John ConroyHy,
from the manual:
The AUTHID clause is allowed only in the header of a stand-alone subprogram, a
package spec, or an object type spec. The header syntax is
-- stand-alone function
CREATE [OR REPLACE] FUNCTION [schema_name.]function_name
[(parameter_list)] RETURN datatype
[AUTHID {CURRENT_USER | DEFINER}] {IS | AS}
-- stand-alone procedure
CREATE [OR REPLACE] PROCEDURE [schema_name.]procedure_name
[(parameter_list)]
[AUTHID {CURRENT_USER | DEFINER}] {IS | AS}
-- package spec
CREATE [OR REPLACE] PACKAGE [schema_name.]package_name
[AUTHID {CURRENT_USER | DEFINER}] {IS | AS}
-- object type spec
CREATE [OR REPLACE] TYPE [schema_name.]object_type_name
[AUTHID {CURRENT_USER | DEFINER}] {IS | AS} OBJECT
where DEFINER is the default option. In a package or object type, the AUTHID
clause applies to all routines.
Note: Most supplied PL/SQL packages (such as DBMS_LOB, DBMS_PIPE, DBMS_
ROWID, DBMS_SQL, and UTL_REF) are invoker-rights packages. -
Servlet + JSP + SQL question
I have a servlet that is executing a few queries against a database. I am fowarding the results to a jsp page to display the results. I have been able to do this. My problem is when my query selects more than one field I am unsure on how to read that into an array or something like that. All the results I have done so far have had multiple results but only from one field in the database. Here is my serlvet and jsp code. If some one could tell me how to read multiple field into an array and display them on a jsp page that would be great. Thank you
Servlet
package nnet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.security.Principal;
import java.sql.*;
import java.sql.DriverManager;
* <p>Title: NNET</p>
* <p>Description: Northland Intranet</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: NMI</p>
* @author not attributable
* @version 1.0
public final class home
extends HttpServlet {
//Initialize global variables
//Initialize queries
private static final String USERQUERY =
"SELECT public.tblindividual.firstname as firstname " +
"FROM public.tblloginname " +
"INNER JOIN public.tblindividual ON (public.tblloginname.indlink = public.tblindividual.indid) " +
"WHERE LOWER(public.tblloginname.loginname) = LOWER(?)";
private static final String MAINLINKQUERY =
"SELECT public.nnetsection.name " +
"FROM public.nnetsection " +
"WHERE public.nnetsection.posted = 'true'";
private static final String ANOUNCEMENTQUERY =
"SELECT public.nnetanouncement.anouncement, to_char(nnetanouncement.postdate,'MonthDD, YY') as postdate " +
"FROM public.nnetanouncement " +
"ORDER BY public.nnetanouncement.postdate DESC";
public void init() throws ServletException {
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
Connection con = null;
PreparedStatement stmt = null;
//Initialize Resultset objects
ResultSet namers = null;
ResultSet mainlinkrs = null;
ResultSet anouncementrs = null;
ResultSet anouncementdaters = null;
//Initialize Array Lists
ArrayList mainlinkresults = new ArrayList();
ArrayList anouncementresults = new ArrayList();
String firstnameresult = null;
Principal user = request.getUserPrincipal();
String username = user.getName();
Properties props = new Properties();
InputStream in = getServletContext().getResourceAsStream(
"/WEB-INF/sql.properties");
props.load(in);
in.close();
//get Users login name to pass on
try {
Class.forName(props.getProperty("connection.driver"));
con = DriverManager.getConnection(props.getProperty("connection.url"), props);
stmt = con.prepareStatement(USERQUERY);
stmt.setString(1, username);
namers = stmt.executeQuery();
while (namers.next()) {
firstnameresult = namers.getString("firstname");
//results.add(namers.getString("firstname"))
catch (SQLException ex1) {
catch (ClassNotFoundException ex) {
finally {
if (stmt != null) {
try {
stmt.close();
catch (SQLException e) {
e.printStackTrace();
stmt = null;
if (con != null) {
try {
con.close();
catch (SQLException e) {
e.printStackTrace();
con = null;
//get the main links to pass on
try {
Class.forName(props.getProperty("connection.driver"));
con = DriverManager.getConnection(props.getProperty("connection.url"), props);
stmt = con.prepareStatement(MAINLINKQUERY);
mainlinkrs = stmt.executeQuery();
while (mainlinkrs.next()) {
mainlinkresults.add(mainlinkrs.getString("name"))
catch (SQLException ex1) {
catch (ClassNotFoundException ex) {
finally {
if (stmt != null) {
try {
stmt.close();
catch (SQLException e) {
e.printStackTrace();
stmt = null;
if (con != null) {
try {
con.close();
catch (SQLException e) {
e.printStackTrace();
con = null;
//get the announcements to pass on
try {
Class.forName(props.getProperty("connection.driver"));
con = DriverManager.getConnection(props.getProperty("connection.url"), props);
stmt = con.prepareStatement(ANOUNCEMENTQUERY);
anouncementrs = stmt.executeQuery();
while (anouncementrs.next()) {
anouncementresults.add(anouncementrs.getString("anouncement"));
catch (SQLException ex1) {
catch (ClassNotFoundException ex) {
finally {
if (stmt != null) {
try {
stmt.close();
catch (SQLException e) {
e.printStackTrace();
stmt = null;
if (con != null) {
try {
con.close();
catch (SQLException e) {
e.printStackTrace();
con = null;
request.setAttribute("firstname", firstnameresult);
request.setAttribute("mainlink", mainlinkresults);
request.setAttribute("anouncement", anouncementresults);
RequestDispatcher rd =
request.getRequestDispatcher("home.jsp");
rd.forward(request, response);
//Clean up resources
public void destroy() {
JSP Page
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
<html>
<head>
<title>
index
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
-->
</style></head>
<body bgcolor="#008000">
<table width="100%" border="1" cellspacing="0" bordercolor="#000000">
<tr>
<td bgcolor="#FFFFFF"><h1>Welcome to NNET <c:out value="${requestScope.firstname}" /></h1>
</td>
</tr>
</table>
<br>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="150"><table width="100%" border="1" cellspacing="0" bordercolor="#000000" bgcolor="#FFFFFF">
<tr>
<td><strong>Main Links </strong></td>
</tr>
<c:forEach var="item" items="${requestScope.mainlink}">
<tr>
<td valign="top"><c:out value="${item}"/></td>
</tr>
</c:forEach>
</table>
<p> </p></td>
<td><table width="100%" border="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td valign="top"><h2>Announcements</h2>
<p>
<c:forEach var="item" items="${requestScope.anouncement}">
<c:out value="${item}" />
</c:forEach>
</p>
</td>
</tr>
</table></td>
<td width="150"> </td>
</tr>
</table>
</body>
</html>OK if you look at the code I pasted above I have doen that. I hav ethat book and it is good. My question is how do I get the data read into a multidemisional array or an arraylist like I am using in the code above so I can access that on the jsp page. Can you give an example. Here is what I want . I have a table called anouncements with 3 fields (ID, name, url) I am returning say 10 results. I want to store them in a single arraylist or multideminsional array and call them on the jsp page. What syntax would I use on the servlet and on the jsp page for this? I know how to do it as seen above when I return only one field with many results from the database. Thank you in advance for any help
-
I have seen the following in some sql, but not sure of the difference.
select abc, NULL from xyz where .....
select abc, to_char(NULL) from xyz where ....
my question is there a difference between NULL and TO_CHAR(NULL) ?
Thanks.BluShadow wrote:
Looks like someone was trying to cast the null to a varchar2 datatype so that SQL knew the datatype of the column. In that case they should have used the CAST function...
Blu:
Just out of curiosity, any particular reason for the preference for cast instead of to_datatype(null)? I often use that construct, particularly in union type queries. The cast is sematically meaningless in a union query since the column will get the size of the largest column in the query.
SQL> set null null
SQL> select *
2 from (select 1 id, null c1, to_char(null) c2, cast(null as varchar2(10)) c3 from dual
3 union all
4 select 2, 'Hello there', 'Hello there', 'Hello there' from dual);
ID C1 C2 C3
1 null null null
2 Hello there Hello there Hello there
SQL> create view v as
2 select *
3 from (select 1 id, null c1, to_char(null) c2, cast(null as varchar2(10)) c3 from dual
4 union all
5 select 2, 'Hello there', 'Hello there', 'Hello there' from dual);
View created.
SQL> desc v;
Name Null? Type
ID NUMBER
C1 VARCHAR2(11)
C2 VARCHAR2(11)
C3 VARCHAR2(11)About the only place where I would use an explicit cast is if I was "hiding" the content of a column in a view, but needed to maintain the same structure as the table.
John -
SQL Questions (New to Cisco)
Hello. I work for Clarian Health in Indianapolis and am trying to learn as much as possible about the SQL databases, both AWDB and HDS so that I can handle the reporting for our Revenue Cycle Customer Service.
I am currently working my way through the Database Schema Handbook for Cisco Unified ICM /Contact Center Enterprise & Hosted. I’m also reviewing the explanation pages that are available for the reports on WebView. During my reviews, I have noticed a few things that confuse me.
My questions are:
1. Why do a majority of the tables on our SQL Server start with “t_”?
2. Why do some of the tables have data on the AWDB server but not on the HDS server, and vice versa? (Examples: t_Agent and t_Agent_Team and t_Agent_Team_Member and t_Person are blank on the HDS database but not blank on the AWDB database; but the t_Agent_Logout is blank on the AWDB database and not blank on the HDS database)
3. When data is moved to the HDS server every 30 minutes, is it also removed from the corresponding AWDB table?
4. In review of the agent26: Agent Consolidated Daily Report syntax info located on the WebView, 1 of the calculations uses the LoggedOnTimeToHalf from the Agent_Half_Hour table while the remaining calculations uses the same field from the Agent_Skill_Group_Half_Hour table. Can you please tell me why this is? Why would all of the percent calculations not use the data from the same table? (The % of time Agent paused and/or put a task on hold uses the Agent_Half_Hour Table. All other % calculations uses the same field from the Agent_Skill_Group_Half_Hour Table.)
5. Also in reviewing the agent26: Agent Consolidated Daily Report syntax info, I noticed that it contains the Skill_Group table, the Agent_Half_Hour table and the Media_Routing_Domain table. Both the Skill Group table and the Agen_Half_Hour table contain links to the Media_Routing_Domain table. Which relationship/join is actually utilized for this report?
6. Why doesn't the LoggedOnTimeToHalf field on both the Agent_Half_Hour table and the Agent_Skill_Group_Half_Hour table have the same value in them?
7. On the agent_26: Agent Consolidated Daily Report syntax explanation page, the Agent State Times: Log on Duration says that it is derived using the Agent_Half_Hour.LoggedOnTimeToHalf field, but when i convert this field to HH:MM:SS, it does not match the actual WebView report. But, when I use the Agent_Skill_Group_Half_Hour.LoggedOnTimeToHalfHour, it does match. Which one is correct?
8. On the agent_26: Agent Consolidated Daily Report, why does the Completed Tasks: Transfer Out contain both the TransferredOutCallsToHalf and the NetTransferredOutCallsToHalf fields? What's the difference between the two? What Transfer out data writes to each field?
Thank you.
Angie Combest
Clarian Health
[email protected]You need to be careful when looking at the three databases - Logger, AW, HDS - which use the same schema. But many of what appear to be tables in the AW are really views into the t_ tables in the HDS - the data is not there in the AW DB. You are right to look at the schema - but check with SQL Enterprise to understand a bit more.
In essence, the AW DB is for configuration data and real-time data. The HDS is for historical data. You can query the AW DB for (say) Call_Type_Half_Hour data and join with the Call_Type table to resolve the call type ID into its name - but the data is really in the HDS through the view.
The DB design is quite complex and sophisticated - many things are not obvious.
Keep up your research.
Regards,
Geoff -
SQL question- on how to handle groups of records at a time.
Hi,
I have a sql that looks like the following:
insert into INVALID_DATES_TMP
(id, gid, created, t_rowid, updated)
select id, gid, created, rowid, updated
from TABLE1
where fix_invalid_date_pkg.is_date_invalid('TABLE1', 'CREATED', ROWID) = 'Y';
COMMIT;
What the above sql does is selects all rows from TABLE1 where the CREATED column
has invalid dates and inserts them into invalid_dates_tmp table. So we can process/fix
those invalid dates from the temp table. Problem is our DBA said Table1 can have
millions of rows so the above sql can be very database intensive. So, I need to
figure out another way that may handle chunks of rows at a time from table1.
Any ideas are appreciated!
ThankYou,
Radhika.Hallo,
in general INSERT AS SELECT is the fastest method to insert into the table.
Probably you can use direct load ? (Hint APPEND).
Other options (INSERT IN LOOP or BULK + FORALL) are slower.
I think, this method is optimal.
Another question is, the function itself. It is not clear, whether it searches the invalid dates optimal. I suppose strong, that function uses dynamic SQL.
Why ? It is better to search static . Or you use this function for many other columns ? Could you post the function also ?
Regards
Dmytro -
Parent - child table issue wrt to count - SQL question
I have a scenario:
There are 2 tables (parent and child). lets say, case summary table and task level dimension table.
for every case id in case summary table, there would be multiple tasks in task level dim table with a flag indicator set to 1 for all tasks.
but while counting the number of cases active with flag indicator 1 (ofcourse when joining case summary table with task dimension table), for a case id only 1 instance of task needs to be accounted (even though it has more than one task , for counting active cases, the flag ind corresponding to a task in a case if set to 1 , then the case is considered active)..but while joining and taking count of case ids with flag indicator as 1, you get the count of every task row of a case which is incorrect logically. how to discard the rest of child records of a case in child table (task dimension table)?
I am not sure how to achieve this in sql query
Kindly help!
Case summary table
case id, busininess_unit, agent_name
1001, admin, Ram
1002, Finance, Sam
task table
case id, task_id,task_name, flag_indicator
1001, 1, 'New', 1
1001,2, 'Open',1
1001,3,'In progress',1
1002, 4, 'New', 1
(In fact task_id is not a big deal... even you can assume task id doesn't exist..only task name ... )
now my question... if my query should get the current active cases (ind=1); as per above it should essentially give 2... but my query gives me 4..you know the reason why.. but how do i get the correct count?
Thanks!may be you need just this:
select count(distinct case_id) from task
where indicator = 1;
If this is not what you are looking for, please elaborate and tell us the expected output and rest of the details as mentioned in FAQ Re: 2. How do I ask a question on the forums?: -
SQL question - please help!
Hi,
I am working on a SQL, please help ms with the question
below .... thanks
(1)Increase by 10% salary of these captain pilots who have
traveled more than 800,000 miles.
Routes | | Flights | |Pilots |
| | | | |
#routeID | | #flightNO | |#pilotID |
depAirportID | | airplaneNO| |*name |
arrAirportID |_______/| pilotID |\___________|*hours_in_air|
length | \| routeID |/ |*grade |
______________| |_____________| |*salary |
|____________|If the length column in routes is in hours, and it represents
additional hours to those shown in hours_in_air in pilots, then
the following should work:
UPDATE pilots
SET salary = salary * 1.1
WHERE pilotid in (SELECT a.pilotid
FROM pilots a,
(SELECT b.pilotid,sum(c.length) new_hours
FROM flights b, routes c
WHERE b.routeid = c.routeid
GROUP BY b.pilotid) d
WHERE a.pilotid = d.pilotid and
new_hours + hours_in_air >= 80000)I suspect that you probably need to add additional criteria to
the sub-query from flights and routes to take into account only
flights since the hours_in_air column from pilots was last
updated. However, your table structures do not indicate any
date sensitivity. If the table flights is emptied every time
hours_in_air is updated, then the query above will work. -
SQL Question (Select rows with multiple records)
Hello Gurus,
I am learning SQL and have a question. Thanks for your time and help.
I have 2 tables TABLE_AA and TABLE_BB. Both tables have two columns ID, DATA.
TABLE_AA is connected to TABLE_BB through ID field (TABLE_AA.AA_DATA = TABLE_BB.BB_DATA)
TABLE_AA
~~~~~~~
AA_ID______AA_DATA
~~~~~~~~~~~~~~~~
1111_______XXXX
2222_______QQQQ
3333_______ZZZZZ
4444_______PPPPP
~~~~~~~
TABLE_BB
~~~~~~~
BB_ID BB_DATA
~~~~~~~~~~~~~~~~
1111_______AAAA
2222_______BBBB
3333_______CCCC
3333_______DDDD
4444_______EEEE
I am looking to get those AA_ID values that have multiple in TABLE_BB for their parent reference in TABLE_BB.
So, from the above example, the sql should return the following as AA_ID 3333 has more than 1 reference value in BB_ID
AA_ID_____BB_ID
~~~~~~~~~~
3333______CCCC
3333______DDDDHi,
It's working fine. !!
14:10:05 topgun>With a As
14:10:06 2 (
14:10:06 3 Select 1111 c1, 'AAAA' c2 From dual Union All
14:10:06 4 Select 2222 , 'BBBB' From dual Union All
14:10:06 5 Select 3333 , 'CCCC' From dual Union All
14:10:06 6 Select 4444 , 'DDDD' From dual
14:10:06 7 ), b As
14:10:06 8 (
14:10:06 9 Select 1111 c1,'AAAA' c2 From dual Union All
14:10:06 10 Select 2222 , 'BBBB' From dual Union All
14:10:06 11 Select 3333 , 'CCCC' From dual Union All
14:10:06 12 Select 3333 , 'DDDD' From dual Union All
14:10:06 13 Select 4444 , 'EEEE' From dual
14:10:06 14 )
14:10:06 15 Select c1,
14:10:06 16 c2
14:10:06 17 From
14:10:06 18 (
14:10:06 19 Select a.c1,
14:10:06 20 b.c2,
14:10:06 21 Count(*) over (Partition By a.c1 Order By a.c1) cnt
14:10:06 22 From a,
14:10:06 23 b
14:10:06 24 Where a.c1 = b.c1
14:10:06 25 )
14:10:06 26 Where cnt = 2;
C1 C2
3333 CCCC
3333 DDDD- Pavan Kumar N
Maybe you are looking for
-
Application server file is full
Hi, I am downloading a file onto applocation server. the file contain huge amount of data. I scheduled a background job, It got cancelled with error DATASET_WRITE_ERROR Runtime errors DATASET_WRITE_ERROR
-
Refresh button deleted by mistake
First, my thanks to Dave Sawyer for answering my help plea so quickly and directing me here to ask my question. My question is how do I get the refresh button (which I accidently deleted) back on Safari? Thank's in advance, Tessie2
-
Itunes shuts down everytime i try to sinc music to my ipod touch
I just updated my itunes to the newest version and i have a 4.1 ipod touch. Whenever i try to put new music on my ipod, the syncing is stopped because itunes shuts down every single time.. I tried to reinstall it but it wont help. What am i suppose t
-
How use insert more than query (select)
insert into FISH_FAMILIES (id,code ,SCIENCE_NAME,ARABIC_NAME,LATIN_NAME,IS_FAMILY) SELECT ROWNUM,to_char(ROWNUM) FROM dual CONNECT BY LEVEL <= 43, select distinct FAMILY, ARABIC_DESCRIPTION,LATIN_DESCRIPTION from FISH_SPECIES , select distinct IS_FAM
-
Anyone know how to used GoodsMovementERPConfirmation_Out or V1
Where in ECC it config the call to GoodsMovementERPConfirmation_Out Proxy?