Re: sqlexec() with multiple SQL commands

From: Anders Altberg (x_pragma_at_telia.com)
Date: 10/28/04


Date: Fri, 29 Oct 2004 00:45:56 +0200

You don't have to separate SQLServer commands on separate lines. thew ;
shows is the end-of-command chrarcter. It's confusing of course that for VFP
the ; is a line continuation charachter and chr(1# is th end of command
 this works in q query sent to SQLServer as a one-line string
 lcSQL = [select * from customers; insert into customers (lastname) values
('x') ; delete from customers where lastname = 'x';]
or in VFP with 2 line breaks
 lcSQL = [select * from customers; insert ;
into customers (lastname) ;
values ('x') ; delete ;
customers where lastname = 'x';]
 SQLEXEC(h, lcsql)

or using TEXT - ENDTEXT
TEXT TO lcSQL NOSHOW
select * from customers; insert into
customers (lastname) values ('x') ; delete
from customers where lastname = 'x';
ENDTEXT
SQLEXEC(h, lcSQL)

-Anders

"Alan C. Sheffield" <asheffield @ park west gallery.com> wrote in message
news:e2Dm7pPvEHA.2616@TK2MSFTNGP10.phx.gbl...
> could you get the same result by just inserting a chr(13) into the sql
> string?
>
> m_query = 'insert into table_a (field_a) values (100);'
> +chr(13)+' select @@identity;'
>
> m_retcode = sqlexec(m_handle,m_query,"cursor10")
>
>
> Alan
> "Anders Altberg" <x_pragma@telia.com> wrote in message
> news:u2LjuI9tEHA.2192@TK2MSFTNGP14.phx.gbl...
> > Hi Randy
> > TEXT TO lcSQL NOSHOW
> > insert into table_a (field_a) values (100);
> > select
> > @@identity;
> > ENDTEXT
> > s=SQLEXEC(conn, lcSQL, 'retval')
> >
> > SQLServer will ignore the linbreaks in the text
> > -Anders
> >
> > <rmbyers@magma.ca> wrote in message
> > news:34b8n01jqdm65381n6ciklbqjvtgn936r0@4ax.com...
> > > Hello,
> > >
> > > I want to send two SQL commands to the SQL server with just one
> > > SQLEXEC() call. I believe this should be possible, but it doesn't
> > > appear to work.
> > >
> > > Here is the code:
> > >
> > > m_query = 'insert into table_a (field_a) values (100); select
> > > @@identity;'
> > >
> > > m_retcode = sqlexec(m_handle,m_query,"cursor10")
> > >
> > >
> > > ** notice the semicolon separating the two SQL commands in m_query
> > >
> > > I would expect to get a cursor back containing a field named "exp"
> > > which would be the identity value for table_a (which has an identity
> > > column named "id")
> > >
> > > Any ideas would be appreciated.
> > >
> > > Thanks
> > > Randy
> > >
> > >
> >
>
>



Relevant Pages

  • Re: works in query window, but not in code
    ... SQL Server also does not know about WITH OWNERACCESS OPTION. ... CountOfJob_Num FROM Customers INNER JOIN tblJobs ON Customers. ... When I paste it into a query window it runs fine. ... the query window parse it differently for SQLServer? ...
    (comp.databases.ms-access)
  • works in query window, but not in code
    ... CountOfJob_Num FROM Customers INNER JOIN tblJobs ON Customers. ... When I paste it into a query window it runs fine. ... the query window parse it differently for SQLServer? ...
    (comp.databases.ms-access)
  • Re: sqlexec() with multiple SQL commands
    ... TEXT TO lcSQL NOSHOW ... SQLServer will ignore the linbreaks in the text ... > I want to send two SQL commands to the SQL server with just one ...
    (microsoft.public.fox.vfp.queries-sql)
  • Getting table schema information with ADO.NET
    ... Given a table name (e.g. CUSTOMERS), how do I get column names of the table ... and the data types of the columns the table has? ... I am using SQLServer and would like to get that info from my C# code. ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)