Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic sql building

Status
Not open for further replies.

rehanqadri

Programmer
Jan 31, 2004
40
PK
i want to pass sql clauses through a procedure to an sql statement. i tried my best to do everything but was not able to do so.

example
procedure chk_pk (tablename varchar2) is
.
.
select * from tablename
.
.
.

if anybody can solve my problem i will be very thankful

regards
 
Use a ref cursor. A quick search on the Oracle forums should give you some good examples.
 
I have a table accts in Oracle 8i from which I want to select cust and acctno. Each customer can have more than 1 acctno. So select cust,acctno order by cust,acctno from accts returns
cust acct
1 989
1 990
2 010
2 011
2 012
3 001
4 800
etc.

I can product a comma delimited file from this okay, but I want one that has all acctno's with 1 cust ie

1,989,990
2,010,011,012
3,001
4,800
etc.

Apart from writing a function with a cursor, is there any neat way to do this?



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top