oracleparameter returns empty resultset

H

Huseyin altun

these two parameter field are varchar type in DB.
when I pass an empty string in one of the paramters the result set is empty.
but if I one parameter is something other than empty string, and the other
is existing value in the db, the result is correct.
Any idea ?

string SQL = "Select * from GAESTEST where MEMBERNR = :MemberNr or NAME =
:Name";
OracleCommand Cmd = new OracleCommand(SQL, OraConn);
Cmd.CommandType = CommandType.Text;

Cmd.Parameters.Add("MemberNr", txtMemberId.Text);
Cmd.Parameters.Add("Name", txtName.Text);

OraConn.Open();
 
G

Guest

Move to a stored procedure and test input. Below is partially PL/SQL coded
(have not worked in Oracle in months), so alter to correct syntax:

CREATE PROCEDURE TestProc
(
MemberNr varchar2,
Name varchar2
)
AS

IF MemberNr IS NULL or ''

'Run query with name only

ELSE IF Name is NULL or ''

'Run Query with MemberNr only

May want a test if both are null or empty and send back an error.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top