Re: Question about prepares.
Posted in 1996
> > Since we don't use prepares here at all. I thought I would take a > stab at one of the simpler 4gl reports just to see if I could get it > to work. Code fragment compiles fine but blows up at runtime with > Program stopped at "glksum.4gl", line number 32. > SQL statement error number -201. > A syntax error has occurred. > Line 32 is the prepare. > ... > ... > ... > PROMPT "Enter fund: " for fund > PROMPT "Enter SOF: "for sof > PROMPT "Enter account: " for acct > let select_stmt = > "select glk_key_cc[3,11], sum(glt_dr/100), sum(glt_cr/100) ", > "from glk_key_mstr,glt_trns_dtl ", > "where glk_key_mstr.glk_key_cc = glt_trns_dtl.glt_glad_cc1 ", > "and glk_grp_part01= '",fund,"'", ^ you need a space here. > "and glk_grp_part06 matches '",sof ,"'", ^ you need a space here. > "and glt_glad_cc1[13,13]= '",acct,"'", ^ you need a space here. > "group by glk_key_cc ", > "order by glk_key_cc" When you run into this problem the first thing to do is DISPLAY select_stmt SLEEP 10 Right here in your code. Then you can look at what it thinks it's trying to do, freeze the screen, cut and paste it into ISQL and try it... --- Other note - you can do some nifty stuff with PREPARE and CONSTRUCT: CONSTRUCT BY NAME where_clause ON foo.fund, foo.sof, foo.account LET sel_stmt = "SELECT * FROM foo WHERE ", where_clause clipped PREPARE s1 FROM sel_stmt .... cheers j. _____________________________________________________________________________ Jack Parker - Hewlett Packard, DMD/IS Boise, Idaho, USA jparker@hpbs3645.boi.hp.com Back in Boise _____________________________________________________________________________ If anything can go wrong, fix it. To hell with Murphy. _____________________________________________________________________________ Any opinions expressed herein are my own and not those of my employers. _____________________________________________________________________________