Solved

Stored Procedure Dynamic SQL in Interbase Firebird

Posted on 2004-09-28
6
992 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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 100 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 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