Dynamic SQL in Oracle Stored Procedure thro' ASP

suppose that i have a stored procedure that takes in an SQL command as input parameter and executes that statement.
We need to call that procedure through ASP.

The problem arises when we pass a SQL command, with a quoted string such as 'select * from temp where c1 = 'gh ' '
as

" ADODB.Command error '800a0d5d'
The application is using a value of the wrong type for the current operation. "

How could this be solved...

Thanks and Any help in this regards is appreciated.
rkrubaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

xabiCommented:
Use SQLEncode() function.
Ie:

Dim sString
sString = "'hi there" & """" ' Anything
strSQL = "SELECT * FROM foo WHERE text=" & SQLEncode(sString)
..
..

This should work

Xabi
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rkrubaAuthor Commented:
This gives a way out..  But still VBSCript gives Error on
SQLEncode

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'SQLEncode'

What to do now?



Thanks in ADvance
rkruba
0
xabiCommented:
Hi there again:

This is part of my code, and it works:

function SQLEncode(strSqlTmp)
 SQLEncode = replace(strSqlTmp,"'","'+CHAR(39)+'")
end function

strExample = "john " & chr(34) & "leftie's" & chr(34)
strSql = "INSERT INTO data (id) VALUES ('" & SQLEncode(strExample) & "')"
objConn.execute strSql
 .
 .

Xabi
0
xabiCommented:
I will splain you a few about this:

String values must be betwen ' (sigle quotes).
Ie: 'john'

If you want to inser a double quote you can.
Ie: 'John "the fly"'

If you want to add a sigle quote you must insert de SQL funtion CHAR(intAsc)
ie: 'John "leftie' + CHAR(39) + 's"'

Example of a complete query:

INSERT INTO data (id) VALUES ('john "leftie'+CHAR(39)+'s"')

Hope it helps
Xabi
0
MoondancerCommented:
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed.  Also a question is posted there specific to these changes that apply to the experts here.  Also, I am including the link to our All Topics, since many new ones have recently been added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.