You also might need an '='
str = <<END_OF_SQL
(buncha sql)
END_OF_SQL

--Mark


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Cain, Mark
Sent: Monday, March 20, 2006 1:13 PM
To: [email protected]
Subject: Re: [Wtr-general] OT: big 'ol variables?

Did you intend to put a space between << and END_OF_SQL?
str << END_OF_SQL
(buncha sql)
END_OF_SQL

it looks like there is not supposed to be one in the documentation.
str <<END_OF_SQL
(buncha sql)
END_OF_SQL


--Mark

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chris McMahon
Sent: Monday, March 20, 2006 12:44 PM
To: [email protected]
Subject: [Wtr-general] OT: big 'ol variables?

Hi...

Pardon the interruption, but I'm scratching my head over this one.

the "<<" syntax works fine for assigning a ton of XML to a variable
"str" i.e.

str = <<END_OF_XML
<requestroot xmlns="http://foo";>
<lastname xmlns="" >#{lstnm} < /lastname>
<firstname xmlns="">#{fstnm}</firstname>
</requestroot>
END_OF_XML


but if I try to assign a large SQL statement to a variable using the
same technique, Ruby is trying to parse the parens and things as if
the SQL were code:

foo_test.rb:47: syntax error
foo_test.rb:49: warning: don't put space before argument parentheses
foo_test.rb:50: warning: parenthesize argument(s) for future version
foo_test.rb:51: syntax error
              from   FOOLIB.TABLE1 first_value
                  ^
foo_test.rb:51: warning: parenthesize argument(s) for future version
foo_test.rb:52: warning: parenthesize argument(s) for future version
foo_test.rb:52: warning: parenthesize argument(s) for future version
foo_test.rb:55: syntax error
                and  FOOLIB.TABLE2.CRAZY_DATE >
'9999-12-30-00.00.00.000000'
                   ^
foo_test.rb:56: syntax error

anyone have any suggestions for getting Ruby to Do The Right Thing when

str << END_OF_SQL
(buncha sql)
END_OF_SQL

?

Thanks and apologies...
-Chris

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to