GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  Visual Basic
Go To First  |  Previous Question  |  Next Question 
 Visual Basic  |  Question 376 of 453    Print  
How to write SQL query in Database environment, the query is parameterized eg: select * from account where accno=x
x: has to be taken from an Input box

  
Total Answers and Comments: 2 Last Update: May 08, 2006     Asked by: sireesha 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 18, 2006 02:11:57   #1  
sway        

RE: How to write SQL query in Database environment, th...

--I read somewhere about the following query.

--But this is not secure since @tableName can be replaced by anything

CREATE PROCEDURE dbo.getTable
@tableName varchar(50)
@fieldName varchar(20) NULL
@value varchar(20) @fieldName
AS
IF @fieldName NULL
BEGIN
EXEC ('SELECT * FROM '+ @tableName)
END
ELSE
BEGIN
EXEC ('SELECT * FROM ' + @tableName + ' WHERE ' + @fieldName + ' ' + @value + ' ')
END
GO


 
Is this answer useful? Yes | No
May 08, 2006 02:20:45   #2  
amrita sinha        

RE: How to write SQL query in Database environment, th...

Its very simple

write a procedure which will build a runtime SQL for you.

try this

create or replace procedure P_For_Test(PIN_ACCOUNT_NO number)

IS

strSQl varchar2(1000);

begin

strsql : ' ';

strsql : strsql ||'select * from <table name> where acc_no ' ||

write a procedure which will build a runtime SQL for you.

try this

create or replace procedure P_For_Test(PIN_ACCOUNT_NO number)

IS

strSQl varchar2(1000);

begin

strsql : ' ';

strsql : strsql ||'select * from <table name> where acc_no ' || PIN_ACCOUNT_NO

execute immediate strsql ;

end;

using this method u can build a runtime query and execute it . The most interesting fact is that u can run a DML statement in PL/SQL using this method.

bye


 
Is this answer useful? Yes | No

 Related Questions

Latest Answer : ODBC IS THE ONE OF THE WAY FOR CONNECTING DATABASEPROVIDER IS ANOTHER  WAY FOR CONNECTING DATABASEconnecting through DSN is odbc directconnecting through provider is microsoft jet database engine ...

Latest Answer : Step to Create ActiveX DLL/EXEStart-Visual Basic-select ACtiveDLL in New Project-in ClassModule write any functionRun the DLLChoose wait for component createdClick OK.Go to File click on Make project DLLsave the DLLNow IMP pointregister the componentyou ...

Latest Answer : 1. open ActveX Control from project. 2. Design and do coding. 3. Run it. 4. Make OCX(select File-Make OCX) 5. Register in system32. 6. Use it in ur program by selecting it from components. ...


Latest Answer : YesBy using Oracel driver with ODBC Connection object ...

Latest Answer : we can store data in XML file like database, we can retrive data from XML like database ...






 Sponsored Links

 
Related Articles

Using XMLType for Handling XML Data in the Database

Using XMLType for Handling XML Data in the Database Being an object type XMLType can not only be used to store XML data in the database but also to operate on that data via its built in methods Regardless of the storage model you choose XMLType provides a set of XML specific methods to operate on XM
 

Using Oracle Database for Storing, Modifying, and Retrieving XML Data

Using Oracle Database for Storing Modifying and Retrieving XML Data With Oracle XML DB you have various XML storage and XML processing options allowing you to achieve the required level of performance and scalability One of the most interesting things about Oracle XML DB is that it allows you to per
 

Performing XSLT Transformations inside the Database

Performing XSLT Transformations inside the Database Now that you have the employees XSL stylesheet stored in the database and the xmlusr schema is permitted to access the hr employees table you can create a script that will instruct the database to build an HTML page based on the data stored in hr e
 

Moving All the XML Processing into the Database

Moving All the XML Processing into the Database In the preceding example the database server performs only a part of the XML processing while the rest is still performed by the PHP engine Specifically the database server generates an employees XML document based on the records from the hr employees
 

Performing XML Processing inside the Database

Performing XML Processing inside the Database When building XML enabled applications on top of Oracle there are many advantages to performing the XML processing inside the database when compared to performing it on the client The key advantages to perform XML processing inside the database are as fo
 

jQuery - Basic Alphabetical Sorting

Learning jQuery Basic Alphabetical Sorting Now let s perform a sort on the Title column of the table We ll need a class on the table header cell so that we can select it properly geshibot lang html&quot; Title Author s Publish Date Price geshibot mosgoogle To perform the actual s
 

Working with XML in Visual Basic

Working with XML in Visual Basic Extensive markup language and Visual Basic is the odd couple of the industry Visual Basic is one of the most common languages that are being used today This Microsoft introduced language was meant to be middle tier in characteristic but has managed to get the top tie
 

C++ Standard Input Output Stream

C Standard Input Output Stream In this C tutorial you will learn about standard input stream and standard output stream explained along with syntax and examples C programming language uses the concept of streams to perform input and output operations using the keyboard and to display information on
 

What is an Ad Hoc Query

An Ad-Hoc Query is a query that cannot be determined prior to the moment the query is issued. It is created in order to get information when need arises and it consists of dynamically constructed SQL which is usually constructed by desktop-resident query tools. This is in contrast to any query which
 

What is Operational Database

Operational Database is the database-of-record, consisting of system-specific reference data and event data belonging to a transaction-update system. It may also contain system control data such as indicators, flags, and counters. The operational database is the source of data for the data warehouse
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape