| 1 | # | ||
| 2 | # Copyright (c) 2005, Presicient Corp., USA | ||
| 3 | # | ||
| 4 | # Permission is granted to use this software according to the terms of the | ||
| 5 | # Artistic License, as specified in the Perl README file, | ||
| 6 | # with the exception that commercial redistribution, either | ||
| 7 | # electronic or via physical media, as either a standalone package, | ||
| 8 | # or incorporated into a third party product, requires prior | ||
| 9 | # written approval of the author. | ||
| 10 | # | ||
| 11 | # This software is distributed in the hope that it will be useful, | ||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 14 | # | ||
| 15 | # Presicient Corp. reserves the right to provide support for this software | ||
| 16 | # to individual sites under a separate (possibly fee-based) | ||
| 17 | # agreement. | ||
| 18 | # | ||
| 19 | # History: | ||
| 20 | # | ||
| 21 | # 2005-Jan-27 D. Arnold | ||
| 22 | # Coded. | ||
| 23 | # | ||
| 24 | package SQL::Amazon::Functions; | ||
| 25 | use strict; | ||
| 26 | |||
| 27 | our $VERSION = '0.10'; | ||
| 28 | sub SQL_FUNCTION_AMZN_MATCH_ANY { return undef; } | ||
| 29 | |||
| 30 | sub SQL_FUNCTION_AMZN_MATCH_ALL { return undef; } | ||
| 31 | |||
| 32 | sub SQL_FUNCTION_AMZN_MATCH_TEXT { return undef; } | ||
| 33 | |||
| 34 | sub SQL_FUNCTION_AMZN_POWER_SEARCH { return undef; } | ||
| 35 | sub SQL_FUNCTION_AMZN_IN_ANY { | ||
| 36 | my ($obj, $sth, $rowhash, $expr, @list) = @_; | ||
| 37 | return join(',', @list) | ||
| 38 | unless (defined($rowhash) && | ||
| 39 | (scalar keys %$rowhash)); | ||
| 40 | return undef | ||
| 41 | unless defined($expr); | ||
| 42 | |||
| 43 | foreach (@list) { | ||
| 44 | next unless defined($_); | ||
| 45 | return 1 | ||
| 46 | if ((is_number($expr) && is_number($_) && ($expr == $_)) || | ||
| 47 | ($expr eq $_)); | ||
| 48 | } | ||
| 49 | return undef; | ||
| 50 | } | ||
| 51 | |||
| 52 | sub SQL_FUNCTION_AMZN_NOT_IN_ANY { | ||
| 53 | my ($obj, $sth, $rowhash, $expr, @list) = @_; | ||
| 54 | return 1 unless defined($expr); | ||
| 55 | |||
| 56 | foreach (@list) { | ||
| 57 | next unless defined($_); | ||
| 58 | return undef | ||
| 59 | if ((is_number($expr) && is_number($_) && ($expr == $_)) || | ||
| 60 | ($expr eq $_)); | ||
| 61 | } | ||
| 62 | return 1; | ||
| 63 | } | ||
| 64 | |||
| 65 | sub is_number { | ||
| 66 | my $v = shift; | ||
| 67 | return ($v=~/^([+-]?|\s+)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/); | ||
| 68 | } | ||
| 69 | 1; |