Prototype of Universal Wrapper stored procedure for Update, Delete and Insert in Postgres. Removes the need for writing procedures for each table.


1 -table name

2 - Can be'U', 'I', 'D' for Update, Insert, Delete respectively

3 - Primary key column name for Update, Delete

4 - Array of column names

5 - Array of column values


CREATE OR REPLACE FUNCTION "public"."uid" (p_table_name varchar, p_transaction_type varchar, p_key_name varchar, p_key_value varchar, p_column_names varchar [], p_column_values varchar []) RETURNS "pg_catalog"."void" AS
  v_sql VARCHAR;
  v_transaction_type VARCHAR;
  ArrayUbound INTEGER;
v_transaction_type := upper(p_transaction_type);
CASE WHEN v_transaction_type='U' THEN
     v_sql:= 'UPDATE ' || quote_ident(p_table_name) ||
     ' SET ';
     ArrayUbound := ARRAY_UPPER( p_column_names , 1) ; -- Get the upper bound of Array for the first dimension.  
     for i in 1 .. ArrayUbound loop
        v_sql := v_sql || quote_ident(p_column_names[i]) ||
         ' = ' || quote_literal(p_column_values[i]);
         if i < ArrayUbound THEN
            v_sql := v_sql || ',';
         end if;
     end loop;
     v_sql := v_sql || ' WHERE '|| quote_ident(p_key_name) ||
     ' = ' || quote_literal(p_key_value);
     RAISE LOG 'v_sql %', v_sql;
     EXECUTE v_sql;
     WHEN v_transaction_type='I' THEN
     INSERT INTO "public"."adb_koef" ("code_k", "namer_k", "namee_k", "prim", "saldo", "ras", "p_priv")
VALUES (4, 'К4', NULL, 'ЧПД/ССА', 0, NULL, True);
     v_sql:= 'INSERT INTO ' || quote_ident(p_table_name) ||
     ' (';
     ArrayUbound := ARRAY_UPPER( p_column_names , 1) ; -- Get the upper bound of Array for the first dimension.  
     for i in 1 .. ArrayUbound loop
        v_sql := v_sql || quote_ident(p_column_names[i]);
         if i < ArrayUbound THEN
            v_sql := v_sql || ',';
         end if;
     end loop;
     v_sql := v_sql || ') VALUES (';
     for i in 1 .. ArrayUbound loop
        v_sql := v_sql || quote_literal(p_column_values[i]);
         if i < ArrayUbound THEN
            v_sql := v_sql || ',';
         end if;
     end loop;
     v_sql := v_sql || ')';
     RAISE LOG 'v_sql %', v_sql;
     EXECUTE v_sql;
     WHEN v_transaction_type='D' THEN
     v_sql:= 'DELETE FROM ' || quote_ident(p_table_name) ||
     ' WHERE '|| quote_ident(p_key_name) ||
     ' = ' || quote_literal(p_key_value);
     RAISE LOG 'v_sql %', v_sql;
     EXECUTE v_sql;




Example of calling stored procedure above from MS Visual FoxPro


hConn = SQLCONNECT("sbs_pg",'SBS','SBS')
*hConn = SQLCONNECT("sbs_bt",'sbs','sbs')
Private begin_sec, end_sec, passed_sec
LOCAL v_date_wrk as Date
? v_date_wrk

* m_sql1="select public.uid('adb_koef','u','code_k','1',ARRAY['namer_k','namee_k','prim','ras'],ARRAY['laula1','lala2','lala3','lala4'])"
* m_sql1="select public.uid('adb_koef','d','code_k','20',null,null)"
m_sql1="select public.uid('adb_koef','i',null,null,ARRAY['code_k','namer_k','namee_k','prim','ras'],ARRAY['20','laula1','lala2','lala3','lala4'])"

? m_sql1
   ? RET
   end_sec = SECONDS()
   passed_sec = end_sec-begin_sec
   ? passed_sec    
   RET=SQLEXEC(hconn,"SELECT * from adb_koef","MyResult")
   *? RET
*? ok



**** Have a nice day! Hope my tip helped you.


My name is Kubanych Dzhakypakunov. I come from Kyrgyzstan, the small country in the Central Asia.


I want to write a fiction book, looking back to the path in my life, the life of microwave mind control “guinea pig” and tell to the people story of my life. Reality is stranger than fiction, sometimes I have a feeling that I do not believe that all this happened to me. This all feels like a long, unreal dream. You may think that I'm broken and my spirit is low. Well, not quite. I learned to be strong from Akira Kurosawa's characters in "Seven Samurai" film, those experiments may have damaged my body and to some extent brain, but not my spirit. Could you help and guide me on this endeavor? In exchange, you'd get unparalleled book story, or even script for the film. English language is not the thing I excel at, it's not my native language. But I could write a book in Russian to be translated into English later.

