Click here to Skip to main content
15,914,924 members
Home / Discussions / Database
   

Database

 
AnswerRe: problem related to insert query Pin
Mycroft Holmes6-May-09 14:42
professionalMycroft Holmes6-May-09 14:42 
QuestionRe: problem related to insert query Pin
nazimghori6-May-09 17:49
nazimghori6-May-09 17:49 
AnswerRe: problem related to insert query Pin
Mycroft Holmes6-May-09 18:06
professionalMycroft Holmes6-May-09 18:06 
AnswerRe: problem related to insert query Pin
AlexeiXX37-May-09 8:11
AlexeiXX37-May-09 8:11 
QuestionParameter problems Pin
Shrimpersfan6-May-09 4:00
Shrimpersfan6-May-09 4:00 
AnswerRe: Parameter problems Pin
Mycroft Holmes6-May-09 14:40
professionalMycroft Holmes6-May-09 14:40 
Questionhelp on sql CE update Pin
zigzagooo5-May-09 23:01
zigzagooo5-May-09 23:01 
QuestionOracle dynamic sql OPEN-FOR won't take SQL string in form of a string variable Pin
devvvy5-May-09 18:07
devvvy5-May-09 18:07 
hello

I'm using "OPEN-FOR", not "EXECUTE IMMEDIATE" because I want to do multi rows query. However, "OPEN-FOR" won't take a variable "strSQL" in its FOR clause, it only takes fixed strings?

create or replace function fnEnumSystemUser
(
LogonFilter nvarchar2,
...
AdditionalWhereClause nvarchar2,
OrderByClause nvarchar2
)
RETURN xxxxx.cursorType
AS
strSQL nvarchar2(2000);

FormatAdditionalWhereClause nvarchar2(2000);
FormatOrderByClause nvarchar2(2000);

SystemUserCursor xxxxx.cursorType;
BEGIN

IF AdditionalWhereClause IS NULL THEN
FormatAdditionalWhereClause := ' ';
ELSE
FormatAdditionalWhereClause := TRIM(AdditionalWhereClause);
END IF;

IF OrderByClause IS NULL THEN
FormatOrderByClause := ' ';
ELSE
FormatOrderByClause := TRIM(OrderByClause);
END IF;

strSQL := 'select Id,FirstName,MiddleName,LastName,PrimaryEmail,PersonType,CreateDate,CreatedBy,LastUpdate,LastUpdateBy,Logon,PasswdHash,IsSuspended,ExpiryDate from SystemUser left join Person on SystemUser.PersonId = Person.Id ';
-- This won't work, simply says "Warning: compiled but with compilation errors" when I tried to create function
open SystemUserCursor FOR strSQL;

-- This won't either, on invoke "ORA-01006: bind variable does not exist"
open SystemUserCursor FOR
'select Id,FirstName,MiddleName,LastName,PrimaryEmail,PersonType,CreateDate,CreatedBy,LastUpdate,LastUpdateBy,Logon,PasswdHash,IsSuspended,ExpiryDate from SystemUser left join Person on SystemUser.PersonId = Person.Id WHERE SystemUser.Logon like :x :y ' using LogonFilter, OrderByClause ;

-- This also failed (on invocation, "ORA-00900: invalid SQL statement")
open SystemUserCursor FOR
'select Id,FirstName,MiddleName,LastName,PrimaryEmail,PersonType,CreateDate,CreatedBy,LastUpdate,LastUpdateBy,Logon,PasswdHash,IsSuspended,ExpiryDate from SystemUser left join Person on SystemUser.PersonId = Person.Id WHERE SystemUser.Logon like :x' || OrderByClause using LogonFilter;

RETURN SystemUserCursor ;
END;


This is how I invoked it:
declare
NumItemsSelected int;
lstResult xxxxx.cursorType;

TYPE SystemUserRecordType IS RECORD
(
Id numeric(19,0),
FirstName nvarchar2 (50),
MiddleName nvarchar2 (50),
LastName nvarchar2 (50),
PrimaryEmail nvarchar2 (190),
PersonType int,
CreateDate timestamp,
CreatedBy numeric(19,0),
LastUpdate timestamp,
LastUpdateBy numeric(19,0),

Logon nvarchar2 (75),
PasswdHash int,
IsSuspended char,
ExpiryDate timestamp
);
oUser SystemUserRecordType;
begin

lstResult := fnEnumSystemUser (... '%',... ' Person.PrimaryEmail like ''%a%'', ' order by Logon ASC',0,10,NumItemsSelected);
LOOP
fetch lstResult into oUser;
exit when lstResult%notfound;
dbms_output.put_line('Id: ' || oUser.Id);
END LOOP;
end;


I need ability to append to SQL string because in the end say the least I need to append:
1. ORDER BY clause
2. Call a FUNCTION in WHERE Clause
3. Paging and ROW_NUMBER() clause

What can I do? Thanks!

dev

QuestionWhat would be the best front-end RAD software? Pin
el_pablo5-May-09 15:05
el_pablo5-May-09 15:05 
QuestionWhich flavor of SQL Server to use Pin
Hypermommy5-May-09 7:48
Hypermommy5-May-09 7:48 
AnswerRe: Which flavor of SQL Server to use Pin
Luc Pattyn5-May-09 8:47
sitebuilderLuc Pattyn5-May-09 8:47 
AnswerRe: Which flavor of SQL Server to use Pin
Eddy Vluggen6-May-09 2:41
professionalEddy Vluggen6-May-09 2:41 
QuestionDatabase design question Pin
AlexeiXX35-May-09 7:15
AlexeiXX35-May-09 7:15 
AnswerToo normalized ? Pin
David Mujica5-May-09 8:27
David Mujica5-May-09 8:27 
GeneralRe: Too normalized ? Pin
Mycroft Holmes5-May-09 14:56
professionalMycroft Holmes5-May-09 14:56 
GeneralRe: Too normalized ? Pin
AlexeiXX37-May-09 7:59
AlexeiXX37-May-09 7:59 
GeneralRe: Too normalized ? Pin
Mycroft Holmes7-May-09 14:22
professionalMycroft Holmes7-May-09 14:22 
GeneralRe: Too normalized ? Pin
AlexeiXX37-May-09 7:47
AlexeiXX37-May-09 7:47 
GeneralGlad to Help Pin
David Mujica7-May-09 7:56
David Mujica7-May-09 7:56 
QuestionSQL SERVER Pin
vasini5-May-09 4:07
vasini5-May-09 4:07 
AnswerDivide and conquer Pin
David Mujica5-May-09 5:11
David Mujica5-May-09 5:11 
GeneralRe: Divide and conquer Pin
vasini5-May-09 7:53
vasini5-May-09 7:53 
GeneralRe: Divide and conquer Pin
David Mujica5-May-09 8:20
David Mujica5-May-09 8:20 
Questionsecurity in MS access Pin
hrishiS5-May-09 2:01
hrishiS5-May-09 2:01 
AnswerRe: security in MS access Pin
Eddy Vluggen5-May-09 7:26
professionalEddy Vluggen5-May-09 7:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.