SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 18th, 2004, 05:13 AM
Gute Gute is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 Gute User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Stored Procedure Question

Hi all. I am currently trying to create (IMO) a pretty advanced stored procedure.

The table I start to fetch looks like this (reduced)

Page - Type - Sql
simple DropDown select id, text from ....
simple Text (NULL)

so I start to call the SP with the page name 'simple' and when everything is fetched I want too loop the resultset
and replace every SQL that is not NULL with a string separated by commas (, or # or whatever =)). The string should
be fetched using the SQL in the SQL to be replaced.

So in pseudocode what I want to do is

stored procedure getPageLayout(string aPage)
{
select * from dynamicTable where page = aPage;
for each row
{
if (sql != NULL)
{
set this.sql = call executeSQL(sql)
}
}
return reslutSet;
}

Is this possible?

Reply With Quote
  #2  
Old May 18th, 2004, 05:19 AM
Gute Gute is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 Gute User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

I can add that my procedure currently looks like this

create procedure
getDynTable(aPage char(15))

result(lPage CHAR(15), lType char(20), lSQL VARCHAR(255))

begin
select
page as lPage,
type as lType,
sql as lSql,
from
dyntable where page = aPage
end;

But does anyone have any ideas of how to loop the resultset and replace the SQL-tags != NULL with that querys result?

Reply With Quote
  #3  
Old May 18th, 2004, 09:47 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
Declare a cursor, open it, loop through it, replace what needs to be replaced, close the cursor, deallocate the cursor.

If you need help with cursors, check out MSDN or Sql Team.

Reply With Quote
  #4  
Old May 18th, 2004, 10:24 AM
Gute Gute is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 Gute User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Great thanks, will try that out tomorrow.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Stored Procedure Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT