Solved

Stored Procedure Dynamic SQL in Interbase Firebird

Posted on 2004-09-28
6
988 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

738 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