C
cptkirkh
I a trying to store certain sql queries in a table to reference
later. I want to perform a sql query to see if they are in the table
and i want to use bind variables. HOw can i do this?
Here is a sample of my code:
Dim sqltorun As String = "select max(ec_export_number) from
event_campaign " & _
" where EC_PURPOSE
= :event_purpose AND EC_ITEM_SENT = :item_sent" & _
" AND EC_SQL = :sql_totalcount "
Dim cmd As New OracleCommand(sqltorun, myConnection)
Try
cmd.Connection.Open()
Catch ex As Exception
MsgBox("Please close the program and reopen to establish a
new connection and if it happens again call MIS" + export_date,
MsgBoxStyle.OkOnly, title)
End Try
cmd.Parameters.Add(":sql_totalcount", OracleDbType.Varchar2).Value =
"select cli_rid from dual"
cmd.Parameters.Add(":event_purpose",
OracleDbType.Varchar2).Value = "20070511TXAM"
cmd.Parameters.Add(":item_sent", OracleDbType.Varchar2).Value
= "POSTCARD"
Try 'go and get the export number if false no query has been run
before
export_num = cmd.ExecuteScalar
When i get to this step i get illegal number or vairable as the
exception.
This sql code works just fine when i run it in sql plus or toad.
Thanks for your help.
later. I want to perform a sql query to see if they are in the table
and i want to use bind variables. HOw can i do this?
Here is a sample of my code:
Dim sqltorun As String = "select max(ec_export_number) from
event_campaign " & _
" where EC_PURPOSE
= :event_purpose AND EC_ITEM_SENT = :item_sent" & _
" AND EC_SQL = :sql_totalcount "
Dim cmd As New OracleCommand(sqltorun, myConnection)
Try
cmd.Connection.Open()
Catch ex As Exception
MsgBox("Please close the program and reopen to establish a
new connection and if it happens again call MIS" + export_date,
MsgBoxStyle.OkOnly, title)
End Try
cmd.Parameters.Add(":sql_totalcount", OracleDbType.Varchar2).Value =
"select cli_rid from dual"
cmd.Parameters.Add(":event_purpose",
OracleDbType.Varchar2).Value = "20070511TXAM"
cmd.Parameters.Add(":item_sent", OracleDbType.Varchar2).Value
= "POSTCARD"
Try 'go and get the export number if false no query has been run
before
export_num = cmd.ExecuteScalar
When i get to this step i get illegal number or vairable as the
exception.
This sql code works just fine when i run it in sql plus or toad.
Thanks for your help.