Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Function strings to select data from primary database

2 posts in General Discussion Last posting was on 2011-08-15 18:30:17.0Z
mf Posted on 2011-08-10 19:30:46.0Z
Sender: 8ad.4e42d9e9.1804289383@sybase.com
From: MF
Newsgroups: sybase.public.rep-server
Subject: Function strings to select data from primary database
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4e42dc66.971.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 10 Aug 2011 12:30:46 -0700
X-Trace: forums-1-dub 1313004646 10.22.241.41 (10 Aug 2011 12:30:46 -0700)
X-Original-Trace: 10 Aug 2011 12:30:46 -0700, 10.22.241.41
Lines: 52
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.rep-server:9027
Article PK: 870196

Hi,

I need to select data from primary database in a replicated
system with Replication server 12.5 between to databases
located in the same ASE 12.5, but the queries for selection
are

Query 1:
SELECT * FROM TABLE
WHERE FIELD1 IN (select A.FIELD2 from TABLE2 A, TABLE3 B
where A.FIELD3 = 'A'
AND (A.FIELD2 = B.FIELD2 OR
A.FIELD2 = B.FIELD3)
AND B.FIELD4 = 'A')

Query 2:
select A.* from TABLE A, TABLE2 B
where A.FIELD = 'A'
AND (A.FIELD = B.FIELD OR
A.FIELD = B.FIELD2)
AND B.FIELD3 = 'A'

Query 3:
SELECT * FROM TABLE where FIELD in
(select FIELD2 from TABLE2 where FIELD3='A' and FIELD in
(select FIELD from TABLE3 where FIELD4='A'))
union all
SELECT * FROM TABLE where FIELD in
(select FIELD3 from TABLE2 where FIELD4='A' and FIELD in
(select FIELD from TABLE3 where FIELD4='A'))



where TABLE is the table to replicate and TABLE2 and TABLE3
are tables in the primary database.

How can I do it? I think I cannot include this kind of query
in the where clause of the subscription, but maybe
it's possible to create a rs_select function string to
filter data from primary database. All tables in the select
statement are created in the primary database.
Maybe is possible to implement this functionality in a
better way or it's not possible to do it. In this case, I
can try
to select data from replicated database or to replicate all
data and select the rows later, or create views in the
replicated
system.

Could you please help me?

Thank you


Manish Negandhi [TeamSybase] Posted on 2011-08-15 18:30:17.0Z
From: "Manish Negandhi [TeamSybase]" <nospam_negandhi.manish@gmail.com>
Newsgroups: sybase.public.rep-server
References: <4e42dc66.971.1681692777@sybase.com>
Subject: Re: Function strings to select data from primary database
Lines: 71
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3664
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3664
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4e4965b9@forums-1-dub>
Date: 15 Aug 2011 11:30:17 -0700
X-Trace: forums-1-dub 1313433017 10.22.241.152 (15 Aug 2011 11:30:17 -0700)
X-Original-Trace: 15 Aug 2011 11:30:17 -0700, vip152.sybase.com
X-Authenticated-User: teamsybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.rep-server:9030
Article PK: 870197


<MF> wrote in message news:4e42dc66.971.1681692777@sybase.com...
> Hi,
>
> I need to select data from primary database in a replicated
> system with Replication server 12.5 between to databases
> located in the same ASE 12.5, but the queries for selection
> are
>
> Query 1:
> SELECT * FROM TABLE
> WHERE FIELD1 IN (select A.FIELD2 from TABLE2 A, TABLE3 B
> where A.FIELD3 = 'A'
> AND (A.FIELD2 = B.FIELD2 OR
> A.FIELD2 = B.FIELD3)
> AND B.FIELD4 = 'A')
>
> Query 2:
> select A.* from TABLE A, TABLE2 B
> where A.FIELD = 'A'
> AND (A.FIELD = B.FIELD OR
> A.FIELD = B.FIELD2)
> AND B.FIELD3 = 'A'
>
> Query 3:
> SELECT * FROM TABLE where FIELD in
> (select FIELD2 from TABLE2 where FIELD3='A' and FIELD in
> (select FIELD from TABLE3 where FIELD4='A'))
> union all
> SELECT * FROM TABLE where FIELD in
> (select FIELD3 from TABLE2 where FIELD4='A' and FIELD in
> (select FIELD from TABLE3 where FIELD4='A'))
>
>
>
> where TABLE is the table to replicate and TABLE2 and TABLE3
> are tables in the primary database.
>
> How can I do it? I think I cannot include this kind of query
> in the where clause of the subscription, but maybe
> it's possible to create a rs_select function string to
> filter data from primary database. All tables in the select
> statement are created in the primary database.
> Maybe is possible to implement this functionality in a
> better way or it's not possible to do it. In this case, I
> can try
> to select data from replicated database or to replicate all
> data and select the rows later, or create views in the
> replicated
> system.
>
> Could you please help me?
>
> Thank you

What is that you are trying to do exactly ? Do you just want to select data
based on some tables in primary and some in replicate ?
rs_select function string has replication definition scope , you can see
that this function is created with your repdef, you can not select data from
primary using this
Repserver will only get that data if RepAgent will find something in the
trasacton log for that table. You can either replicate all these tables and
select data from replicate or if all these tables are present in primary
then use function replication to execute stored proc at primary as well as
replicate or may be use CIS to query data from remote site

-HTH
Manish Negandhi
[TeamSybase]