276: -- 1. Will search for the p_search_string variable in the set of strings
277: -- which compose a workbook SQL statement and are stored in the
278: -- AMS_DISCOVERER_SQL table.
279:
280: -- 2. p_found will return FND_API.G_TRUE if the string has been found.
281:
282: -- 3. p_found_in_str returns the number of the sql string in which the search
283: -- string was found. each SQL string is 2000 characters in length.
284:
338:
339: --the length of the sub string.
340: l_substr_len number := 0;
341:
342: --set to FND_API.G_TRUE when the first character of the searched for string
343: --has been found.
344: l_first_char_found varchar2(1);
345:
346:
374: l_search_str_len := length(p_search_string);
375: l_search_sub_str := substr(p_search_string,2,l_search_str_len);
376:
377:
378: x_found := FND_API.G_FALSE;
379:
380: --getting the total number of strings that compose the sql statement.
381: Select Count(*)
382: into l_str_count
384: Where Workbook_name = p_workbook_name
385: And Worksheet_name = p_worksheet_name;
386:
387: if (l_str_count = 0) then
388: x_found := FND_API.G_FALSE;
389: --dbms_output.put_line('search sql str : could not find workbook SQL = '||to_char(l_str_count));
390: RETURN;
391: end if;
392:
429: if (l_total_str_len >= p_max_search_len) then
430:
431: --dbms_output.put_line('search sql str : max num of characters have been read');
432:
433: l_last_fetch := FND_API.G_TRUE;
434: l_tmp_str := substr(l_sql_table(l_iterator + 1),1,p_max_search_len - 1);
435:
436: --dbms_output.put_line('search sql str : l_tmp_str ='||l_tmp_str);
437:
442:
443: --If First character of search string has been found in the previous string
444: --but the remainder of previous string is too short to contain the rest of
445: --the search string.
446: if (l_first_char_found = FND_API.G_TRUE) then
447: --getting the substring length.
448: l_substr_len := length(l_substr);
449: --dbms_output.put_line('search sql str : overflow detected, length of sub string = '||to_char(l_substr_len));
450:
456:
457: if ( l_substr||substr(l_sql_table(l_iterator + 1),1,((l_search_str_len-1)-nvl(l_substr_len,0)) ) = l_search_sub_str) then
458: --dbms_output.put_line('search sql str : sucessful match after overflow');
459:
460: x_found := FND_API.G_TRUE;
461: x_overflow := (l_search_str_len-1)- l_substr_len;
462:
463: --dbms_output.put_line('search sql str : overflow length = '||to_char(x_overflow));
464:
464:
465: exit l_fetch_string;
466: else
467:
468: x_found := FND_API.G_FALSE;
469: --calculating the new search position.
470: l_str_pos := l_str_pos + 1;
471:
472: --dbms_output.put_line('search sql str : unsucessful match after overflow, new string position ='||to_char(l_str_pos ));
502: --setting current position in sql string.
503: l_str_pos := l_first_char_pos;
504:
505: --indicating that the first character of the searched for string has been found.
506: l_first_char_found := FND_API.G_TRUE;
507:
508:
509: if (l_str_count = 1) then
510: x_found_in_str := l_iterator;
517: x_position := l_first_char_pos;
518:
519: if (l_search_str_len = 1 ) then
520: --dbms_output.put_line('search sql str : Match has been found');
521: x_found := FND_API.G_TRUE;
522: exit l_search_string;
523: --there are enough characters left in the current string to find a match.
524: elsif ( (l_str_len - (l_str_pos + 1)) >= (l_search_str_len - 1) )then
525:
532: --match has been found.
533: if ( l_substr = l_search_sub_str ) then
534:
535: --dbms_output.put_line('search sql str : Match has been found');
536: x_found := FND_API.G_TRUE;
537: exit l_search_string;
538:
539: --no match found, update string search position.
540: else
538:
539: --no match found, update string search position.
540: else
541: --dbms_output.put_line('search sql str : Match has not been found');
542: x_found := FND_API.G_FALSE;
543: l_str_pos := l_str_pos + 1;
544: end if;
545:
546: --not enough characters remaining in current sql string to perform a match.
560: --l_first_char has not been been found in the current string.
561:
562:
563: --indicating that the first character of the searched for string has not been found.
564: l_first_char_found := FND_API.G_FALSE;
565:
566: --indicating that the search string has not been found;
567: x_found := FND_API.G_FALSE;
568:
563: --indicating that the first character of the searched for string has not been found.
564: l_first_char_found := FND_API.G_FALSE;
565:
566: --indicating that the search string has not been found;
567: x_found := FND_API.G_FALSE;
568:
569: --exit the search string loop and fetch another sql string.
570: exit l_search_string;
571: end if;
575: --dbms_output.put_line('search sql str : exiting search string loop');
576:
577: --the string has been found , no need to fetch any more sql strings.
578: --OR the max. number of characters have been read.
579: If (x_found = FND_API.G_TRUE or l_last_fetch = FND_API.G_TRUE ) then
580: exit l_fetch_string;
581: end If;
582:
583: End Loop l_fetch_string;--Fetching the SQL strings.
675: x_position => l_position,
676: x_overflow => l_overflow
677: );
678:
679: EXIT WHEN c_master_types%NOTFOUND OR l_found = FND_API.G_TRUE;
680: END LOOP;
681: CLOSE c_master_types;
682:
683: x_source_type_code := l_source_type_code;