![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | select from database and own parameter Hi, I've huge problem with one thing. I need to create select in oracle where one comparison will include my own parameter. Here is example: sql = "select to_char(oradatetime,'rrrr-mm-dd HH24:MI:SS') oratime from table where oratime >= MYPARAMETER" MYPARAMETER is date type - conversion the same like oradatetime MYPARAMETER = date & " " & time MyStrDate = CStr(MYPARAMETER ) If I use: sql = "select to_char(oradatetime,'rrrr/mm/dd HH24:MI:SS') oratime from table where oratime >= " & MyStrDate I got error that: Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC driver for Oracle][Oracle] ORA-00933 : SQL command not properly ended Does anybody know how to avoid this error I've tried join, replace, chr(34) - nothing work when I try to use sql connection I got this error. Regards, esska |
My System Specs![]() |
| | #2 (permalink) |
| | Re: select from database and own parameter esska wrote: Quote: > Hi, > I've huge problem with one thing. I need to create select in oracle > where one comparison will include my own parameter. > Here is example: > > sql = "select to_char(oradatetime,'rrrr-mm-dd HH24:MI:SS') oratime > from table where oratime >= MYPARAMETER" > > > MYPARAMETER is date type - conversion the same like oradatetime > MYPARAMETER = date & " " & time MYPARAMETER = Now() ? Quote: > > MyStrDate = CStr(MYPARAMETER ) > > If I use: > sql = "select to_char(oradatetime,'rrrr/mm/dd HH24:MI:SS') oratime > from table where oratime >= " & MyStrDate > > I got error that: > Microsoft OLE DB > Provider for ODBC Drivers: [Microsoft][ODBC driver for Oracle][Oracle] > ORA-00933 Quote: >> SQL command not properly ended > Does anybody know how to avoid this error > I've tried join, replace, chr(34) - nothing work when I try to use sql > connection I got this error. > sql = "select to_char(oradatetime,'rrrr/mm/dd HH24:MI:SS') " & _ "oratime from table where oratime >= ?" Use a command object to pass the value into the statement: set cmd=createobject("adodb.command") cmd.commandtype=1 '1=adCmdText cmd.commandtext=sql set cmd.activeconnection = yourcommandobject set rs = cmd.execute(,CDate(MYPARAMETER)) -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" |
My System Specs![]() |
| | #3 (permalink) |
| | Re: select from database and own parameter The error message you're getting says that your SQL command isn't properly ended. That means you need single quotes around the date. sql = "select to_char(oradatetime,'rrrr/mm/dd HH24:MI:SS') oratime from table where oratime >= '" & MyStrDate & "'" |
My System Specs![]() |
| | #4 (permalink) |
| | Re: select from database and own parameter Hi, Thank you for replying. The problem was with sql, it shoud be something like this: sql = "select to_char(oradatetime,'rrrr/mm/dd HH24:MI:SS') from table where oradatetime>= (' " & MyStrDate & "','rrrr/mm/dd HH24:MI:SS')". I use this to execute command: oRs.open sql, oConn which is similar to executhing made by Bob. Thank you for help. Regards, esska |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Using multiple Parameter sets for a Parameter | PowerShell | |||
| Configuration parameter in SQL database | .NET General | |||
| Works database 2007 and Office database 2003 | .NET General | |||
| How to best control parameter attributes and parameter parsing in your own scripts? | PowerShell | |||
| Suggestion: new parameter for Select-Object: "-Which <position> | PowerShell | |||