473,406 Members | 2,439 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,406 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

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #1
0 1145

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.