?
Solved

Stored Procedure Dynamic SQL in Interbase Firebird

Posted on 2004-09-28
6
Medium Priority
?
1,022 Views
Last Modified: 2008-02-26
How am i able to run a dynamic criteria SQL in a SP in a *Interbase FireBird database*?
For e.g. This SP received a few parameters named as P1, P2 which is my sql criteria value.
The sql statement will look like this :
select * from table1
where field1 = <P1 value> and field2 = <P2 value>

however if P1 or P2 appears to be null or empty value the sql ll be alternated to be:
select * from table1
where field1 = <P2 value>

or just:
select * from table1

how am i able to run a dynamic sql statement like this in a reasonable way.

Thanks for answering
0
Comment
Question by:den06boy
  • 4
  • 2
6 Comments
 
LVL 19

Expert Comment

by:NickUpson
ID: 12168495
to start with we need to know if it is interbase or firebird you are using and which version
0
 
LVL 19

Expert Comment

by:NickUpson
ID: 12168579
Is there some reason a view will do what you need?
0
 
LVL 19

Expert Comment

by:NickUpson
ID: 12168643
oops, type, that should be
Is there some reason a view will not do what you need?
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

Author Comment

by:den06boy
ID: 12176091
Oh I have a misunderstanding on interbase and firebird. I think I m using Firebird but for which version I m not sure of.
There is a reason which a view doesnt cater for my scenario but it will be whole lot to mention about it. The main purpose would be using a dynamic sql to get the result which i needed to do certain transactions using stored procedure.
0
 
LVL 19

Accepted Solution

by:
NickUpson earned 300 total points
ID: 12177031
Well firebird version 1.5 has EXECUTE STATEMENT :str; where str contains the SQL statement but it's not available in earlier versions of firebird
It may help to identify the version to know that 1.5 became available around feb/mar of this year.
0
 

Author Comment

by:den06boy
ID: 12177720
Anyway it helps!! thanks!
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
How much do you know about the future of data centers? If you're like 50% of organizations, then it's probably not enough. Read on to get up to speed on this emerging field.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question