Using Decode in Order By clause
Hi all,
I've a prblem with the DECODE in ORDER BY clause
Could you please advise if I did something wrong with my sort order.
Actually,I've a store procedure which gather all information from several tables and return with a resultset.
Therefore I just post an example table_resultset instead of lenghthy StoreProc in forum
/* table contain the column need to be sort on the resultset */
create table table_sort (sortnum,sortname) as
select 1553, 'IDNO' from dual union all
select 1231, 'IDNAME' from dual union all
select 1001, 'CREDATE' from dual;
/* a sample of some information that resultset return by a storeproc */
create table table_resultset (idno,idname,credate) as
select 1111, 'SORT ORDER', sysdate-7 from dual union all
select 54555, 'NEED A TEST CASE', sysdate+5 from dual union all
select 10012, 'BEYOND THE LIMIT', sysdate from dual union all
select 10522, 'CONCENTRATION', sysdate+20 from dual union all
select 01231, 'A VALIDATION', sysdate-3 from dual;
/* this select statement similar to execute a storeproc with s decode in the ORDER BY clause */
select * from table_resultset
order by decode((select ltrim(rtrim(sortname)) from table_sort where sortnum=1231),'IDNO',1,'IDNAME',2,3);
OR
select * from table_resultset
order by case (select ltrim(rtrim(sortname)) from table_sort where sortnum=1231)
when 'IDNO' then 1
when 'IDNAME' then 2
else 3
end;
Thanks.
Thanks for the tip Samb ... :)
I got it ... all sort field must be same datatype.
SQL> create table table_sort (sortnum,sortname) as
2 select 1553, 'IDNO' from dual union all
3 select 1231, 'IDNAME' from dual union all
4 select 1001, 'CREDATE' from dual;
Table created.
SQL> create table table_resultset (idno,idname,credate) as
2 select 1111, 'SORT ORDER', sysdate-7 from dual union all
3 select 54555, 'NEED A TEST CASE', sysdate+5 from dual union all
4 select 10012, 'BEYOND THE LIMIT', sysdate from dual union all
5 select 10522, 'CONCENTRATION', sysdate+20 from dual union all
6 select 01231, 'A VALIDATION', sysdate-3 from dual;
Table created.
SQL> select * from table_resultset;
IDNO IDNAME CREDATE
1111 SORT ORDER 08-07-03
54555 NEED A TEST CASE 08-07-15
10012 BEYOND THE LIMIT 08-07-10
10522 CONCENTRATION 08-07-30
1231 A VALIDATION 08-07-07
SQL> select * from table_sort;
SORTNUM SORTNAM
1553 IDNO
1231 IDNAME
1001 CREDATE
if I want to sort the resultset by the column IDNAME of table_resultset then
SQL> select * from table_resultset
2 order by decode((select ltrim(rtrim(sortname)) from table_sort
3 where sortnum=1231),'IDNO',to_char(idno),'IDNAME',idname,to_char(credate,'yyyymmdd'));
IDNO IDNAME CREDATE
1231 A VALIDATION 08-07-07
10012 BEYOND THE LIMIT 08-07-10
10522 CONCENTRATION 08-07-30
54555 NEED A TEST CASE 08-07-15
1111 SORT ORDER 08-07-03
if I want to sort the resultset by the column CREDATE of table_resultset then
SQL> select * from table_resultset
2 order by decode((select ltrim(rtrim(sortname)) from table_sort
3 where sortnum=1001),'IDNO',to_char(idno),'IDNAME',idname,to_char(credate,'yyyymmdd'));
IDNO IDNAME CREDATE
1111 SORT ORDER 08-07-03
1231 A VALIDATION 08-07-07
10012 BEYOND THE LIMIT 08-07-10
54555 NEED A TEST CASE 08-07-15
10522 CONCENTRATION 08-07-30
But if I want to sort the resultset by the column IDNO of table_resultset then I've a problem due to the field converted into character, and the field IDNO define as number(9) of a table in production. therefore I've to find a solution when that field convert into character must be same length in order to sort IDNO correctly. As you can see from below
SQL> select * from table_resultset
2 order by decode((select ltrim(rtrim(sortname)) from table_sort
3 where sortnum=1553),'IDNO',to_char(idno),'IDNAME',idname,to_char(credate,'yyyymmdd'));
IDNO IDNAME CREDATE
10012 BEYOND THE LIMIT 08-07-10
10522 CONCENTRATION 08-07-30
1111 SORT ORDER 08-07-03
1231 A VALIDATION 08-07-07
54555 NEED A TEST CASE 08-07-15
your suggestion always welcome.
Thanks,
DT.
Similar Messages
-
How can we use DECODE function in where clause.
Hi Guys,
I have to use DECODE function in where clause.
like below
select * from tab1,tab2
where a.tab1 = b.tab2
and decode(code, 'a','approved')
in this manner its not accepting?
Can any one help me on this or any other aproach?
Thanks
-LKR>
I am looking for to decode the actual db value something in different for my report.
like if A then Accepted
elseif R then Rejected
elseif D then Denied
these conditions I have to check in where clause.
>
what are you trying to do?
may be you are looking for
select * from tab1,tab2
where a.tab1 = b.tab2
and
(decode(:code, 'A','Accepted') = <table_column>
or
decode(:code, 'R','Rejected') = <table_column>
or
decode(:code, 'D','Denied') = <table_column>
) -
Is it possible to use a decode function in the order by clause, when you have two select statements with a union between? I seem to be getting an error-message telling me to type a number.
Can anybody help me?Tove,
Is this what you mean?
SQL> SELECT
2 *
3 FROM
4 (SELECT
5 empno no
6 , ename name
7 , job description
8 FROM emp
9 UNION
10 SELECT
11 deptno no
12 , dname name
13 , loc description
14 FROM dept
15 )
16 ORDER BY
17 DECODE(1
18 , 1,TO_CHAR(no)
19 , 2,name
20 , 3,description)
21 /
NO NAME DESCRIPTION
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
7369 SMITH CLERK
7499 ALLEN SALESMAN
7521 WARD SALESMAN
7566 JONES MANAGER
7654 MARTIN SALESMAN
7698 BLAKE MANAGER
7782 CLARK MANAGER
7788 SCOTT ANALYST
7839 KING PRESIDENT
7844 TURNER SALESMAN
7876 ADAMS CLERK
7900 JAMES CLERK
7902 FORD ANALYST
7934 MILLER CLERK
18 rows selected.Now, to order by the second column, I set the first parameter of the
DECODE to "2":
SQL> SELECT
2 *
3 FROM
4 (SELECT
5 empno no
6 , ename name
7 , job description
8 FROM emp
9 UNION
10 SELECT
11 deptno no
12 , dname name
13 , loc description
14 FROM dept
15 )
16 ORDER BY
17 DECODE(2
18 , 1,TO_CHAR(no)
19 , 2,name
20 , 3,description)
21 /
NO NAME DESCRIPTION
10 ACCOUNTING NEW YORK
7876 ADAMS CLERK
7499 ALLEN SALESMAN
7698 BLAKE MANAGER
7782 CLARK MANAGER
7902 FORD ANALYST
7900 JAMES CLERK
7566 JONES MANAGER
7839 KING PRESIDENT
7654 MARTIN SALESMAN
7934 MILLER CLERK
40 OPERATIONS BOSTON
20 RESEARCH DALLAS
30 SALES CHICAGO
7788 SCOTT ANALYST
7369 SMITH CLERK
7844 TURNER SALESMAN
7521 WARD SALESMAN
18 rows selected.
SQL> SELECT
2 *
3 FROM
4 (SELECT
5 empno no
6 , ename name
7 , job description
8 FROM emp
9 UNION
10 SELECT
11 deptno no
12 , dname name
13 , loc description
14 FROM dept
15 )
16 ORDER BY
17 DECODE(3
18 , 1,TO_CHAR(no)
19 , 2,name
20 , 3,description)
21 /
NO NAME DESCRIPTION
7788 SCOTT ANALYST
7902 FORD ANALYST
40 OPERATIONS BOSTON
30 SALES CHICAGO
7369 SMITH CLERK
7934 MILLER CLERK
7900 JAMES CLERK
7876 ADAMS CLERK
20 RESEARCH DALLAS
7566 JONES MANAGER
7698 BLAKE MANAGER
7782 CLARK MANAGER
10 ACCOUNTING NEW YORK
7839 KING PRESIDENT
7499 ALLEN SALESMAN
7844 TURNER SALESMAN
7654 MARTIN SALESMAN
7521 WARD SALESMAN
18 rows selected.I needed to put the TO_CHAR in the DECODE so all of the columns
by which I could potentially order are VARCHAR2's, else I was
getting
SQL> /
DECODE(1
ERROR at line 17:
ORA-01785: ORDER BY item must be the number of a SELECT-list expressionHTH
T. -
Decode in order by clause with desc
I want to user order by clause with decode + desc order.
somthing like
ORDER BY DECODE ('SALE', e.sale, 'SALE DESC' ????)
????-> How to use desc order with decode
Thanks in advanceI thought smart people in this OTN community will understand that I am trying to order by the thisdate column that is timestamp datatype:). My apologize for not being that specific.
The query I gave is a simple version of the stored procedure I am using. The point is I need to order by - depending on one of the parameters that is passed to the procedure. In simplest decode statements, its something like
order by decode(p_in_var,'ABC','thisdate asc','DEF','thisdate desc',thisdate asc)
Here p_in_var is varchar input parameter to the stored procedure.
Please let me know if there is any more information needed.
Thx! -
Why I cannot use RowID in where clause but can use it in order by clause
I am on SQL Server 2008.
1. If I use
SELECT (ROW_NUMBER() over
(order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, *
FROM [JnJ_Version1].[dbo].[td_Production_Week]
order by RowID
Statement works
But
2. If I use
SELECT (ROW_NUMBER() over
(order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, *
FROM [JnJ_Version1].[dbo].[td_Production_Week]
where RowID > 10000
I get error, RowID is an invalid column Name why? How to correct query 2.This is due to the logical evaluation order of a SELECT statement. Logically, a SELECT statement is computed in the order:
FROM (which includes JOIN)
WHERE
GROUP BY
HAVING
SELECT
ORDER BY
OFFSET
Thus, you can use what is defined in the SELECT list in the ORDER BY clause, but not in the WHERE clause.
In the case of row_number(), this has immediate repurcussions. row_number() is computed from the rows as they arrive the SELECT clause, and if you then you would filter on the value in the WHERE clause you would be going round in circles.
To do what you are looking for, you use a nested table, for instance with a CTE:
WITH numbering AS (
SELECT (ROW_NUMBER() over
(order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, *
FROM [JnJ_Version1].[dbo].[td_Production_Week]
SELECT *
FROM numbering
WHERE RowID > 10000
Erland Sommarskog, SQL Server MVP, [email protected] -
Using decode to define "where" clause
Gurus,
Before, I was unioning several queries to get my desired results. Is there a way to utilize decode to define my "where" conditions?
Thanks
msi.global_attribute1 HTS_Number,
msi.global_attribute2 ECCN_Number ,
msi.market_price price, --- double-check
decode(msi.serial_number_control_code,5,'Serial','Lot') control_type,
-- add item_type
--Item Label Creation At Receipt or At Sales Order Issue
(case
when enabled_flag = 'Y' and end_date_active is null then 'Active'
when enabled_flag = 'Y' and end_date_active > sysdate then 'Active'
when enabled_flag = 'Y' and end_date_active < sysdate then 'Inactive'
when enabled_flag = 'N' then 'Inactive'
else 'Active'
end) status,
from inv.mtl_system_items_b msi,
po_hazard_classes phc,
po_un_numbers pun
where msi.hazard_class_id = phc.hazard_class_id(+)
and msi.un_number_id = pun.un_number_id(+)
and msi.organization_id = 543
and msi.creation_date = msi.last_update_date
--and 'New Items' = nvl(p_item_status,'All Items') --p_item_status
and decode('New Items', --p_item_status,
'New Items', (msi.creation_date = msi.last_update_date),
'Updated Items', (msi.creation_date <> msi.last_update_date),
'All Items', (1=1), (1=1))
and msi.segment2 = '14078'Hi,
sreese wrote:
Before, I was unioning several queries to get my desired results. Is there a way to utilize decode to define my "where" conditions?Depending on what you mean, yes.
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Simplify the problem as much as possible. Remove all tables and columns that play no role in this problem.
Always say which version of Oracle you're using.
Here's an example of two UNIONed queries:
SELECT deptno
, SUM (sal) AS total_sal
, 'MANAGEMENT' AS grp_name
FROM scott.emp
WHERE job IN ('MANAGER', 'PRESIDENT')
GROUP BY deptno
UNION ALL
SELECT deptno
, SUM (sal) AS total_sal
, 'OLD-TIMERS' AS grp_name
FROM scott.emp
WHERE hiredate < DATE '1984-01-01'
GROUP BY deptno
ORDER BY deptno
, grp_name
;Output:
` DEPTNO TOTAL_SAL GRP_NAME
10 7450 MANAGEMENT
10 8750 OLD-TIMERS
20 2975 MANAGEMENT
20 6775 OLD-TIMERS
30 2850 MANAGEMENT
30 9400 OLD-TIMERSA more efficient way to get the same information, without a UNION is:
SELECT deptno
, SUM (CASE WHEN job IN ('MANAGER', 'PRESIDENT') THEN sal END) AS management
, SUM (CASE WHEN hiredate < DATE '1984-01-01' THEN sal END) AS old_timers
FROM scott.emp
WHERE job IN ('MANAGER', 'PRESIDENT')
OR hiredate < DATE '1984-01-01'
GROUP BY deptno
ORDER BY deptno
;Output:
` DEPTNO MANAGEMENT OLD_TIMERS
10 7450 8750
20 2975 6775
30 2850 9400As you can see, the results aren't exactly the same. UNION makes it easy to get more rows in the output than there are in the original; CASE (or DECODE,you can use whichever you like) makes it easy to get fewer rows and more columns. If you reallt want one kind of output or the other, it can be done with a little more work using either UNION or CASE.
When using CASE, the WHERE clause is typically more inclusive than any of the WHERE caluses in the UNION. Some of the conditions (in this example, all of the conditions) that were in the separate WHERE clauses of the UNION get changed to be conditions in separate CASE expressions. -
Sorting character column ( used in order by clause dynamically)
Hi,
I need help on sorting character-based numbers. Like say, I want to sort customers based on street numbers(which is a character string being used in the
order by clause) they live in.
The criteria are :
i. Numbers must take precedence.
This being a character string, 1000001 comes before 2. This shouldn't happen. And you cannot use to_number
since using it with a string having characters in it would raise an error.
ii. If only a single alphabet occurs as the last character, then treat the whole string as a number except the last character and then sort it
as if sorting a number. Something like : if you have 1000A, 200D, 200B, 1000X, the result would be 200B,200D,1000A,1000X.
iii. if a character occurs elsewhere in the string, then perform the search normally as if performing a character search.
The output of the following data :
100
A101
B100A
110C
C120B
120
100020
120C
C1100
100D
would be like :
100
100D
110C
120
120C
100020
A101
B100A
C120B
C1100
Please note that the sort is being done dynamically, so I could have access to the values of the street numbers only during run time.
Any help is really appreciated.
Thanks in advance.
Regards,
Anil.Create a function to test whether the column is numeric :
create FUNCTION is_numeric(v_number VARCHAR2)
RETURN INTEGER
IS
l_number NUMBER;
BEGIN
IF INSTR(UPPER(v_number),'E') > 0 THEN
RETURN 0;
END IF;
l_number := TO_NUMBER(v_number);
RETURN 1;
EXCEPTION
WHEN OTHERS THEN
RETURN 0;
END;
And try this query
Assume the table name is TEST with column STREET
select * from TEST
order by case is_numeric(STREET) when 1 then LPAD(STREET,20, ' ') else STREET end
Please make sure that 20 mentioned above is the column size for STREET.
Hope this helps.
-Nags -
Decode/Case in Where clause
Hello,
We are experiencing an issue with a Select statement that uses Decode in the Where clause. Specifically, it seems to be ignoring a nested Decode and just returning the default value. We have another nested decode that works fine, though.
A member of our team mentioned that he believed there was an issue with using Decode and Case statements inside of a where clause within HTML DB...Is this correct? If it is, is there a workaround? Since the nested Decode works elsewhere in this statement, that doesn't seem right.
My select statement looks like:
SELECT
SUBSTR(OBOB.OBOB_CNAME, 0, 30) d,
OBOB.OBOB_UID r
FROM
ISR_OBOB_OBJECT OBOB,
ISR_OBAF_OBJECT_AFFILIATION OBAF,
ISR.ISR_OBSD_SDR OBSD
WHERE
OBOB.OBOB_UID = OBSD.OBOB_UID AND
OBOB.OBOB_UID = OBAF.OBOB_B_UID AND
/*If Personal radio button is selected, displays all SDRs associated with user.
If All is selected, displays all SDRs associated with IS group selected from drop down list
or every SDR.
OBAF.OBOB_A_UID = DECODE(:P1_DISPLAY_ALL,
'Personal', :F101_APP_USER_UID,
/*This is the decode statement that it seems to ignore. If ALL is selected, the query should see if a group has
has been selected from a drop down list that appears when the ALL button is chosen. If a group is selected
(the item isn't 0), only SDRs for that group should be shown. Otherwise, all SDRs for every group should display.
'ALL', DECODE(:P1_SEARCH_IS_SUPPORT_GROUP, 0, OBAF.OBOB_A_UID, :P1_SEARCH_IS_SUPPORT_GROUP),
OBAF.OBOB_A_UID) AND
/*If Personal radio button is selected, display SDRs where user is the Primary assignee.
OBAF.OBAT_UID = DECODE(:P1_DISPLAY_ALL, 'Personal', (select OBAT_UID from ISR_OBAT_OBJ_AFFIL_TYPE WHERE OBAT_APP_REF = 'SDR_PRIMARY'), OBAF.OBAT_UID) AND
/*If a SDR Status (open, completed, on hold, not started...) is selected, only display the SDRs with that status.
OBSD.KTTR_STATUS_UID = DECODE(:P1_ISR_STATUS_UID, 0, OBSD.KTTR_STATUS_UID, :P1_ISR_STATUS_UID) AND
/*If SDR_History textbox is Null, or Open, Not Started, or On Hold SDR status has been selected, then all SDRs with
a create date between today and 99999 months ago will display. Otherwise, only SDRs with a create date between
today and however many months are in the textbox will display (i.e. Completed SDRs created in the past 6 months.)
MONTHS_BETWEEN(sysdate, OBSD.OBSD_CREATE_DATE) <= DECODE(:P1_SDR_HISTORY, NULL, 99999, DECODE(:P1_ISR_STATUS_UID,
(select KTTR_UID from ISR_KTTR_TRANSLATION where KTTR_APP_REF = 'SD_STAT_OPEN'), 99999,
(select KTTR_UID from ISR_KTTR_TRANSLATION where KTTR_APP_REF = 'SD_STAT_NOT_STA'), 99999,
(select KTTR_UID from ISR_KTTR_TRANSLATION where KTTR_APP_REF = 'SD_STAT_HOLD'), 99999,
:P1_SDR_HISTORY))
/*Alphabetical order
Order by
dWe originally wrote this as a PL/SQL statement that returned a query string since most of the where clause is dependent on items the user may or may not select, but we have moved the query into a multiselect list, which only seems to allow SQL Queries.
Any help or advice would be appreciated.
Thanks,
ScottScott: Did you try running that SQL statement in SQL Workshop in Apex? You can run it as it is, it will popup a window asking you to enter values for the bind variables.
JAC73: I don't think an IN clause doesn't work that way, you need a actual SQL sub-query, not an expression from a DECODE/CASE statement. Search this site for str2tbl and see Tom's excellent discussion at
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:110612348061 -
Exception caused by bind variables in ORDER BY clause and VO RANGE_PAGING
Hi,
I'm using a ViewObject in RANGE_PAGING mode and discovered a problem when using bind variables in the ORDER BY clause of my statement:
SELECT * FROM (SELECT /*+ FIRST_ROWS */ IQ.*, ROWNUM AS Z_R_N FROM (
SELECT * FROM T_TABLE WHERE (attr1 = :1) ORDER BY decode (attr2, :2, 1, null, 0, -1) desc, attr3 ) IQ
WHERE ROWNUM < :2) WHERE Z_R_N > :3 When a bind variable is used in the ORDER BY CLAUSE and the method VO.getEstimatedRowCount() is call then the DB issued an SQL error:
java.sql.SQLException: Ungültiger Spaltenindex (eng.: invalid column index)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:137)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:174)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:239)
at oracle.jdbc.driver.OraclePreparedStatement.setStringInternal(OraclePreparedStatement.java:4612)The numbering of the bind variables indicates that the last two bind variables have the wrong numbering (??)
When I rewrite the SQL into the following statement, the SQL error does not occur but I have not verified yet that the VO delivers the correct range of data because the numbering of the bind variables is not correct.
SELECT * FROM (SELECT /*+ FIRST_ROWS */ IQ.*, ROWNUM AS Z_R_N FROM (
SELECT *, decode (attr2, :1, 1, null, 0, -1) as ATTR_FOR_SORTING FROM T_TABLE WHERE (attr1 = :2) ORDER BY ATTR_FOR_SORTING desc, attr3 ) IQ
WHERE ROWNUM < :2) WHERE Z_R_N > :3I'm working with JDev 10.1.2 and Oracle DB 9203.
Any comments are welcome!
Thanks,
MarkusYou are using the bind variable :2 twice. Did you try
SELECT * FROM (SELECT /*+ FIRST_ROWS */ IQ.*, ROWNUM AS Z_R_N FROM (
SELECT * FROM T_TABLE WHERE (attr1 = :1) ORDER BY decode (attr2, :2, 1, null, 0, -1) desc, attr3 ) IQ
WHERE ROWNUM < :4) WHERE Z_R_N > :3
setWhereClauseParm(0, "a"); // :1
setWhereClauseParm(1, "b"); // :2
setWhereClauseParm(2, "c"); // :3
setWhereClauseParm(3, "b"); // :2setting the fourth parameter the same as the second one?
I remeber reading something about using bind variables twice causing problems, but I#m not sure about it. -
Hello,
Sorry I am posting it for the second time
In Oracle , the order by clause does not return the expected query result, if any of the field value in the order by clause has an empty string.
Oracle treats the empty string as null value and ORDER BY gives a result with the empty string field values listed at last.
For example :
test is a sample table containing "name" field.
Query: "select name from test order by name"
In SQL Server/Access
Result (1)
NAME
(blank)
(blank)
User1
User2
User3
In Oracle
Result (2)
NAME
User1
User2
User3
(blank)
(blank)
I know some of the Work arounds for this as listed below :
1) To use NVL in Order By Clause.
i.e., the modified query
"select name from test order by nvl(name,0)"
gives the result same as Result (1).
2) To have single blank space in the field value if it is empty.
I dont want to use either of these two options b'se it would lead to a mass change in my existing code.
Is there any way i can do a
collation order settings in the Oracle databases to get the results as in MS SQL/Access.
Or Is there any other way that i can set the
option once for this and need not worry abt it afterwards?
Can Any help me out in Solving this?
Thanks
Devi
nullFor fun and out of curiosity, I tried :
SQL> select /*+ leading(t) use_nl(e t) */
2 e.deptno
3 , e.empno
4 from scott.emp e
5 , table(sys.odcinumberlist(30,10,20)) t
6 where e.deptno = t.column_value
7 ;
DEPTNO EMPNO
30 7499
30 7521
30 7654
30 7698
30 7844
30 7900
10 7782
10 7839
10 7934
20 7369
20 7566
20 7902
12 rows selected
It "seems" to work but of course we can't expect a consistent behaviour, or can we? ;) -
Order By Clause with Empty Field values !
Hello,
In Oracle , the order by clause does not return the expected query result, if any of the field value in the order by clause has an empty string.
Oracle treats the empty string as null value and ORDER BY gives a result with the empty string field values listed at last.
For example :
test is a sample table containing "name" field.
Query: "select name from test order by name"
In SQL Server/Access
Result (1)
NAME
(blank)
(blank)
User1
User2
User3
In Oracle
Result (2)
NAME
User1
User2
User3
(blank)
(blank)
I know some of the Work arounds for this as listed below :
1) To use NVL in Order By Clause.
i.e., the modified query
"select name from test order by nvl(name,0)"
gives the result same as Result (1).
2) To have single blank space in the field value if it is empty.
I dont want to use either of these two options b'se it would lead to a mass change in my existing code.
Is there any way i can do a
collation order settings in the Oracle databases to get the results as in MS SQL/Access.
Can Any help me out in Solving this?
Thanks
Devi Shankar
nullBharath,
I am moving this question to the SQL forum.
Regards,
Geoff -
[JPA/TOPLINK] is the function "lower" supported in "order by" clause?
In EJB-QL
I can use lower() or upper() in where clause.
But there is always a parse exception thrown when i tried to use it in main clause or order by clause.
works:
select s from Student s where lower(s.name) like 'm%'
exception thrown:
select s from Student s where s.name like 'm%' order by lower(s.name)
OR --------------
Why i am asking this is that the resultset returned from database is not alphabetical sorted but ascii sorted, which means any characters with upper case is always prior to the ones with lower case.
If EJB-QL doesn't support using lower() in order by clause, do I have any other options to avoid this problem?
BTW, it is the Oracle 10g we are using as DB
many thanks,
Xuphey
Edited by: Xuphey on Nov 29, 2007 1:33 AMIf you want to do this, you'd have to use dynamic SQL (execute immediate or DBMS_SQL). For the easier 'execute immediate' approach, you'd do something like
create or replace someProc( someArg varchar2 )
as
strSQL varchar2(4000)
begin
strSQL := <<string containing your SQL statement up to the order by clause>>
strSQL := strSQL || 'ORDER BY ' || someArg
execute immediate strSQL;
endJustin -
Order by clause using decode function
Hi everybody,
i need below order in my report.
Connecticut
greenwich
stamford
bridgeport
New York
NYC
wrestcher
byram
Georgia
atlanta
athens
oconny
first i need above order in my view out put.
so in order by clause i used first decode function for State ordering
and in second decode function for city ordering.
i do not need order by ascending or descending.
so pls anybody can help me.
any help is greatly appreciated.
thanks.add asc after the decode. default is desc
-
Using bind varaible for order by clause
Hello
Can some one suggest for the following scenario?
My order by clause will be constructed based on the selected fields in the form. And now the order by clause need to be passed as parameter to Excel report.
When I use Ref cursor and OPEN-FOR-USING clause, data is not sorted.
do we have any other alternate for this?
Please observe the example code for the same. Block below resembles the code for to select the data for excel report.
SQL> select * from t;
T
sdf
der
gdr
ghft
ytut
lkrt
rtrt
tyrt
SQL> declare
2 l_order_by VARCHAR2 (100);
3 l_test varchar2(10);
4 TYPE TEST IS REF CURSOR;
5 c_TEST test;
6 L_string VARCHAR2(2000):= 'select * from t order by :pi_order';
7 begin
8 l_order_by := ' t DEsc';
9 open c_test for l_string using l_order_By;
10 loop
11 fetch c_test into l_test;
12 exit when c_TEST%notfound;
13 dbms_output.put_line (l_test);
14 end loop;
15 close c_test;
16 end;
17 /
sdf
der
gdr
ghft
ytut
lkrt
rtrt
tyrt
PL/SQL procedure successfully completed.
Cheers
Ram KanalaMy order by clause will be constructed based on the selected fields in the formDoes this look like you need ?
SQL> var so number
SQL> exec :so := 1;
PL/SQL procedure successfully completed.
SQL> set serveroutput on
SQL> declare
2 rc sys_refcursor;
3 type emprec is table of emp%rowtype index by pls_integer;
4 erec emprec;
5 begin
6
7 open rc for 'select * from emp order by ' ||
8 'decode(:p,1,ename,2,deptno,3,sal,null),' ||
9 'decode(:p,4,ename,5,deptno,6,sal,null) desc' using :so,:so;
10 fetch rc bulk collect into erec;
11 close rc;
12
13 for i in 1..erec.count loop
14 dbms_output.put_line('Ename = ' || erec(i).ename || ', deptno = ' || erec(i).deptno || ', sal
= ' || erec(i).sal);
15 end loop;
16 end;
17 /
Ename = ADAMS, deptno = 20, sal = 1100
Ename = ALLEN, deptno = 30, sal = 1600
Ename = BLAKE, deptno = 30, sal = 2850
Ename = CLARK, deptno = 10, sal = 2450
Ename = FORD, deptno = 20, sal = 3000
Ename = JAMES, deptno = 30, sal = 950
Ename = JONES, deptno = 20, sal = 2975
Ename = KING, deptno = 10, sal = 5000
Ename = MARTIN, deptno = 30, sal = 1250
Ename = MILLER, deptno = 10, sal = 1300
Ename = SCOTT, deptno = 20, sal = 3000
Ename = SMITH, deptno = 20, sal = 800
Ename = TURNER, deptno = 30, sal = 1500
Ename = WARD, deptno = 30, sal = 1250
PL/SQL procedure successfully completed.
SQL> exec :so := 2
PL/SQL procedure successfully completed.
SQL> /
Ename = CLARK, deptno = 10, sal = 2450
Ename = KING, deptno = 10, sal = 5000
Ename = MILLER, deptno = 10, sal = 1300
Ename = JONES, deptno = 20, sal = 2975
Ename = FORD, deptno = 20, sal = 3000
Ename = ADAMS, deptno = 20, sal = 1100
Ename = SMITH, deptno = 20, sal = 800
Ename = SCOTT, deptno = 20, sal = 3000
Ename = WARD, deptno = 30, sal = 1250
Ename = TURNER, deptno = 30, sal = 1500
Ename = ALLEN, deptno = 30, sal = 1600
Ename = JAMES, deptno = 30, sal = 950
Ename = BLAKE, deptno = 30, sal = 2850
Ename = MARTIN, deptno = 30, sal = 1250
PL/SQL procedure successfully completed.
SQL> exec :so := 5;
PL/SQL procedure successfully completed.
SQL> /
Ename = BLAKE, deptno = 30, sal = 2850
Ename = TURNER, deptno = 30, sal = 1500
Ename = ALLEN, deptno = 30, sal = 1600
Ename = MARTIN, deptno = 30, sal = 1250
Ename = WARD, deptno = 30, sal = 1250
Ename = JAMES, deptno = 30, sal = 950
Ename = SCOTT, deptno = 20, sal = 3000
Ename = JONES, deptno = 20, sal = 2975
Ename = SMITH, deptno = 20, sal = 800
Ename = ADAMS, deptno = 20, sal = 1100
Ename = FORD, deptno = 20, sal = 3000
Ename = KING, deptno = 10, sal = 5000
Ename = MILLER, deptno = 10, sal = 1300
Ename = CLARK, deptno = 10, sal = 2450
PL/SQL procedure successfully completed.Rgds. -
How to use left outer joins ,right outer joins and order by clause for belo
Hi,
How to use left outer joins ,right outer joins and order by clause for below XML query.
The query which is red colour returns null then its not displaying any values for columns in that tables. Tried decode, nvl function hasn't worked.
SELECT XMLAGG ( XMLELEMENT( "P", XMLFOREST( P.process_id AS Ppid,
(SELECT XMLAGG( XMLELEMENT( "PI", XMLFOREST( PI.question_id AS PIqid,
PI.process_id AS PIpid,
PI.innertext AS
PItext, PI.itemtype AS PItype,
PI.linkfrom AS PIfrom,
PI.linkto AS PIto,
PI.associated AS PIas,
PI.content_id AS PIc,
PI.exitpoint1_id AS PIe1,
PI.exitpoint2_id AS PIe2,
PI.exitpoint3_id AS PIe3,
PI.followoncall AS PIfoc,
PI.userinput AS PIui,
PI.resolveidentifier AS PIri,
PI.libquestion_idfk AS PIlqid,
PI.isLocked AS PIstls,
PI.PreviousAnswer AS PIPAns,
PI.VisibleToAgent AS PIVAgent,
PI.RetryAttempt AS PIRetry,
PI.Tags AS PITag,
SELECT XMLAGG( XMLELEMENT( "PO", XMLFOREST( PO.option_id AS POoid,
PO.question_id AS POqid,
PO.process_id AS popid,
PO.opt_innertext AS POtext,
PO.opt_linkfrom AS POfrom,
PO.opt_linkto AS POto,
PO.libquestion_idfk AS POlqid,
PO.liboption_idfk AS POloid ) ) )
FROM vw_liveProcessOption_Sim_v6 PO
WHERE PI.question_id = PO.question_id (+)
AND PI.process_id = PO.process_id (+)
) "A" ) ) ) AS "PO"
FROM vw_liveProcessItem_Sim_v6 PI
WHERE P.process_id = PI.process_id
) "A" ) ) ) AS "PI"
FROM liveProcess_ec P
WHERE (P.process_id = 450)
Any help really appreciated.
Thanksuser512743 wrote:
Hi,
Here below is the scripts of tables, insert statements and Required output.
CREATE TABLE VW_LIVEPROCESSOPTION_SIM_v6
( "OPTION_ID" NUMBER,
"QUESTION_ID" NUMBER(10,0),
"PROCESS_ID" NUMBER(10,0),
"OPT_INNERTEXT" VARCHAR2(200 CHAR),
"OPT_LINKFROM" VARCHAR2(20 CHAR),
"OPT_LINKTO" VARCHAR2(20 CHAR),
"LIBQUESTION_IDFK" NUMBER,
"LIBOPTION_IDFK" NUMBER
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,2,450,'Yes',null,'5',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,3,450,'Yes',null,'5',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,5,450,'Yes',null,'6',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,6,450,'Yes',null,'7',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,8,450,'Block All',null,'9',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,9,450,'Yes',null,'10',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,11,450,'Yes',null,'12',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,12,450,'Yes',null,'13',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,14,450,'Yes',null,'16',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,2,450,'No',null,'3',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,3,450,'No',null,'4',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,5,450,'No',null,'8',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,6,450,'No',null,'8',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,8,450,'Standard',null,'11',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,9,450,'No',null,'11',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,11,450,'No',null,'14',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,12,450,'No',null,'14',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,14,450,'No',null,'15',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (3,8,450,'Disabled',null,'12',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (4,8,450,'User Defined',null,'12',null,null);
REATE TABLE "VW_LIVEPROCESSITEM_SIM_v6"
( "QUESTION_ID" NUMBER(10,0),
"PROCESS_ID" NUMBER(10,0),
"INNERTEXT" VARCHAR2(200 CHAR),
"ITEMTYPE" VARCHAR2(50 CHAR),
"LINKFROM" VARCHAR2(500 CHAR),
"LINKTO" VARCHAR2(500 CHAR),
"ASSOCIATED" VARCHAR2(200 CHAR),
"CONTENT_ID" NUMBER,
"EXITPOINT1_ID" NUMBER(10,0),
"EXITPOINT2_ID" NUMBER(10,0),
"EXITPOINT3_ID" NUMBER(10,0),
"RESOLVEIDENTIFIER" VARCHAR2(40 CHAR),
"LIBQUESTION_IDFK" NUMBER(10,0),
"FOLLOWONCALL" NUMBER(1,0),
"USERINPUT" VARCHAR2(200 CHAR),
"ISLOCKED" NUMBER(1,0),
"PREVIOUSANSWER" NUMBER(1,0),
"VISIBLETOAGENT" NUMBER(1,0),
"RETRYATTEMPT" NUMBER(10,0),
"TAGS" VARCHAR2(50 BYTE)
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (1,450,'CBB1015 - Router Firewall Settinngs Process','Title',null,'2',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (2,450,'Is the customers PC Firewall turned off?','Question','1','2.2,2.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (3,450,'Advise the customer to turn off the PC Firewall in order to continue. Has this been done?','Question','2.2','3.2,3.1',null,278,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (4,450,'Advise the customer the PC Firewall must be switched off before this process????','ExitPoint','3.2',null,null,null,14,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (5,450,'Is the customer able to access the internet now?','Question','3.1,2.1','5.2,5.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (6,450,'Is the customer having a problem with a specific website?','Question','5.1','6.2,6.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (7,450,'1536: CBB1008 - Browser Setup and Daignostics','SubProcess','6.1',null,'1536-1-0',null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (8,450,'What is the security level on the CPE Management page?','Question','6.2,5.2','8.4,8.3,8.2,8.1',null,279,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (9,450,'Change the security level to Standard. Does this resolve the customers issue?','Question','8.1','9.2,9.1',null,280,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (10,450,'Issue Resolved','ExitPoint','9.1',null,null,null,1,6,122,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (11,450,'Change the security level to Disabled. Is the customer able to browse the internet?','Question','9.2,8.2','11.2,11.1',null,281,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (12,450,'Change the security level to Standard. Is the customer able to browse the internet now?','Question','11.1,8.3,8.4','12.2,12.1',null,283,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (13,450,'Issue Resolved','ExitPoint','12.1',null,null,null,1,6,123,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (14,450,'Ask the customer to perform a master reset. Does this resolve their issue?','Question','12.2,11.2','14.2,14.1',null,282,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (15,450,'Faulty CPE','ExitPoint','14.2',null,null,null,1,6,124,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (16,450,'Issue Resolved','ExitPoint','14.1',null,null,null,1,6,123,null,null,null,null,null,null,null,null,null);
CREATE TABLE "LIVEPROCESS_EC_V"
( "PROCESS_ID" NUMBER(10,0),
"USER_ID" NUMBER(10,0),
"CREATED" TIMESTAMP (6)
Insert into LIVEPROCESS_EC (PROCESS_ID,USER_ID,CREATED) values (450,7460,to_timestamp('21-APR-08 09.34.41.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'));
Required O/P in XML format
<P>
<Ppid>450</Ppid>
<PI>
<PIqid>1</PIqid>
<PIpid>450</PIpid>
<PItext>CBB1015 - Router Firewall Settinngs Process</PItext>
<PItype>Title</PItype>
<PIto>2</PIto>
<PO />
</PI>
<PI>
<PIqid>2</PIqid>
<PIpid>450</PIpid>
<PItext>Is the customers PC Firewall turned off?</PItext>
<PItype>Question</PItype>
<PIfrom>1</PIfrom>
<PIto>2.2,2.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>2</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>5</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>2</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>3</POto>
</PO>
</PI>
<PI>
<PIqid>3</PIqid>
<PIpid>450</PIpid>
<PItext>Advise the customer to turn off the PC Firewall in order to continue. Has this been done?</PItext>
<PItype>Question</PItype>
<PIfrom>2.2</PIfrom>
<PIto>3.2,3.1</PIto>
<PIc>278</PIc>
<PO>
<POoid>1</POoid>
<POqid>3</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>5</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>3</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>4</POto>
</PO>
</PI>
<PI>
<PIqid>4</PIqid>
<PIpid>450</PIpid>
<PItext>Advise the customer the PC Firewall must be switched off before this process????</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>3.2</PIfrom>
<PIe1>14</PIe1>
<PO />
</PI>
<PI>
<PIqid>5</PIqid>
<PIpid>450</PIpid>
<PItext>Is the customer able to access the internet now?</PItext>
<PItype>Question</PItype>
<PIfrom>3.1,2.1</PIfrom>
<PIto>5.2,5.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>5</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>6</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>5</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>8</POto>
</PO>
</PI>
<PI>
<PIqid>6</PIqid>
<PIpid>450</PIpid>
<PItext>Is the customer having a problem with a specific website?</PItext>
<PItype>Question</PItype>
<PIfrom>5.1</PIfrom>
<PIto>6.2,6.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>6</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>7</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>6</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>8</POto>
</PO>
</PI>
<PI>
<PIqid>7</PIqid>
<PIpid>450</PIpid>
<PItext>1536: CBB1008 - Browser Setup and Daignostics</PItext>
<PItype>SubProcess</PItype>
<PIfrom>6.1</PIfrom>
<PIas>1536-1-0</PIas>
<PO />
</PI>
<PI>
<PIqid>8</PIqid>
<PIpid>450</PIpid>
<PItext>What is the security level on the CPE Management page?</PItext>
<PItype>Question</PItype>
<PIfrom>6.2,5.2</PIfrom>
<PIto>8.4,8.3,8.2,8.1</PIto>
<PIc>279</PIc>
<PO>
<POoid>1</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POtext>Block All</POtext>
<POto>9</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POtext>Standard</POtext>
<POto>11</POto>
</PO>
<PO>
<POoid>3</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POtext>Disabled</POtext>
<POto>12</POto>
</PO>
<PO>
<POoid>4</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POtext>User Defined</POtext>
<POto>12</POto>
</PO>
</PI>
<PI>
<PIqid>9</PIqid>
<PIpid>450</PIpid>
<PItext>Change the security level to Standard. Does this resolve the customers issue?</PItext>
<PItype>Question</PItype>
<PIfrom>8.1</PIfrom>
<PIto>9.2,9.1</PIto>
<PIc>280</PIc>
<PO>
<POoid>1</POoid>
<POqid>9</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>10</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>9</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>11</POto>
</PO>
</PI>
<PI>
<PIqid>10</PIqid>
<PIpid>450</PIpid>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>9.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>122</PIe3>
<PO />
</PI>
<PI>
<PIqid>11</PIqid>
<PIpid>450</PIpid>
<PItext>Change the security level to Disabled. Is the customer able to browse the internet?</PItext>
<PItype>Question</PItype>
<PIfrom>9.2,8.2</PIfrom>
<PIto>11.2,11.1</PIto>
<PIc>281</PIc>
<PO>
<POoid>1</POoid>
<POqid>11</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>12</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>11</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>14</POto>
</PO>
</PI>
<PI>
<PIqid>12</PIqid>
<PIpid>450</PIpid>
<PItext>Change the security level to Standard. Is the customer able to browse the internet now?</PItext>
<PItype>Question</PItype>
<PIfrom>11.1,8.3,8.4</PIfrom>
<PIto>12.2,12.1</PIto>
<PIc>283</PIc>
<PO>
<POoid>1</POoid>
<POqid>12</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>13</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>12</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>14</POto>
</PO>
</PI>
<PI>
<PIqid>13</PIqid>
<PIpid>450</PIpid>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>12.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>123</PIe3>
<PO />
</PI>
<PI>
<PIqid>14</PIqid>
<PIpid>450</PIpid>
<PItext>Ask the customer to perform a master reset. Does this resolve their issue?</PItext>
<PItype>Question</PItype>
<PIfrom>12.2,11.2</PIfrom>
<PIto>14.2,14.1</PIto>
<PIc>282</PIc>
<PO>
<POoid>1</POoid>
<POqid>14</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>16</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>14</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>15</POto>
</PO>
</PI>
<PI>
<PIqid>15</PIqid>
<PIpid>450</PIpid>
<PItext>Faulty CPE</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>14.2</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>124</PIe3>
<PO />
</PI>
<PI>
<PIqid>16</PIqid>
<PIpid>450</PIpid>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>14.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>123</PIe3>
<PO />
</PI>
</P>
Thanks in advance
Edited by: user512743 on Nov 18, 2008 4:46 AM
Maybe you are looking for
-
ICloud on iPad and iPhone GarageBand
Hi, A week ago or so, suddenly my iPad and iPhone Garageband Apps lost conenction with my iCloud and all the Garage Band Projects I had stored there. The App kept saying: connecting with iCloud but never connected. I decided to delete and reinstall t
-
Changing port for http server not working, please help
Hi Gurus I installed standalone hhtp server from db companion cd on AIX 5.3 10gR2. I tested the http server URL http://XXX.XXX.XXX.com:7777/epdev/helloworld after creating a procedure in the db and it works But I need http server to use port 80 and n
-
How to change timezone in B2B to reflect date fields per local time in DB
Hi, I am in EST zone and I could see the data in database with date columns having time in PST. One of my transaction just errorred , I could see from B2B user interface tool error report message date time as 2:14 EST, while when I check the database
-
I have the following message on my iPad: "iPad is disabled connect ti iTunes"
I have the following message on my iPad: "iPad is disabled connect to iTunes" but when I connect to iTunes i have a message asking me to log on my iPad. I cannot slide my iPad to key in the passcode. what should I do?
-
Hi, I want to know the meaning of each staus code in Idoc ... For example... 03 : -Data passed to port OK. Points will be rewarded.