View previous topic :: View next topic |
Author |
Message |
amphiprion
Joined: 07 Nov 2006 Posts: 44 Location: Toulouse (France)
|
Posted: Sun Jan 20, 2008 16:11 Post subject: Imbricated Queries |
|
|
Hello, i'm back to the nwn2/nwnx world 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 |
|
|
cadderly
Joined: 05 Dec 2007 Posts: 8
|
Posted: Sun Jan 20, 2008 19:17 Post subject: |
|
|
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 |
|
|
amphiprion
Joined: 07 Nov 2006 Posts: 44 Location: Toulouse (France)
|
Posted: Sun Jan 20, 2008 19:19 Post subject: |
|
|
ok thanks for the pop script |
|
Back to top |
|
|
|