Value of a variable in my stored proc

I have a cursor in my Stored Proc. which passes data to a variable "sRowcount" to store how many rows returned from the Cursor. In My Access app. I need to call the stored proc and pass the value of the last row returned.
e.g.sRowcount=1,sRowcount=2,sRowcount=3,sRowcount=4,sRowcount=5,sRowcount=6. In my Access app, I need to call the stored proc. and get value of last row count sRowcount=6 and pass to somewhere else.
Thanks

YESSSS . Thanks you very much Kglad it wotk i put all in a function inside the filmstrip function Tload(theUrl){etc ect}and in the root i call it like this filmstrip.Tload(theUrl);   and it works
code in the root var link1:Array = new Array();
var LINK:String;
var url:String;
var whoOn:Number;
whoOn=0;
var x:XML = new XML();
x.ignoreWhite = true;
x.onLoad = function(success) {
var photos:Array = this.firstChild.childNodes;
for (i=0; i<photos.length; i++) {
_root.link1.push(photos[i].attributes.link1);
url=link1[whoOn];
theUrl=url;
filmstrip.Tload(theUrl);//<<--HERE
x.load("category.xml");
var cbListener:Object = new Object();
cbListener.change = function(event_obj:Object) {
trace(select.selectedItem.label);
if (select.selectedItem.label == "Last updated") {
whoOn=0;
} else if (select.selectedItem.label == "Special") {
whoOn=1;
url=link1[whoOn];
theUrl=url;
filmstrip.Tload(theUrl);//<<-----HERE
select.addEventListener("change",cbListener);

Similar Messages

  • Variables/parrameters in stored procs

    Hi All
    Are there any way of specifying something other than the stored procedure name to be appended in front of local variables and parrameters in a SP when migrating from Sybase 11.9.2. Our variables mostly have the same name as table columns since sybase allows you to distinguish between them using the "@" character. In oracle though we would like to implement the proper naming standard like "v_" or something similar
    Thanks

    Local variables can have the local procedure name'.' or nothing appended to the front of them. There is a parser option to choose which. If this is a serious restriction please email [email protected] to raise an enhancement request.
    (You could use a script to change procedurename. to v_ afterwards (?))
    Turloch
    Oracle Migration Workbench Team

  • Writing a Stored Proc which will execute the Queries passed to it as args

    Hi,
    I need to write a Stored Proc which gets the Query to be executed as an Argument and return the results in an OUT Variable.
    The Stored Proc i wrote is
    CREATE OR REPLACE PROCEDURE SP_FETCH_RESULTS(l_query in varchar2,
    l_returnValue out clob )
    is
    l_output utl_file.file_type;
    l_theCursor integer ;
    l_columnValue clob;
    l_status integer;
    l_results      clob;
    begin
    l_theCursor := dbms_sql.open_cursor;
    -- Parse the Query
    dbms_sql.parse( l_theCursor, ':x', dbms_sql.native );
    DBMS_SQL.BIND_VARIABLE(l_theCursor, ':x', l_query);
    -- Define the coulmnValue Variables
    dbms_sql.define_column( l_theCursor, 1, l_columnValue);
    -- Execute the Query
    l_status := dbms_sql.execute(l_theCursor);
    -- Get the Results and prepare the return Value.
    loop
    exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
    dbms_sql.column_value( l_theCursor, 1, l_columnValue );
         DBMS_LOB.APPEND(l_returnValue, l_columnValue);
    end loop;
    -- Close the Cursor
    dbms_sql.close_cursor(l_theCursor);
    end SP_FETCH_RESULTS;
    As the Queries paased to it always return CLOB Types i declared the OUT Variable as CLOB
    And when i try to execute is using the below given PL/SQL Block
    DECLARE
    l_Query CLOB ;
    l_retVal CLOB;
    l_results CLOB;
    BEGIN
    l_Query:='SELECT extract(object_value,''/AC'').getStringVal() into l_results from CommonAssetCatalog';
    SP_FETCH_RESULTS(l_Query,l_retVal);
    dbms_output.put_line ('Results =');
    END;
    I am getting the Error.
    ERROR at line 1:
    ORA-00900: invalid SQL statement
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 906
    ORA-06512: at "SYS.DBMS_SQL", line 39
    ORA-06512: at "WEBLOGIC.SP_FETCH_RESULTS", line 13
    ORA-06512: at line 7
    Could you guys pls give me some inputs on how to resolve this..
    Thanks a lot
    Sateesh

    Hi James,
    I tried with out the Bind Variable and got the Same Error..
    The Code which i tried earlier is
    CREATE OR REPLACE PROCEDURE SP_FETCH_RESULTS(l_query in varchar2,
    l_returnValue out clob )
    is
    l_output utl_file.file_type;
    l_theCursor integer ;
    l_columnValue clob;
    l_status integer;
    l_results      clob;
    begin
    l_theCursor := dbms_sql.open_cursor;
    -- Parse the Query
    dbms_sql.parse( l_theCursor, l_query, dbms_sql.native );
    --DBMS_SQL.BIND_VARIABLE(l_theCursor, ':x', l_query);
    -- Define the coulmnValue Variables
    dbms_sql.define_column( l_theCursor, 1, l_columnValue);
    -- Execute the Query
    l_status := dbms_sql.execute(l_theCursor);
    -- Get the Results and prepare the return Value.
    loop
    exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
    dbms_sql.column_value( l_theCursor, 1, l_columnValue );
         DBMS_LOB.APPEND(l_returnValue, l_columnValue);
    end loop;
    -- Close the Cursor
    dbms_sql.close_cursor(l_theCursor);
    end SP_FETCH_RESULTS;
    and the Procedure got Compiled Successfully and when i ran the PL/SQL Block which calls the Above Stored Proc i got the Error
    DECLARE
    ERROR at line 1:
    ORA-00905: missing keyword
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 906
    ORA-06512: at "SYS.DBMS_SQL", line 39
    ORA-06512: at "WEBLOGIC.SP_FETCH_RESULTS", line 13
    ORA-06512: at line 7
    Pls let me know how can i resolve this..
    Thanks
    Sateesh

  • Unable to pass the values to stored proc using presentation variable in OBI

    Hi All,
    Need your help regarding in resolving an issue in OBIEE 10.1.3.4.1
    There is an OBIEE requirement whereby two prompts need to be defined.
    1.     Textbox prompt
    2.     Drop-down prompt
    The dropdown values should be populated using textbox prompt. So, we have used presentation variable in textbox prompt and passing the same to select query of drop-down.
    Until this step, the report works just fine.
    Now, the value in both textbox and drop-down needs to be passed to stored proc.
    While trying to pass the values by using the presentation variable, the following error comes-up saying
    Session variable has no value definition.
    Note:Although the corresponding session variable has been set to default value,still the error appears.
    Please advise.
    Regards,
    Prasad

    "Session variable has no value definition" I'm assuming typo error and it should be presentation variable.
    Set default value for presentation variable that may work

  • How to set variable values in Stored Procs

    Hi all,
    please excuse my newbie questions - I've spent too long using SQL Server......
    Anyway,
    I'm playing with SP basics and was wondering how I can set a variable value in a stored proc, ideally getting a value from a table or some select .
    for instance...........
    CREATE OR REPLACE PROCEDURE RPT_SP_ANT_TESTING
    P1 IN NUMBER,
    P2 IN VARCHAR2
    IS
    TmpNum NUMBER;
    TmpStr VARCHAR2(255);
    BEGIN
    --How do set these?
    SET TMPNUM := SELECT Count( * ) FROM ALL_TABLES;
    SET TMPSTR := P2 + '_APPENDED';
    INSERT INTO TEST_TABLE
    ( STRINGFIELD, NUMBERFIELD )
    VALUES
    ( TmpStr, TMPNUM )
    END;
    Regards
    DC

    Some ways are...
    setting directly
    x := 1;
    setting from a select use INTO clause
    select 1 into x from dual
    setting from a select into a collection type use BULK COLLECT INTO
    select name bulk collect into lName from your_table.
    It would be better if you read the document.
    Thanks,
    Karthick.

  • To pass new session variable value to stored proc before running a report.

    Hi,
    Below is summary of the report requirement -
    Database level design
    1. Created a view and a global temporary table (GTT)
    2. Created an Oracle package procedure to accept from and to business dates on basis of which it will fetch, process and populate the GTT.
    Repository level design
    1. Created a business model containing the view and the GTT (mentioned above)
    2. Created two SESSION variables "from_dt" and "to_dt" to be initialized by their respective init blocks. Each of the variable is initialized with a DATE column value (of type DATETIME) from a database lookup table. I have also set the option "Enable that variable to be set by any user" for both variables.
    Query for these variables :
    from_dt = select from_date from <table>
    to_dt = select add_months(from_date,12) from <table>
    Presentation level design
    1. Using a text box, i display the default/initialized values of these variables like this -
    Current business date:@{biServer.variables['NQ_SESSION.from_dt']} Future business dt:@{biServer.variables['NQ_SESSION.to_dt']}
    Dates get displayed in YYYY-MM-DD 00:00:00 format
    The text msg displays these default dates and allows the user to specift different date range for which i create prompts as shown below.
    2. Using any random two columns of date type from the business model, i create two date dashboard prompts with labels "From Dt" and "To Dt".
    i select Calender Controls for both; setting Default To = Report Defaults.
    The Set Variable is set to Presentation variables - such that pv_from_dt maps to "From Dt" and pv_to_dt maps to "To Dt".
    3. i create the report using the business model created above. In the report "Advanced Tab" => "Prefix" field i specify the following -
    SET VARIABLE from_dt='@{pv_from_dt}',to_dt='@{pv_to_dt}';
    Note : The logic here is to display the default dates and allow user to specify different date values which will be stored in presentation variables.
    If the user does specify different "from dt" and "to dt" values, then using the presentation variables, i want to "write" back these new values to the corresponding session variables mentioned above.
    If the user does not specify different date range, then the default/initialized dates must be considered.
    I also display the default and new date values in the report title.
    Back to Repository level design
    To execute the stored procedure that will load the GTT before running the report I need to pass two date parameters to the stored procedure on basis of which it will fetch data, process and populate the GTT.
    In the Connection Pool --> Connection Script Tab --> Execute before query, I wrote the below query using the repository variables FROM_DT and TO_DT to execute the procedure -
    DECLARE
    v_from_dt date;
    v_to_dt date;
    BEGIN
    v_from_dt := VALUEOF(From_Dt);
    v_to_dt := VALUEOF(To_Dt);
    package_name1.package_body(v_from_dt,v_to_dt);
    END;
    Now when i try to run the report i get the following error :
    [nQSError: 10058] A general error has occurred. [nQSError: 23006] The session variable, NQ_SESSION.to_dt, has no value definition. (HY000)..
    Need help on this.
    Is it possible to "write back" a new value to a session variable ?
    Any other alternatives.
    Thanks
    Nusrat
    Edited by: user10309945 on Jan 24, 2011 10:08 PM

    Sandeep, I found a several topics where users describe saving values in DB through stored procedure or function. For example, [How to store OBIEE presentation level variable values in DB |http://forums.oracle.com/forums/thread.jspa?threadID=892006] I tried it and get an error
    *10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 14551, message: ORA-14551: cannot perform a DML operation inside a query ORA-06512*
    It's not a BI error. This error are generated by Oracle DB. If I write next:
    SELECT MyPLSQLFunction(p1,p2) FROM DUAL
    I get the same error.
    Oracle doesn't allow DML operations in SELECT.
    Did you relalize this feature yourself? Where did I mistake?

  • How to pass the values to stored proc using presentation variable in OBIEE

    Need your help regarding in resolving an issue in OBIEE 10.1.3.4.1
    There are 6 reports say ‘A’,’B’,’C’,’D’,’E’,’F’ in the same subject area.
    The reports are being configured with prompts using either the repository/presentation variables.
    One of the reports say ‘A’ has been configured to pass the values using presentation variables from the prompt in Advanced Tab of the report request to the stored procedure defined in the Execute Before Query section of the connection pool.
    After running another report ‘B’ in the same subject area, upon visiting the report ‘A’ view display error is being seen ( Please have a look below screen shot for your reference) .
    Speculate the issue is around presentation variables of report ‘A’ getting initialized even before running the report.
    Appreciate your earliest advise as this is a prod issue.

    Hi Prasad,
    I got your note, you should not use Session variable syntax to call presentation variable.
    you should use like @{AIC_PROJ_PLAT_SEQ_NO}
    One more thing: first test the variable AIC_PROJ_PLAT_SEQ_NO value then try to pass to SP.
    Hope this helps

  • Stored Proc with SSRS multi value parameter gives " Must Declare scalar Varaiable @StateID

    Hi All,
    I have one stored proc with @fromDate , @Todate and multivalue input
    parameter@StateID of type integer.
    When I run below stored proc via SSRS by selecting multiple values thru multiValue parameter into @StateID...it gives error saying "Must Declare scalar variable @StateID"
    Not sure what is wrong with the input parameters.
    ID is Integer type in all the 3 tables - dbo.EastCities, dbo.WestCities  , dbo.Country
    I need help fixing this  "Must Declare scalar variable @StateID" error
    This is the UDF split() I am using..
    Function:
    CREATE FUNCTION dbo.SplitStateID
    (    @List VARCHAR(MAX))
    RETURNS TABLE
    AS   
    RETURN   
    (        SELECT DISTINCT [Value] = CONVERT(INT, LTRIM(RTRIM(CONVERT( VARCHAR(12),SUBSTRING(@List, Number, CHARINDEX(',', @List + ',', Number) - Number))))
     FROM  dbo.Numbers       
     WHERE Number <= CONVERT(INT, LEN(@List))AND SUBSTRING(',' + @List, Number, 1) = ','    );
     GO
     SELECT [Value] FROM dbo.SplitStateID('10,30,50');
    Also, I have created dbo.Numbers table which is used in udf..
    reference url -- > 
    http://sqlblog.com/blogs/aaron_bertrand/archive/2009/08/01/processing-a-list-of-integers-my-approach.aspx
    SET NOCOUNT ON;
    DECLARE @UpperLimit INT;
    SET @UpperLimit = 10000;
    WITH n AS(   
    SELECT        rn = ROW_NUMBER() OVER        (ORDER BY s1.[object_id])   
    FROM sys.objects AS s1   
    CROSS JOIN sys.objects AS s2   
    CROSS JOIN sys.objects AS s3)
    SELECT [Number] = rn - 1
    INTO dbo.Numbers FROM n
    WHERE rn <= @UpperLimit + 1;
    CREATE UNIQUE CLUSTERED INDEX n ON dbo.Numbers([Number]);
    Stored procedure:
    Create Procedure dbo.CountrySelection
    ( @FromDate Date, @ToDate Date, @StateID Int)
    AS
    BEGIN
    set nocount on;
    SELECT * INTO #EastCities
    FROM (
    SELECT ID,Description from dbo.EastCities
    Where ID IN (SELECT Value from dbo.SplitStateID(@StateID))
    ) AS A
    SELECT * INTO #WestCities
    FROM (
    SELECT ID,Description from dbo.WestCities
    Where ID IN (SELECT Value from dbo.SplitStateID(@StateID))
    ) AS B
    SELECT * INTO #Country
    FROM (
    SELECT ID , Description, State,Country From dbo.Country
    ) AS C
    SELECT EC.ID AS East, WC.ID AS West , EC.Description AS EastDesc, WC.Description AS WestDesc, CT.State, CT.Country
    FROM #Country CT
    LEFT JOIN #EastCities EC ON CT.ID=EC.ID
    LEFT JOIN #WestCities WC ON CT.ID=WC.ID
    DROP TABLE #EastCities
    DROP TABLE #WestCities
    DROP TABLE #Country
    END
    Above 3 temp tables are joined by #Country.ID key
    It works fine when single value is passed in @StateID
    Exec dbo.CountrySelection '01/01/2010','02/01/2010',10
    It fails when multi value passed into @StateID
    Exec dbo.CountrySelection '01/01/2010','02/01/2010','10,30,40'
    SSRS error log shows "Must declare scalar variable @StateID"
    Need help in fixing this issue.
    Thanks,
    RH
    sql

    Visakh,
    I changed @StateID date type to varchar(max) and still I get this error.  
    System.Data.SqlClient.SqlException: Must declare the scalar variable "@StateID".
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    I am running this SO in SSRS quert Type =Text
    Actually sp created on db2 database and due to some limitations I am running(via SSRS) this from different db1 database data source within the same db server. When I run this sp from SSRS query designer(edit query designer button) and pass
    multivalue parameters to @StateID as 10 , 20 it works and gives expected resultset.
    Thanks,
    RH
    sql

  • Replacing null values in optional prompts and passing to stored proc

    Hi,
    I want to create a stored procedure with OPTIONAL prompts. When user does not pass a value for that parameter, I want to set the value for that parameter by selecting from a column in table then I WANT to use that paramvalue in sql within cursor of stored proc. How do I do that?
    In short, I want to do the following Here is the psuedocode:
    Create or replace procedure test (param IN varchar2 DEFAULT NULL)
    As
    var_param varchar(20);
    select param into var_param from dual;
    If param is null then select custid from table1 else var_param
    OPen ref_cursor for
    Select xyz from table2
    where fyy = var_para
    Can someone let me know the syntax on how to do this in stored proc?
    Regards,
    hena
    Edited by: 904385 on Dec 25, 2011 7:04 AM

    Hi,
    Merry Christmas, and welcome to the forum!
    Here's one way to do what you requested:
    CREATE OR REPLACE PROCEDURE     test
    (    param     IN     VARCHAR2     DEFAULT     NULL
    AS
        ref_cursor     SYS_REFCURSOR;
        var_param     VARCHAR2 (20)     := param;
    BEGIN
        IF  var_param  IS NULL
        THEN
         SELECT     custid
         INTO     var_param
         FROM     table1
    --     WHERE     ...     -- Unless table1 has only 1 row
        END IF;
        OPEN  ref_cursor
        FOR   SELECT  xyz
           FROM       table2
           WHERE       fyy     = var_param;
    END     test;Whatever you're trying to do, this is probably niot the simplest or most efficient way to do it.

  • Parsing Column Value. SQL / Stored Proc/ Function ?

    Hi,
    I just started writing SQL. Need your valuable input for the following query,
    Need to query a table and parse a column to produce a desired output.
    like suppose my column value is
    #ADFA
    /SDFGAS
    {ABC}: 123
    {BCA}: 456
    {DEF}: 789
    and i need to get an out put as follows
    {ABC} {BCA} {DEF}
    123 456 789
    so the patterns are defined.
    I some how tried and reached through SQL, but there should be better way than this. So posted this question.
    I tried using SQL itself (using substr, instr & decode functions in the select statement)... with out using stored proc/ function as i have not created one earlier.. I am just learning the syntax and trying it.
    The psuedo code i have planned is
    function substring(column_value, search_string)
    var start_index NUMBER;
    var end_index NUMBER;
    var result VARCHAR2;
    result = 'N/A';
    start_index = instr(column_value, search_string) + 4
    if start_index >= 4
    end_index = instr(substr(column_value, 0, start_index), CHR(13)-1)
    if start_index >= 4 && end_index >=0
    result = substr(column_value, start_index, end_index);
    return result;
    I just wrote it like writing in a programming language. Need to implement this through Stored Proc/ Function. Please let me know your comment on this

    Oops, I think regular expressions are not available in my current oracle version :-(
    I am having Oracle 9i.
    Got it.. Yes it is available from 10G onwards.. :-(
    Message was edited by:
    Thiru.Thiru

  • DATE value in a STORED PROC becoming incorrect?

    I have a PL SQL script that creates a TABLE on the fly with a DATE column in it. I then have a FUNCTION that queries this table. The FCN is called from within a SP. In these three steps the date becomes a BOGUS value.... I am seeing things like this:
    2/5/0009 12:00:00.000 AM
    6/4/0009 12:00:00.000 AM
    4/16/0009 12:00:00.000 AM
    7/9/0008 12:00:00.000 AM
    5/7/0007 12:00:00.000 AM
    Obviously the 0009 should be 2009 and 0008 2008 etc..... ANy idea what is causing this?????
    Here is my code:
    DROP TABLE MAXIMO.MAX411_TEMP_REG_DATE
    create table
       MAXIMO.MAX411_TEMP_REG_DATE
    as
    SELECT  ITEMNUM,
            DESCRIPTION,
            LOCATION,
            BINNUM,
            REG_DATE + (trunc(rownum / ((select count(*) from inventory)/100))*7) REG_DATE
    FROM ( SELECT   I.ITEMNUM,
                    I.DESCRIPTION,
                    N.LOCATION,
                    N.BINNUM,
                    TO_DATE(SYSDATE,'DD-MON-YYYY') REG_DATE
            FROM ITEM I, INVENTORY N
            WHERE I.ITEMNUM = N.ITEMNUM
            ORDER BY N.LOCATION, N.BINNUM)
    COMMIT
    CREATE OR REPLACE FUNCTION MAXIMO.FCN_GET_REGDATE (item_in IN VARCHAR2)
      RETURN DATE
    IS
      new_regdate   DATE;
      var_problem_indicator   number;
      BEGIN
              SELECT reg_date
               INTO new_regdate
               FROM MAXIMO.MAX411_TEMP_REG_DATE
               WHERE itemnum = TRIM(item_in) AND ROWNUM = 1;
      END;
    RETURN new_regdate;
    END;
    / STORED PROC CALL
    var_regdate             DATE;
    var_regdate := MAXIMO.FCN_GET_REGDATE (rec.ITEMNUM);Thanks for any help I can get.....
    Miller

    Looking at this code I find two items very disturbing:
    ORDER BY N.LOCATION, N.BINNUM
    ... and ...
    WHERE itemnum = TRIM(item_in) AND ROWNUM = 1;
    It looks a lot like you are trying to rely on a sort order imposed on the data as it is inserted into the table to identify a particular record for a given item_in. If so, that's very dangerous, but it's nothing that can't be fixed. Let us know ...

  • Passing series of value to a stored proc

    I call a stored proc from an ASP page (VBScript or Jscript) via ADO and I need to give to this proc a series of value.
    The proc as to execute a query that look like
    select a_Column from a_Table
    where a_TableId in (My_Series)
    I would like to pass My_Series as a single parameter.
    Could I declare My_Series as something like an array ?
    or a string like ( 'A', 'B' , , 'C') ?

    See:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:110612348061
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:210612357425
    or just do a search for "in list" on http://asktom.oracle.com/

  • Save prompted sql stored proc parm values in rpt file from designer

    How can I save the last prompted sql stored proc parameter values from within the CR designer.  In other words I want to hard code some of the parameter values (the rest are passed) so that CR does not prompt at run time.  I am running CR Developer XI R2 SP1 from within VS.Net 2005 (Winforms)

    Please re-post if this is still an issue to the .NET Development - Crystal Reports Forum or purchase a case and have a dedicated support engineer work with you directly

  • Oracle 11g stored procs: SELECT ALL_ARGUMENTS not returning certain values in certain cases

    I'm doing a select on the ALL_ARGUMENTS like:
    SELECT count(*) FROM all_arguments WHERE owner LIKE 'MySchema' ESCAPE '/' AND object_name LIKE 'MyStoredProc' ESCAPE '/' AND package_name LIKE 'MyPackage' ESCAPE '/';
    Sometimes, after connecting to the DB after a certain period of time, I get a result = 0, althought the Stored Procedure is there. Immediatelly after that I retry, and I get result = 2.
    Why is that? Does the SELECT recompile the stored proc?

    I'm surprised that you get anything if you use that query.
    Oracle considers object names to be uppercase unless the name is enclosed in double quotes. So there would be no schemas with a name 'MySchema' since the name would actually be 'MYSCHEMA'.

  • Advice Please: Adding Few Static Values to Stored Proc Returned Result Set

    Hello -
    The Stored Proc below returns about 1000 rows of result set when a date is passed to the query. In addition to that, there are about 5 rows of data (which is in my excel file) needs to be added to the result set. What is the best possible way?
    What I have done is I created a new table which has that 5 static rows. It has just the addresses and amount and customer number. There is no invoice date in that table. I tried UNION and the query did not like the fact that I had something like that in
    the first table:
    SELECT
    '0' as 'TYPE'
    ,'TBCCA' as 'Acc ID'
    ,'12882' as 'BEID'
    , '' as ' # OF UNITS'
    , Circuit_Total as 'AMT'
    ,'D' as 'D or C'
    , '' as ' FDOC yyyymmdd'
    , '' as ' LDOC yyyymmdd'
    , Address as 'Brief Comment'
    , city as 'Tax City'
    , State as 'Tax State'
    , Zip_Code as 'Tax Zip Code'
    , INV_DATE as 'Invoice Date'
    FROM [dbo].[TBC_MonthlyCircuitDetail]
    WHERE INV_DATE = '2014-07-01'
    AND [Circuit_Total] >0
    UNION
    SELECT 0
    '0' as 'TYPE' --DID NOT LIKE THIS <<
    ,'TBCCA' as 'Acc ID'
    ,'12882' as 'BEID'
    , '' as ' # OF UNITS'
    , Circuit_Total as 'AMT'
    ,'D' as 'D or C'
    , '' as ' FDOC yyyymmdd'
    , '' as ' LDOC yyyymmdd'
    , Address as 'Brief Comment'
    , city as 'Tax City'
    , State as 'Tax State'
    , Zip_Code as 'Tax Zip Code'
    , '' INV_DATE as 'Invoice Date'
    FROM [dbo].[TBC_MonthlyCircuitDetailStaticValues]
    WHERE INV_DATE = '2014-07-01'
    AND [Circuit_Total] >0
    Stored Proc below:
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE [dbo].[SP_TBC_ORBIT Process Form]
    -- Add the parameters for the stored procedure here
    @INVOICE_DATE varchar(20)
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    -- Insert statements for procedure here
    SELECT
    '0' as 'TYPE'
    ,'TBCCA' as 'Acc ID'
    ,'12882' as 'BEID'
    , '' as ' # OF UNITS'
    , Circuit_Total as 'AMT'
    ,'D' as 'D or C'
    , '' as ' FDOC yyyymmdd'
    , '' as ' LDOC yyyymmdd'
    , Address as 'Brief Comment'
    , city as 'Tax City'
    , State as 'Tax State'
    , Zip_Code as 'Tax Zip Code'
    , INV_DATE as 'Invoice Date'
    FROM [dbo].[TBC_MonthlyCircuitDetail]
    WHERE INV_DATE IN (@INVOICE_DATE)
    AND [Circuit_Total] >0
    END
    GO
    So, what do you suggest? As you can tell, I am quite a novice but I am learning by researching, asking questions and doing it. Thanks in advance!
    Sanjeev Jha

    Your second Select statement is as below:
    SELECT 0
      '0' as 'TYPE'
    --DID NOT LIKE THIS <<
    ,'TBCCA' as
    'Acc ID'
    ,'12882' as
    'BEID'
    , '' as
    ' # OF UNITS'
    , Circuit_Total as
    'AMT'
    ,'D' as 'D or C'
    , '' as
    ' FDOC yyyymmdd'
    , '' as
    ' LDOC yyyymmdd'
    , Address as
    'Brief Comment'
    , city as 'Tax City'
    , State as
    'Tax State'
    , Zip_Code as
    'Tax Zip Code'
    , ''INV_DATE
    as 'Invoice Date'  -- CHANGE HERE
    FROM [dbo].[TBC_MonthlyCircuitDetailStaticValues]
    WHERE INV_DATE = '2014-07-01'
    AND [Circuit_Total] >0
    You are receiving Invoice date from INV_DATE column from table or you want to set it as blank?
    Change it to either - ( '' as
    'Invoice Date' ) or  (INV_DATE as
    'Invoice Date'  )
    -Vaibhav Chaudhari

Maybe you are looking for