Re: Stored Procedure woes!!

From: Ivan Debono (ivanmdeb_at_hotmail.com)
Date: 10/18/04


Date: Mon, 18 Oct 2004 14:39:24 +0200

I mean, event without parameters.

"Ivan Debono" <ivanmdeb@hotmail.com> schrieb im Newsbeitrag
news:upn5e4QtEHA.1720@TK2MSFTNGP14.phx.gbl...
> The problem is that I'm using a complex sql statement with multiple
unions.
>
> How can I execute the SP within a sql statement??
>
>
> "Uri Dimant" <urid@iscar.co.il> schrieb im Newsbeitrag
> news:%23b1c5zQtEHA.1216@TK2MSFTNGP10.phx.gbl...
> > Ivan
> > Its invalid syntax with SQL Server
> > You cannot do that
> > Instead ,create a temp table
> > create table #Temp
> > (
> > col ...
> > col1
> > col2...
> > )
> > Insert Into #Temp EXEC yourSP and then use a JOIN with another table
> >
> > Please ,note that the number of columns in #TEMP table must match with a
> > numbers of columns are returned by your SP
> >
> >
> >
> >
> >
> >
> > "Ivan Debono" <ivanmdeb@hotmail.com> wrote in message
> > news:eTnuFwQtEHA.376@TK2MSFTNGP09.phx.gbl...
> > > Hi all,
> > >
> > > I have the following stored procedure:
> > >
> > > CREATE PROCEDURE gross_net_vat_calculation @id_no_vat int,
@booking_date
> > > datetime, @amount_gross money
> > > as
> > >
> > > select DMBTR =
> > > case when percentage = 0 then @amount_gross else
> > > round((@amount_gross / (100+percentage) * 100),2)
> > > end,
> > > MWSTS =
> > > case when percentage = 0 then 0 else
> > > round((@amount_gross / (100+percentage) * percentage),2)
> > > end,
> > > sap_code as MWSKZ
> > > from vat_ranges
> > > where id_no_vat_fid = @id_no_vat and
> > > runningfrom <= @booking_date and
> > > runningto >= @booking_date
> > > GO
> > >
> > > It works fine when I call it alone (with constants as parameters).
> > >
> > > But I want to execute the procedure within a SELECT statement, where
the
> 3
> > > parameters are fields from a table, sort of:
> > >
> > > select *, exec gross_net_vat calculation vat_id, booking_date,
> > > booking_amount from bookings
> > >
> > > But obviously it's not working :(
> > >
> > > Anybody has an idea how to get it to work??
> > >
> > > Thanks,
> > > Ivan
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: Idea of SQL integration
    ... this issues like compiler directive e.g. ASM. ... is no general solution for multiple DB vendors (sas for multiple ... It gets a SQL statement and another parameter: Open, Execute, ExecuteAndFree. ...
    (borland.public.delphi.non-technical)
  • Re: tkprof interpreatation question
    ... library cache--Hard parse) ... Misses in library cache during execute (Misses while about to execute ... closes a cursor and then reopened a cursor with the same SQL statement ...
    (comp.databases.oracle.server)
  • Re: Optimizing inline view
    ... Mike C wrote: ... Can you verify that the SQL statement that ... I updated the statistics on this table and the thing ... If you are still having problems, execute the three ALTER SESSION ...
    (comp.databases.oracle.misc)
  • Re: newbie, getting cost plan
    ... I want to get the -real- cost and plan of an sql statement, ... assume that you can execute the SQL statement in question in SQL*Plus, ... However, be aware that this dilutes the information in the trace file, ...
    (comp.databases.oracle.server)
  • Re: dbs.Execute strSQL error - Too few parameters
    ... executing an update SQL statement in VBA. ... SQL executed with Execute goes straight to Jet without the advantage of the ... What is easier though is to delimit the statement so that the form reference ...
    (comp.databases.ms-access)