logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Imbricated Queries

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Technical support
View previous topic :: View next topic  
Author Message
amphiprion



Joined: 07 Nov 2006
Posts: 44
Location: Toulouse (France)

PostPosted: Sun Jan 20, 2008 16:11    Post subject: Imbricated Queries Reply with quote

Hello, i'm back to the nwn2/nwnx world Smile and i have a simple question:

is it possible and if yes, how, to execute imbricated queries.
What i need to do is

execute a SELECT who can return multiple rows, iterate on it,
for each row, execute another SELECT returning a single value using a parameter one information of the previous select
the execute on INSERT with collected data.

so it can sumary as:
SELECT
WHILE () {
SELECT
INSERT
}

Thank you
Back to top
View user's profile Send private message
cadderly



Joined: 05 Dec 2007
Posts: 8

PostPosted: Sun Jan 20, 2008 19:17    Post subject: Reply with quote

Dont know since there is no handle for different connections.

But a solutions that should work is:
build a string from the results of the first selection.
Something like "Result|result|Result|......."

After that you take the first Substring and make a select
then the next and so on till no more results come from the string

maybe this function will help:
Code:

// str_pop Searches for first occurence of delimiter in haystack, cuts the string
// at delimiter and returns a struct with the two strings. Delimiter is deleted
//   struct pop_return{
//      int success;
//     string substring;
//      string remainder;
//   };
//   success is 1 if delimiter was found.
// If given delimiter wasnt found success=0 and substring is set to haystack
struct pop_return str_pop(string haystack, string delimiter){
   struct pop_return ret_val;
   int position;
   int length;
   position=FindSubString(haystack,delimiter);
   if (position==-1){
      ret_val.success=0;
      ret_val.substring=haystack;
      ret_val.remainder="";   
   }
   else{
      length=GetStringLength(haystack);
      ret_val.success=1;
      ret_val.substring=GetStringLeft(haystack,position);
      ret_val.remainder=GetStringRight(haystack,length-position-1);
   }   
   return ret_val;
}
Back to top
View user's profile Send private message
amphiprion



Joined: 07 Nov 2006
Posts: 44
Location: Toulouse (France)

PostPosted: Sun Jan 20, 2008 19:19    Post subject: Reply with quote

ok thanks for the pop script Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Technical support All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group