Ask a Question related to Informix, Design and Development.

  1. #1

    Default SP Temp Tables


    Hi All,

    I am creating temp tables and dropping them after the processing is done in
    a stored procedure , however if users abort and try to run again we get the
    error " t_temp etc.. already in the database" . Is there any workaround to
    check if this temp table exists then drop it and create the temp table again
    ..


    Navdeep

    __________________________________________________ _______________
    See when your friends are online with MSN Messenger 6.0. Download it now
    FREE! [url]http://msnmessenger-download.com[/url]

    sending to informix-list
    navdeep virk Guest

  2. Similar Questions and Discussions

    1. Dynamic identification of Informix temp tables
      I would like to develop a process which can determine if there were temp tables created during my current database connection. I am the system...
    2. Temp tables and jdbc 2.21.jc3 on IDS 9.4.UC1
      The following query uses a TEMP table. I get the results in dbaccess, but the query fails when submitted from a java program using JDBC 2.21.jc3......
    3. Schedule maitenance or temp tables
      I'm developing a content management system to use for the web. I want to allow users to alter data, delete data, and add data for each individual...
    4. Accessing Temp Tables
      Hello Graham, You could try using global temp tables with a "##", in your case it would be - ##UserAccess. K "Graz79"...
    5. Question about optimizer with (big) temp tables
      If I ask query analyser to give me an estimated query plan, how does it work this out since my temp table will only be populated when I fire the...
  3. #2

    Default Re: SP Temp Tables

    If the user aborts in the SPL code you can trap on the exception and
    tidy up. Otherwise always drop the table first and then use the
    exception
    to resume a failed drop.

    navdeep virk wrote:
    >
    > Hi All,
    >
    > I am creating temp tables and dropping them after the processing is done in
    > a stored procedure , however if users abort and try to run again we get the
    > error " t_temp etc.. already in the database" . Is there any workaround to
    > check if this temp table exists then drop it and create the temp table again
    > .
    >
    > Navdeep
    >
    > __________________________________________________ _______________
    > See when your friends are online with MSN Messenger 6.0. Download it now
    > FREE! [url]http://msnmessenger-download.com[/url]
    >
    > sending to informix-list
    --
    Paul Watson #
    Oninit Ltd # Growing old is mandatory
    Tel: +44 1436 672201 # Growing up is optional
    Fax: +44 1436 678693 #
    Mob: +44 7818 003457 #
    [url]www.oninit.com[/url] #
    Paul Watson Guest

  4. #3

    Default Re: SP Temp Tables




    "navdeep virk" <nvirk@msn.com> wrote in message news:bnbo7c$k58$1@terabinaries.xmission.com...
    >
    > Hi All,
    >
    > I am creating temp tables and dropping them after the processing is done in
    > a stored procedure , however if users abort and try to run again we get the
    > error " t_temp etc.. already in the database" . Is there any workaround to
    > check if this temp table exists then drop it and create the temp table again
    > .
    There are two ways of dealing with this problem.

    1. Create an exception block to ignore errors and drop the temp table at the
    start of the procedure. No error will be returned if the table does not exists.

    BEGIN
    ON EXCEPTION
    --
    END EXCEPTION WITH RESUME

    DROP TABLE TMP_TABLE ;

    END

    2. Run this query at the start of the SP.

    SELECT count(*)
    into w_count
    from sysmaster:systabnames s,sysmaster:systabinfo i
    where i.ti_partnum = s.partnum
    and sysmaster:BITVAL(i.ti_flags,'0x0020') = 1
    and s.tabname = 'your_tmp_table_name' ;

    The query will return 1 if the temp table exists.

    I would go for option (1).

    Ravi



    --

    email id is bogus


    rkusenet Guest

  5. #4

    Default Re: SP Temp Tables

    Here's a procedure I have that does the same kind of thing you're talking
    about. You could essentialy add the begin end block logic to the top of
    your procedure.

    Hope this helps.

    Gregg Walker

    Create Procedure ClearShiftEntries(
    pShiftCardID integer
    )

    --set debug file to "/tmp/ClearShiftEntries.out";
    --trace on;

    begin

    on exception in (-206)

    begin

    create temp table tShiftEntry (
    shift_card_id integer not null,
    line_num smallint default 0 not null,
    entry_time datetime year to second not null,
    clock_entry_id integer
    )
    with no log;

    end

    end exception with resume

    delete from
    tShiftEntry
    where
    shift_card_id = pShiftCardID;

    end

    End Procedure; -- ClearShiftEntries

    "navdeep virk" <nvirk@msn.com> wrote in message
    news:bnbo7c$k58$1@terabinaries.xmission.com...
    >
    > Hi All,
    >
    > I am creating temp tables and dropping them after the processing is done
    in
    > a stored procedure , however if users abort and try to run again we get
    the
    > error " t_temp etc.. already in the database" . Is there any workaround to
    > check if this temp table exists then drop it and create the temp table
    again
    > .
    >
    >
    > Navdeep
    >
    > __________________________________________________ _______________
    > See when your friends are online with MSN Messenger 6.0. Download it now
    > FREE! [url]http://msnmessenger-download.com[/url]
    >
    > sending to informix-list

    Gregg Walker Guest

  6. #5

    Default Re: SP Temp Tables



    As you could see there are some "ways" to lead to this "issue"...

    What I wondwer is: Why this happen? Why a delete delay to delete?

    Funny...


    Chucho!

    navdeep virk wrote:
    > Hi All,
    >
    > I am creating temp tables and dropping them after the processing is done
    > in a stored procedure , however if users abort and try to run again we
    > get the error " t_temp etc.. already in the database" . Is there any
    > workaround to check if this temp table exists then drop it and create
    > the temp table again .
    >
    >
    > Navdeep
    >
    > __________________________________________________ _______________
    > See when your friends are online with MSN Messenger 6.0. Download it now
    > FREE! [url]http://msnmessenger-download.com[/url]
    >
    > sending to informix-list
    >
    >
    --


    Atte,


    Jesús Antonio Santos Giraldo
    [email]jeansagi@myrealbox.com[/email]
    [email]jeansagi@netscape.net[/email]

    sending to informix-list
    Jean Sagi Guest

  7. #6

    Default Re: SP Temp Tables

    do this before using the temp table

    if object_id("[tempdb].[dbo].[#TempTableName]") is not null drop #TempTableName
    create table #TempTableName
    (
    column1 DataType1,
    column2 DataType2,
    ...
    )


    This solves the problem.
    -Yordanos
    Unregistered Guest

  8. #7

    Default Re: SP Temp Tables

    do this before using the temp table

    if object_id("[tempdb].[dbo].[#TempTableName]") is not null drop #TempTableName
    create table #TempTableName
    (
    column1 DataType1,
    column2 DataType2,
    ...
    )


    This solves the problem.
    -Yordanos
    yordanos is offline Junior Member
    Join Date
    Feb 2011
    Location
    Maryland
    Posts
    1

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139