?
Solved

Stored Procedure Dynamic SQL in Interbase Firebird

Posted on 2004-09-28
6
Medium Priority
?
1,000 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

765 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