How to convert string to SQL Query

114 Views Asked by At

I have a requirement to convert a query in the string type to sql:ParameterizedQuery because I have to read the query from a file and execute that query against a mysql:Client.

Need to convert this to sql:ParameterizedQuery

string qry = "SELECT id, FirstName, LastName, gender, dob FROM patient";
1

There are 1 best solutions below

0
Prakanth On

We can't directly initialize the string to the parameterized query as this is an object type. We need to set the strings field of that parameterized query.

string qry = "SELECT id, FirstName, LastName, gender, dob FROM patient";
sql:ParameterizedQuery queryString = ``;
queryString.strings = [qry];