473,378 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

which Schema I am working on??

Hi all,
I am writing a pl/psql function with a temp table right now.
It creates the temp table inside. Whenever I call this function in a
session for the first time, it creates a shema, namely pg_temp_number,
automatically and it creates the temp table within the schema. I've
tried to add a check inside the function to check have the temp table
been already existed. The function will look like :

CREATE OR REPLACE FUNCTION reffunc(refcursor, varchar(10),
varchar(10)) RETURNS refcursor AS '
BEGIN
IF (SELECT 1 WHERE EXISTS (SELECT * FROM pg_tables WHERE tablename
= ''tablexxx'')) = 1 THEN
EXECUTE ''DROP TABLE tablexxx '';
END IF;
EXECUTE ''create local temp table tablexxx (repno character(15),
date date)'';
EXECUTE ''insert into tablexxx (repno, date) VALUES (
''||quote_literal($2)||'', now() )'';
EXECUTE ''insert into tablexxx (repno, date) VALUES (
''||quote_literal($3)||'', now() )'';
OPEN $1 for EXECUTE '' SELECT * FROM tablexxx '';
RETURN $1;
END;
' LANGUAGE 'plpgsql';

It works fine as long as there is only one session (or only one client)
calling and called this function. For example, if one session has called
the funciton and the session is not terminated yet, then other session
call this function again, the function would find there is already a
table called tablexxx in the pg_tables and it tries to drop the table.
However, there is not table tablexxx belonged to the second session
actually. Therefore, the function would fail with this error message:

ERROR: table "tablexxx" does not exist

Firstly, is there anyway to find out which Schema I am working on, so I
could query the pg_tables with a specified schemaname??

Second, I am wondering how could I drop the automically created schema
automically? Could I config the system to make it drop the correpsonding
schema whenever a session is terminated?

Thank You Very Much.

Harry Yau
Nov 11 '05 #1
0 1195

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: joes | last post by:
Hello there I tried for several days to get a simple validation with xml schema & xerces working. Goal for me is tuse JAXP and not specific Xerces classes. I don't get the point what I am doing...
4
by: stiank81 | last post by:
Hi. I have a problem witch I assume there is an answear to....? I have several XML schemas, and they all have quiet a lot of definitions in common. They still have to be seperated into...
0
by: Harry Yau | last post by:
Hi all, I am writing a pl/psql function with a temp table right now. It creates the temp table inside. Whenever I call this function in a session for the first time, it creates a shema, namely...
8
by: Poonam | last post by:
Hi, Can some one please help me with (or point me to) a very simple but working code sample that shows how to import XML Schema. I have tried many samples out there on internet but nothing seems...
4
by: Iain A. Mcleod | last post by:
Hi I'm stuck with the following schema validation problem in VS.NET 2003: I have two types of xml document and related schema: project and projectCollection. A projectcollection is just a set...
0
by: Derek | last post by:
I am creating an intranet using Visual Web Developer Express Edition. Everything has been working OK until yesterday when I started getting 62 messages all beginning "Could not find schema...
5
by: Reuven Nisser | last post by:
Hi, How can I describe an XML like this: <X> <Y/> <Z/> <Y/> <Y/> </X>
4
by: cmay | last post by:
I am beginning to wonder if it is not possible to get this working. I am trying to do: <root> <a/> <b/> <c/> </root>
0
by: icesign | last post by:
I know that the selector of these elements has a scope relative to the element being declared, but maybe there is a way to get beyond bounds of this scope or maybe just a way to extend base element?...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.