(I’m not Russian, but lived in Russian village for long).


Following is the story of my life.


Mankurt.  Who is that? 


From the novel “The day lasts longer than Century” by Kyrgyz writer Chingiz Aytmatov.


As Kyrgyz folk legend says, mankurt is the person who was abducted as a child and tortured in a special way. Thus person becomes a slave, who obeys commands of only his master. In an episode of the novel, one of those mankurts kills his own mother.


It’s a brief account of events I witnessed during my employment at Marconi Communications Ltd Ireland, from October 2000  to August 2002, and at CTBTO (Comprehensive Test Ban Treaty Organization, UN related organization), from March 2008 to November 2008.


Your beloved ones, next of kin, could potentially become victims of microwave mind control experiments. It’s about electromagnetic weapon systems. The main advantage of these kinds of weapons: ability to use it covertly and mask the deaths and illnesses from it with natural looking reasons. At present, these kinds of weapons are being tested on “guinea pigs” from Third world countries, the people just like me. (I come from Kyrgyzstan). And there’s a need for plenty of them. Firearms can be tested against any sort of targets, but to test mind control weapons, it takes a live human being. 


The microwave mind control experiment, conducted in Marconi Communications Ltd Ireland, Dublin, Ireland devastated my health, I became sleepless. My body started accumulating huge amount of static electricity. I noticed sudden changes in a state of my consciousness. The back of my neck started aching in constant pain, my immunity degraded. I started to feel chronic fatigue. At the time, the manager of the factory was Ken Doyle. (Ken Doyle, Chief Executive Officer,


I had to leave urgently my job to return to Kyrgyzstan due to bad state of my health. My speech became blurry; I started murmuring peculiar phrases that my relatives noticed, but not me. Later I learned that those were the symptoms of mind control weapons’ side effects.  


For around 3 years I was able to do only farming jobs. Recovery was very slow.  After a while, I returned to IT job. Then, in year 2008, I started working as Oracle DBA for CTBTO ( Comprehensive Test Ban Treaty Organization, UN related organization) in Vienna, Austria.


Right after arriving in my workplace, my employer demanded from me the package of documents that prove my ethnic origin. I considered the demand was peculiar, nevertheless I submitted the papers to the employer. And yet again, they started microwave mind control experiment with me in March 2008. Oh boy! It was like witchcraft, black magic. They could control state of my mind perfectly. They would make me feel apathy or enthusiasm, or get intense sexual arousal, or inflict aggressive mood. They even learned to read my mind.


The mind control experiments started in Nazi Germany under auspices of Ahnenerbe, SS occult institution. People were microwaved, installed electrodes in their brain. They collected huge research material out of those inhuman experiments. After the Second World War, those materials went to coalition of winners.


My colleague Timothy Hampton, who worked closely with me, later died in more than suspicious circumstances. His dead body was recovered from the bottom of stairwell in Building E of UN complex in Vienna, Austria. My work room was E507, Tim worked on the same floor.

(You  could Google up the story on Tim Hampton's death. Keywords: CTBTO BUILDING E OLENA GRYSCHUK WIDOW FLOOR 17)


By November 2008 I could not work. I frequently would fall asleep, again my health degraded. I had to return back to Kyrgyzstan and get medical treatment. Blood test results were just dreadful. 


In all its likeness, researchers used so called John Gittinger’s methods to evaluate my personality changes during stages of mind control experiment. John Gittinger designed the PAS (Personality Assessment System). This is an extraordinary method to evaluate human behavior and predict their decisions. The key element of this system is to make person drink too much alcohol. This reveals basic psychological type of person. Later they create artificial stressful situations in job place or personal life. The behavior patterns are then compared to database of hundreds of thousands such experiments. Thus, they will be able to create the fine model of person’s psychology.     


Best Regards,


Kubanych Dzhakypakunov

Citizen of Kyrgyzstan


Please help!I'm in bad health! Or, if you cannot, please distribute around!

Following are the payment instructions from my bank. Money should be sent in EURO.


1) Intermediary Bank:  Commerzbank AG, Frankfurt am Main, Germany
Account Number: 400886583400EUR
2) Bank of Beneficiary:   "Unicredit Bank" OJSC, Bishkek, Kyrgyz Republic
3) Beneficiary: Kubanych Dzhakypakunov
Account: 0109782099950001
Personal account: 97801000421
Purpose of payment:  Financial help

© postgres-tips

Бесплатный конструктор сайтов - uCoz