[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Stored Procedure Dynamic SQL in Interbase Firebird

Posted on 2004-09-28
Medium Priority
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
Question by:den06boy
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
LVL 19

Expert Comment

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

Expert Comment

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

Expert Comment

ID: 12168643
oops, type, that should be
Is there some reason a view will not do what you need?
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.


Author Comment

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.
LVL 19

Accepted Solution

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.

Author Comment

ID: 12177720
Anyway it helps!! thanks!

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

649 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