User the "\n" sequence to insert newlines in a string.

 

How are you communicating with SQLServer?  You should be aware that using
native http has security consequences.  So does allowing dynamic sql.  You
would do better to use a server side process to integrate with the database.

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Mic
Sent: Monday, April 13, 2009 12:12 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] How to put a well-formatted SQL statement in a string?

 






I have to embed my SQL within Flex until I can work out how to call a
SQLServer proc from within Flex (any pointers here would be much
appreciated), and am writing functions:

private function sel_mrkt_pln_yrs(p_string:String = null):String{
var sqlString:String = "select distinct issue_yr, cast(issue_yr as Int) as
ID from MKT_PLN where (case when " + p_string + " is not null then case when
mkt_pln_typ = " + p_string + " then 1 end else 1 end) = 1 order by 1 desc;";


return sqlString; 
}

I would like to format the SQL so I can read it:

select distinct
issue_yr,
cast(issue_yr as Int) as ID
from
MKT_PLN
where
(case when @p_mkt_pln_typ is not null then
case when mkt_pln_typ = @p_mkt_pln_typ then
1
end
else
1
end) = 1
order by
1 desc;

but var sqlString:String = ... will not take the separate lines etc. How are
people doing this? TIA,

Mic.



Reply via email to