User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 425,963 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,661 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser: Programming Forums
Views: 1059 | Replies: 0
Reply
Join Date: Jan 2008
Posts: 1
Reputation: scansterz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
scansterz scansterz is offline Offline
Newbie Poster

Array wrapped SQL - single Quotes error

  #1  
Jan 10th, 2008
Hi,
Here is the scenareo as well as I, a nubi can 'splain' it.
Three pages:
1. Order Form page. Collects the data and use input. Very complicated, but works and does its stuff well.
2. Processing page.
--a. checks for errors, returns errors - all ok
--b. If no errors, spits out the 'order' line by line accurately and
--c. Saves the line by line information in an array - the actual SQL insert statement
--d. Only allows user to Confirm Order or Cancel. If cancel, well you know. If Confirm then it goes to Third page
3. Thank you page.
--a. Says thanks.
--b. Insert the line items into the DB
--c. Emails Client with order information
--d. Done button - closes window.

Here is the problem and I have only seen it written about once.
When the THIRD page processes it the SQL fails because CF(7) puts in extra quotes in the SQL.
Because I loop thru and pop a query? Yes. I have discovered the problem.
I need the fix!


Here is building the array: Works fine. I can reitterate the all the arrays and visually check that the correct information is being presented in the ThankYou page...
<cfset insert_sql[i]="

(
ORDER_ID,
INSERTED_DATE,
ITEM_ID,
LINE_NUMBER,
QUANTITY_UPDATED,
PERCENT_FEMALE,
SHIP_TO_REP,
BILL_TO_REP
#form_rows_caps#
)
VALUES (
#FORM.ORDER_ID#,
SYSDATE,
'#Form[CountVar & '_item_id']#',
#Form[CountVar & '_line_number']#,
#line_qty#,
#female_percent#,
#FORM.SHIP_TO_REP#,
#FORM.BILL_TO_REP#
#form_vars_caps#
)
">

Here is the loop: From the Thank you page. The looping works fine.

<CFLOOP FROM="1" TO="#form.product_count#" index="i">

<cfquery name="InsertRequest" datasource="my-datasource" >
INSERT INTO my.order_table
#Form["INSERT_LINES_" & i]#
</cfquery>

</CFLOOP>

Inside that cfquery CF add quotes to the quotes and produces incorect SQL insert statements which causes the DB to give out the error, missing comas...

Help? Write a UDF that stops this from happening?

Thanks.
Scan.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ColdFusion Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the ColdFusion Forum

All times are GMT -4. The time now is 10:46 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC