Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 how to write dynamic sql

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-17 : 08:05:33
pavan kumar writes "how to write dynamic sql for below query ??

Here i have 9! combinations for this query...mean, i have 9! different
combinations as input

for all possible 9! inputs, query should work...Plz help me out...

IF PR20100-TT-NO > ZEROES AND
PR20100-PAY-BANK > ZEROES AND
PR20100-FROM-DATE > ZEROES AND
PR20100-TO-DATE > ZEROES AND
PR20100-PAY-BRANCH > ZEROES AND
PR20100-FROM-AMOUNT > ZEROES AND
PR20100-TO-AMOUNT > ZEROES AND
PR20100-ISSUE-BANK > ZEROES AND
PR20100-STATUS > ZEROES

EXEC SQL DECLARE GETTTRF CURSOR FOR
SELECT
ISSUE_DATE,
TT_NO,
TT_AMT,
JRNL_NO,
ISSUE_BRCH_NO,
PAR_FLAG,
PAID_DATE,
PAY_BRN_NO,
TT_STAT
FROM TTRF
WHERE (INST_NO = :WA-PK-INST-NO AND
ISSUE_BRCH_NO = :WA-PK-ISSUE-BRN-NO AND
TT_NO = :WA-PK-TT-NO AND
PAY_BANK_CODE = :WA-PK-PAY-BANK-CODE AND
ISSUE_DATE >= :WA-PK-ISSUE-FROM-DATE AND
ISSUE_DATE <= :WA-PK-ISSUE-TO-DATE AND
PAY_BRN_NO = :WA-PK-PAY-BRN-NO AND
TT_AMT >= :WA-PK-FROM-AMOUNT AND
TT_AMT <= :WA-PK-TO-AMOUNT AND
TT_STAT = :WA-PK-STATUS
)
ORDER BY TT_NO,
JRNL_NO,
JRNL_DATE
END-EXEC
END-IF

Thanks and regards
Pavan kumar.k"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-08-17 : 08:06:06
SQL Team is a Microsoft SQL Server site, Oracle questions are better posted here:

http://dbforums.com/
Go to Top of Page
   

- Advertisement -