Returning 25th to 40th result of SQL query, do I use a cursor?
I have a complex SQL query that returns ALL the results I am looking for. I would to be able to only return the Nth to Nth result, like just the 50th to 70th record counts (assuming there is a sort by in the statement so it always returns in the same order.)
I thought of using a cursor and checking %ROWCOUNT and only returning the proper rows, but that seemed like it would be inefficient. I could do the same on my front end (PHP 4.0.6) relatively easily, but that would be a really inefficient way to retrieve 20 records from a query with 1000+ records returned.
Thanks, the links were helpful.
Since rowcount ignores my order by clause, I have attempted to find ways to overcome this. I have tried using the rowcount method by recreating my tables as index-orginized with an index on the column that I need to be ordered by. As a result of this, I have come accross two problems.
1. then index does not seem to update the order when I update the column. The column being indexed is a date type. The values added are usually sysdate, so although new elements are added properly, updating old ones does not change their index position.
2. I really need to access the items from most recent to oldest, thus desc. Since I am returning by rowcount, this makes it difficult. The following SQL is the best I can come up with and requires the output to be looped in reverse for display in the correct order:
select postid, subject, to_char(lastmod, 'Month FMDD, YYYY HH')||':'||to_char(lastmod, 'MIam'), name from (select t.postid, t.subject, t.lastmod, r.name, rownum ro from forumtopic t, forumrooms r where t.roomid = '1000668' and t.roomid = r.roomid and r.useraccess = '1') where ro between ((select count(*) from forumtopic subt where subt.roomid = '1000668')-40) and ((select count(*) from forumtopic subt where subt.roomid = '1000668')-25);
Similar Messages
-
How to compare result from sql query with data writen in html input tag?
how to compare result
from sql query with data
writen in html input tag?
I need to compare
user and password in html form
with all user and password in database
how to do this?
or put the resulr from sql query
in array
please help me?Hi dejani
first get the user name and password enter by the user
using
String sUsername=request.getParameter("name of the textfield");
String sPassword=request.getParameter("name of the textfield");
after executeQuery() statement
int exist=0;
while(rs.next())
String sUserId= rs.getString("username");
String sPass_wd= rs.getString("password");
if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
exist=1;
if(exist==1)
out.println("user exist");
else
out.println("not exist"); -
Concatenate results SQL query and CASE use Report Builder Reporting Services
I need to concatenate the results from a SQL query that is using CASE. The query is listed below. I do not need permitsubtype but I need to concatenate the results from the permittype.
I tried deleting the permitsubtype query and it would not run correctly. Please see the query and diagram below. Any help is appreciated.
select PERMIT_NO
,(case when
ISNULL(PERMITTYPE,'') = ''
then 'Unassigned'
else (select LTRIM(RTRIM(PERMITTYPE)))
END) AS PERMITTYPE
,(case when
ISNULL(PERMITSUBTYPE,'') = ''
then 'Unassigned'
else (select LTRIM(RTRIM(PERMITSUBTYPE)))
END) AS PERMITSUBTYPE
,ISSUED
,APPLIED
,STATUS
,SITE_ADDR
,SITE_APN
,SITE_SUBDIVISION
,OWNER_NAME
,CONTRACTOR_NAME
,ISNULL(JOBVALUE,0) AS JOBVALUE
,FEES_CHARGED
,FEES_PAID
,BLDG_SF
from Permit_Main
where ISSUED between @FromDate and @ToDateHi KittyCat101,
As per my understanding, you used case when statement in the query, you do not need to display permitsubtype in the report, but when you tried to delete permitsubtype from the query, it could not run correctly. In order to improve the efficiency of troubleshooting,
I need to ask several questions:
“I tried deleting the permitsubtype query and it would not run correctly.” As we can see, it has no effect to delete permitsubtype from the query you provided, could you please provide complete sql query for the report?
Could you please provide detailed information about the report? I would be appreciated it if you could provide sample data and screenshot of the report.
Please provide some more detailed information of your requirements.
This may be a lot of information to ask for at one time. However, by collecting this information now, it will help us move more quickly toward a solution.
Thanks,
Wendy Fu -
How to pass a result of SQL query to shell script variable
Hi all,
I am trying to pass the result of a simple SQL query that only returns a single row into the shell script variable ( This particular SQL is being executed from inside the same shell script).
I want to use this value of the variable again in the same shell scirpt by opening another SQL plus session.
I just want to have some values before hand so that I dont have to do multiple joins in the actual SQL to process data.Here an example :
SQL> select empno,ename,deptno from emp;
EMPNO ENAME DEPTNO
7369 SMITH 20
7499 ALLEN 30
7521 WARD 30
7566 JONES 20
7654 MARTIN 30
7698 BLAKE 30
7782 CLARK 10
7788 SCOTT 20
7839 KING 10
7844 TURNER 30
7876 ADAMS 20
7900 JAMES 30
7902 FORD 20
7934 MILLER 10
14 rows selected.
SQL> select * from dept;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
$ cat my_shell.sh
### First query #####
ENAME_DEPTNO=`sqlplus -s scott/tiger << EOF
set pages 0
select ename,deptno from emp where empno=$1;
exit
EOF`
ENAME=`echo $ENAME_DEPTNO | awk '{print $1}'`
DEPTNO=`echo $ENAME_DEPTNO | awk '{print $2}'`
echo "Ename = "$ENAME
echo "Dept = "$DEPTNO
### Second query #####
DNAME_LOC=`sqlplus -s scott/tiger << EOF
set pages 0
select dname,loc from dept where deptno=$DEPTNO;
exit
EOF`
DNAME=`echo $DNAME_LOC | awk '{print $1}'`
LOC=`echo $DNAME_LOC | awk '{print $2}'`
echo "Dept Name = "$DNAME
echo "Dept Location = "$LOC
$ ./my_shell.sh 7902
Ename = FORD
Dept = 20
Dept Name = RESEARCH
Dept Location = DALLAS
$ -
How to compare a boolean value returned from a function in a sql query
Hi all
i have a function which return boolean true or false.
mean while i am writing a sql query which should check this function and will return a result set only when it is true. how will i use a function which returns boolean in a sql query..
thanks in advance'
HariI don't think this is possible - i'm not sure. Can you post your function script? The reason why am i asking this is --
satyaki>set serveroutput on
satyaki>
satyaki>
satyaki>
satyaki>create or replace function test_satf(emno in number)
2 return boolean
3 is
4 v_cnt number(5);
5 v_flg boolean;
6 begin
7 select count(*)
8 into v_cnt
9 from emp
10 where empno = emno;
11
12 if v_cnt = 1 then
13 v_flg := TRUE;
14 else
15 v_flg := FALSE;
16 end if;
17
18 return v_flg;
19 exception
20 when others then
21 v_flg := FALSE;
22 return v_flg;
23 end;
24 /
Function created.
satyaki>
satyaki>
satyaki>
satyaki>
satyaki>
satyaki>desc emp;
Name Null? Type
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
satyaki>
satyaki>
satyaki>
satyaki>select count(*) from emp;
COUNT(*)
14
satyaki>
satyaki>select empno,test_satf(empno)
2 from emp;
select empno,test_satf(empno)
ERROR at line 1:
ORA-06552: PL/SQL: Statement ignored
ORA-06553: PLS-382: expression is of wrong type
satyaki>select to_char(test_satf(empno))
2 from emp;
select to_char(test_satf(empno))
ERROR at line 1:
ORA-06552: PL/SQL: Statement ignored
ORA-06553: PLS-382: expression is of wrong type
satyaki>
satyaki>create or replace function test_satf(emno in number)
2 return varchar2
3 is
4 v_cnt number(5);
5 v_flg varchar2(10);
6 begin
7 select count(*)
8 into v_cnt
9 from emp
10 where empno = emno;
11
12 if v_cnt = 1 then
13 v_flg := 'TRUE';
14 else
15 v_flg := 'FALSE';
16 end if;
17
18 return v_flg;
19 exception
20 when others then
21 v_flg := 'FALSE';
22 return v_flg;
23 end;
24 /
Function created.
satyaki>
satyaki>
satyaki>select test_satf(empno)
2 from emp;
TEST_SATF(EMPNO)
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TEST_SATF(EMPNO)
TRUE
TRUE
TRUE
14 rows selected.Or, may be i'm missing something.
Regards.
Satyaki De. -
Creating JTree with results from SQL Query
I have the following source in SQLJ:
String temp=null;
iter1 it1;
iter2 it2;
#sql it1={select id,fdn,level from groups connect by prior fdn=parent_fdn start with fdn='/' };
while(it1.next())
System.out.println(it1.id()); // Display Parent
temp=it1.fdn();
#sql it2= {select clli from nes where parent_fdn=:temp order by clli };
while(it2.next())
System.out.println(it2.clli());//Display Child of above Parent if any
My problem is to construct a Tree GUI using JTree from the above
code with the same hierarchy of parent-child relationship.
I have tried every possible solution using Vectors,Hashtables,String Arrays etc but have not come up with a successful solution so far
IF ANYONE HAS A SOLUTION PLEASE HELP ME WITH AN EXAMPLE.
Thank You
Sharathsharathkv,
Your issue seems to be in figuring out an algorithm to convert row-based SQL resultsets to a hierarchical data structure suitable for display in a tree.
Run the jython (www.jython.org) app below: it simulates doing just that. jython is indentation-sensitive, so you'll need to exercise care when copying. If copy-paste to a text editor doesn't work, copy-paste to a HTML-aware editor (even Outlook Express, if on Windows), then copy from there and paste in a text editor.
--A
This is a jython (www.jython.org) app that illustrates
converting row-based data (eg. a SQL resultset) to a custom
hierarchical data structure, and displaying it in a JTree.
from javax.swing import *
from javax.swing.tree import *
import java
def getSQLRows():
Simulates a SQL resultset.
Columns fdn and parent-fdn indicate parent/child relationships.
rows = [
# id, fdn, parent-fdn, level
[1, '/', None, 1]
, [2, '/fruits', '/', 2]
, [3, '/colors', '/', 2]
, [4, '/sports', '/', 2]
, [5, '/fruits/apples', '/fruits', 3]
, [6, '/fruits/oranges', '/fruits', 3]
, [7, '/colors/red', '/colors', 3]
, [8, '/colors/blue', '/colors', 3]
, [9, '/sports/petanc', '/sports', 3]
, [10, '/sports/rugby', '/sports', 3]
return rows
def convertRowsToHierarchy(rows):
Converts row-based results to hierarchical structure.
Uses known parent/child relations present in rows.
root = None
for row in rows:
fdn, parentfdn = row[1], row[2]
node = SQLTreeNode(fdn, parentfdn)
if root:
root.addEx(node)
else:
root = node
return root
class SQLTreeNode(java.lang.Object):
'''Custom tree node; displayed in JTree'''
def __init__(self, fdn, parentfdn):
self.fdn = fdn
self.parentfdn = parentfdn
self.nodes = []
def add(self, node):
'''Adds node as immediate child'''
self.nodes.append(node)
def addEx(self, node):
'''Adds-with-search. NOTE: naive implementation'''
if self.fdn == node.parentfdn:
self.add(node)
else:
for child in self.nodes:
child.addEx(node)
def toString(self):
return self.fdn
def dump(self):
'''Debug routine to dump hierarchy'''
print 'fdn=%s, parentfdn=%s' % (self.fdn, self.parentfdn)
for node in self.nodes:
node.dump()
class SQLTreeModelAdapter(TreeModel):
'''Tree model adapter: adapts custom data structure to TreeModel'''
def __init__(self, root):
self.__root = root
def getChild(self, parent, index):
return parent.nodes[index]
def getChildCount(self, parent) :
return len(parent.nodes)
def getIndexOfChild(self, parent, child):
return parent.nodes.index(child)
def getRoot(self) :
return self.__root
def isLeaf(self, node):
return len(node.nodes) == 0
def addTreeModelListener(self, l):
pass
def removeTreeModelListener(self, l):
pass
def valueForPathChanged(self, path, newValue):
pass
class SQLTreeDemo(JFrame):
Tree demo UI
Displays a tree displaying [hierarchical] results
of a BOM-type SQL query
def __init__(self):
# Get matrix simulating SQL resultset
rows = getSQLRows()
# Convert to custom hierarchical data structure
root = convertRowsToHierarchy(rows)
model = SQLTreeModelAdapter(root)
tree = JTree(model)
sp = JScrollPane(tree)
self.contentPane.add(sp)
self.size = 200, 300
if __name__ == '__main__':
s = SQLTreeDemo()
s.visible = 1 -
Returning composite datatype(record) to an SQL Query
I have a function called get_customer_address() that takes customer id and returns the customer address as a record type.
TYPE cust_address_type IS RECORD
(address1 VARCHAR2(25),
address2 VARCHAR2(25),
city VARCHAR2(25),
zipcode VARCHAR(10),
STATE VARCHAR(10));
cust_address cust_address_type;
My function is returning cust_address.
I want to modify below exising query and call this function from the query to get address.
select cust_id, address1, address2, city, zipcode from customer_table;
Instead of using address1, address2, city, zipcode if I want to the record type variable cust_id returned from the function, can I use it in my query? How do I modify the above query to call the function get_customer_address and get the same values as in the above query?To add to Elic's comment - PL/SQL record structures can be defined as SQL objects, as long as SQL data types are used and not non-supported PL/SQL types like boolean.
E.g. create or replace type TCustAddress is object
( address1 VARCHAR2(25),
address2 VARCHAR2(25),
city VARCHAR2(25),
zipcode VARCHAR2(10),
state VARCHAR2(10)
);This provides a lot more flexibility than using PL/SQL record types. This is essentially an object class definition - and you can add constructors and methods to it.
It works seamlessly across both SQL and PL/SQL. -
Need to return CLOB as String type from SQL query
I have a table that contains a CLOB column, which should be accessible to a JDBC client (JReports) that does not understand how to extract CLOB from a result set.
A possible workaround would be to translate the CLOB type into a normal string on the database side as part of the SQL query (or a view), so that the client can handle it. For that to work, we would need a type conversion within the query itself.
Rather then
SELECT clob_column FROM my_table
we would need something like
SELECT to_char(clob_column) FROM my table
Unfortunately to_char does not work, but possibly there are other ways to achieve it.
nullHi Christo
Works fine. Just had to change the parameter order:
DBMS_LOB.substr(clob_column,4000,1) converts the CLOB to a VARCHAR
Thanks a lot,
Thomas
null -
Kodo 3.4.1: how to limit # of sql query params when using collection param
Hi,
We have a problem when using Kodo 3.4.1 against SQL Server 2005, when we execute query:
Query query = pm.newQuery( extent, "IdList.contains( this )" );
query.declareParameters( "Collection IdList" );
query.declareImports( "import java.util.Collection;" );
return (List) query.execute( list );
We got:
com.microsoft.sqlserver.jdbc.SQLServerException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Too many parameters were provided in this RPC request. The maximum is 2100.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:354)
at com.solarmetric.jdbc.PoolConnection$PoolPreparedStatement.executeQuery(PoolConnection.java:341)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:352)
at com.solarmetric.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:1106)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:352)
at kodo.jdbc.runtime.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1730)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:339)
at kodo.jdbc.sql.Select.execute(Select.java:1581)
at kodo.jdbc.sql.Select.execute(Select.java:1533)
at kodo.jdbc.runtime.SelectResultObjectProvider.open(SelectResultObjectProvider.java:102)
at com.solarmetric.rop.EagerResultList.<init>(EagerResultList.java:22)
at kodo.query.AbstractQuery.execute(AbstractQuery.java:1081)
at kodo.query.AbstractQuery.executeWithArray(AbstractQuery.java:836)
at kodo.query.AbstractQuery.execute(AbstractQuery.java:799)
It seems that there're too many ids in the list, and Kodo didn't limit the # of sql parameters when craft the sql query. Is there a way to ask Kodo to use multiple queries with smaller # of sql parameters instead of using one big sql query?
ThanksHi,
Sadly, there is no way to do that in Kodo currently. The closest is the inClauseLimit DBDictionary setting, but that setting just breaks things up into multiple IN statements put together with an OR clause. In your case, it looks like the network transport, not the SQL parser, is complaining about size limits.
You could force the query to run in-memory, but that would probably be prohibitively slow, unless the data set that you're querying against is relatively small.
-Patrick -
Can we use Result from another query in Webi using Bex uery universe?
Hi,
Can we use Result from another query filter option in Webi to create a report using a Bex Query universe?
I need to create a report using two universes, one is Bex Query Universe and the other is Orcle universe. I have two queries, one is using Oracle universe; the other using Bex Query universe. I need to pass the Oracle data from the Oracle query to the Bex Query query to get the matched data from SAP Bex query.
I used Result from another query in the query filter panel for the query using Bex query universe. But I got an error saying that 'A filter contains a wrong value. you cannot run this query. (Error: WIS 00007). The data used in the filter on both sides are the same. they are char.
I have tested by using two queries from the same Bex query universe to see if the Result from another query filter option works. And I got the same error.
Has anyone run into the same issue and if this is possible and what should be the solution?
Thanks in advance!
Edited by: BO_Haiyan on Oct 6, 2010 3:47 PMIn that situation:
Create two queries : Oracle and BW query.
@ Report:
As you have to see result set from both the Dataproviders, correct? To achieve thise one must have common dimension objects to merge them at report and use Objects those are coming from both queries to use them in single Table/Report.
Unless you don't use Merge Dimensions, you don't get a chane to use both queries objects in single Table/Report. (It will give tooltip saying: You can't drop here -- Incompatable Objects)
In case, if you don't have common dimensions, change object definitions to Detail objects, for those required.
Hope it helps you.
Thank You!! -
Sql query slow while using poc *C, OCI
Sql query is taking long time while using fetching records from RAC using Pro *C, OCI. Same query working fine while using JDBC connection.what could be the issue.Please help
Thanks,
SamPro*C is not part of Oracle Solaris Studio (formerly Sun Studio). Studio has no special support for database programming. You are more likely to get a helpful answer in a database programming forum. Start here:
https://forums.oracle.com/forums/category.jspa?categoryID=18 -
Sql query not executed using recordset
Hi All,
I am trying to first format and then execute SQL query statement using recordset object with DI API. the issue is with vb.net's string formatting. I want to use 'USE [DB_Name]' statement in SQL and then 'Alter Procedure ..' statement. as this has to be the first statement in sql , I am using 'GO' in between and seperating each sentence with following syntax.
Dim AltProc as string
AltProc = " USE [DB_name]" & Environment.NewLine
AltProc = AltProc & " GO " & Environment.NewLine
AltProc = AltProc & " ALTER proc [proc_name] " & Environment.NewLine
'---------------------and so on
Orec.DoQuery(AltProc)
this formatting does not recognize new line and gives 'incorrect syntax near 'Go'' error. strange thing is, if I take this query in SQL, it runs perfectly and I can see it getting formatted with each new line created. I tried even VbcrLf but it didnt work.
any one has any idea?
thanks in advance,
BinitaHI Binita
The reason:
GO is the "command" delimiter of MS Query Editor.
It is not working with RecordSet Object.
In MS SQL 2008 version you can define the schema before the procedure name but in SQL server 2000/2005 it is not possible.
IN SQL 2008 use the Fully Qualified name instead of GO:
Dim AltProc as string
AltProc = " ALTER proc [DB_name].[dbo].[proc_name] " + vbcrlf
'---------------------and so on
Orec.DoQuery(AltProc)
it is not working on MS SQL 2008 i have tried.
'CREATE/ALTER PROCEDURE' does not allow specifying the database name as a prefix to the object name.'
Regards,
J.
Edited by: Janos Nagy on Jun 22, 2009 2:55 PM -
How to retrieve generated sql query from interface using groovy
Hi All,
I'm new to odi and i need the generated sql query code from the interface using groovy.Hi All,
I'm new to odi and i need the generated sql query code from the interface using groovy. -
Different Results from SQL-Query in Oracle 10.2 and Oracle 11.2
Look at the following example:
CREATE TABLE GZP_PLAN (GZP_ID
NUMBER(9) NOT NULL, PARENT_GZP_ID NUMBER(9),
CONSTRAINT GZP_PLAN_PK1 PRIMARY KEY(GZP_ID)
USING INDEX
TABLESPACE USERS
TABLESPACE USERS;
insert into GZP_PLAN values(1,NULL);
CREATE TABLE GZP_WB (OBJECTID NUMBER
NOT NULL, GZP_ID NUMBER(10),
CONSTRAINT GZP_WB_PK1_1 PRIMARY KEY(OBJECTID)
USING INDEX
TABLESPACE USERS
TABLESPACE USERS;
insert into GZP_WB values(1,1);
CREATE OR REPLACE VIEW VW_GZP (GZP_ID1) AS
SELECT xxx.gzp_id
FROM gzp_plan xxx
WHERE gzp_id IN (
SELECT MAX (z.gzp_id) zzz
FROM gzp_plan z
START WITH z.gzp_id = xxx.gzp_id
CONNECT BY PRIOR gzp_id = parent_gzp_id);
-- query
select a.* from GZP_WB a where gzp_id in (select gzp_id1 from vw_gzp);
Result in Oracle 10.2. (Windows Server 2003 32-bit, Oracle 10.2.0.2 or Oracle 10.2.0.5, Enterprise Edition)
OBJECTID GZP_ID
*1 1*
Result in Oracle 11.2 (Windows Server 2008 64-bit, Oralcle 11.2.0.2, Enterprise Edition or Standard Edition One)
no rows selected
The result of the following queries are identical in Oracle 10.2 and 11.2
SQL> select * from GZP_WB where to_char(gzp_id) in
2 (select to_char(gzp_id1) from vw_gzp);
OBJECTID GZP_ID
1 1
SQL>
SQL> select a.* from GZP_WB a, vw_gzp b where a.gzp_id=b.gzp_id1;
OBJECTID GZP_ID
1 1The solution is Oracle 11.2.0.3 - patchset released 11th November.
-
Get Comma separated result from SQL Query
Hey Everyone
I have a requirement where i need to get comma separated result of names because there is one to many relationship i.e for every protocol there are mutiple people associated to it , and i created PL/SQL function for that and everything was fine and when it is in production multiple number of cursors were opened because of the logic and leading to RAC fail over and for that we were manually clearing the cursors every weekend and i am looking to create a Materialized view for this logic but i was unable to code the logic using Connect by clause
Result is like and i want comma separated names for every protocol
P06065 TESTER13 TESTER13
P02095 PATRICIA CARMELITANO
P02095 ANNE MUIR
P02095 ROBERT HARLOW
P02095 JANICE ALBERT
P02095 Jacqueline van Dalen
P02095 GUENTER HENNIG DR.
P05209 Olga Xenaki
P05553 Birgit Limbach-Angele
P05553 Anja Schulz Dr.
P05553 CHRISTA HAGENBUCHER
here is the function which i wrote, i need to get the same logic through SQL Statement .. thanks for your help
cursor c_GSCR is
select T565804.FST_NAME||' '||T565804.LAST_NAME
from
S_PT_POS_HST_LS T544105 /* S_PT_POS_HST_LS_Protocol_Team */ ,
S_CONTACT T565804 /* S_CONTACT_Protocol_Team */,
S_CL_PTCL_LS T541903 /* S_CL_PTCL_LS_Protocol */
where ( T541903.ROW_ID = T544105.CL_PTCL_ID and
T544105.POSTN_ID = T565804.PR_HELD_POSTN_ID and
T544105.ROLE_CD = 'Lead Project Manager' AND
T541903.ROW_ID = v_PTCL_ID and
T541903.PAR_PTCL_ID is null and T544105.END_DT is null );
BEGIN
l_row_num := 0;
l_role := '';
l_role_list := '';
v_PTCL_ID := PTCL_ID;
OPEN C_GSCR;
if C_GSCR%isopen THEN
LOOP
FETCH C_GSCR INTO l_role;
exit when C_GSCR%notfound;
IF l_role_list IS NULL THEN
l_role_list:=l_role;
ELSE
l_role_list:=l_role_list||', '||l_role;
END IF;
END LOOP;
CLOSE C_GSCR;
end if;
~SrixHi,
Srix wrote:
Thanks for the Info .. My database in 10g R 2 i started using COLLECT Function
select T541903.PTCL_NUM ,
CAST(COLLECT(T565804.FST_NAME||' '||T565804.LAST_NAME) AS varchar2_ntt) , 7) AS LPM_NAME
from
S_PT_POS_HST_LS T544105 /* S_PT_POS_HST_LS_Protocol_Team */ ,
S_CONTACT T565804 /* S_CONTACT_Protocol_Team */,
S_CL_PTCL_LS T541903 /* S_CL_PTCL_LS_Protocol */
where T541903.ROW_ID = T544105.CL_PTCL_ID and
T544105.POSTN_ID = T565804.PR_HELD_POSTN_ID and
T544105.ROLE_CD = 'Lead Project Manager' AND
T541903.PAR_PTCL_ID is null and T544105.END_DT is null
GROUP BY T541903.PTCL_NUM
The result i like ...Do you mean "The result *is* like ..."?
Or do you mean "The result I [would] like [is] ..."?
The code above has unblanaced parentheses. If you are getting anything other than an error message, then I don't believe you are really running what you posted.
Whenever you have a problem, post a complete test script that people can use to recreate the problem and test their ideas.
Please do that. Post CREATE TABLE and INSERT statements to crate the sample data, the code you used to create the carachr2_ntt type and the function, and your best attempt at a query (formatted). Simplify as much as possible. For example, do you really need 3 tables to illustrate the problem? For purposes of asking a question on this forum, can't you pretend you have just one table, with 2 columns?
I suspect the problem has to do with the user-defined type and function, which you didn't post. I can't even see how you called the function in your query. Without the information I mentioned above, there's not much I can do to help you.
Maybe you are looking for
-
Restart a step in a Job Chain when complete
Hi, I want to restart a step when complete but I don't see where I can choose how many times I want to restart. I see the Final Status Handlers : restart step on complete, but this restart the step unlimitedly. Could someone help, please ? Re. Clemen
-
Ever since the apple 8.1 update, my phone has been on extended LTE service. My data seems to be going really fast with not much usage. I've done some reading up on this and I'm not the only person having this problem. Any kind of help would be apprec
-
Hello All, When a group is not being displayed, i am using the following code in the template and added the Section Break before the if condition as well <?if@section:not(//G_CUSTOMER)?>No Data Found<?endif?> SampleData <?xml version="1.0" encoding="
-
No audio/visual on TV show downloaded from iTunes app on iPod touch
I downloaded a $3.99 Avatar TV episode from the iTunes app on my 2nd gen iPod touch, and it seemed to go smoothly until I tried playing the episode. It appears to be playing but all I see is black and there is no audio. I restarted my iPod twice; sti
-
HT1491 why can't i download any songs to my iphone 4s?
I have just had my iphone repalced and now i cannot download or sync my songs to it. i have updated to ios 1.6.1? even purchases from icloud will not download.