473,230 Members | 1,366 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,230 software developers and data experts.

Allowing the to show only 1 record or 2 records or 3 records

2 2Bits
Good day
Below is the code which i use if i have 3 rows then it works but if i choose 1 record then i get a resultset error

Expand|Select|Wrap|Line Numbers
  1. CREATE or REPLACE FUNCTION public.upload_coll(
  2.    l_bilbatchno character(32),
  3.    p_filnam CHARACTER,
  4.    p_filnam1 CHARACTER,
  5.    p_filnam2 CHARACTER,
  6.    user_name CHARACTER
  7. )
  10.    LANGUAGE plpgsql
  11.    AS $$ 
  14.    l_uuid_32_long varchar(36);
  15.    l_uuid_32      varchar(32);
  16.    l_oid          varchar(32);
  17.    p_matid        varchar(15);
  18.    coltran_rec    record;
  20. BEGIN
  22.   if p_filnam is not NUll then
  23.      l_uuid_32_long := gen_random_uuid();
  24.    l_oid := replace(l_uuid_32_long, '-', '');
  26.    l_uuid_32_long := gen_random_uuid();
  27.    l_uuid_32 := replace(l_uuid_32_long, '-', '');
  29.    select * into coltran_rec from acc.coltran where bilbatchno = l_bilbatchno; 
  31.    update acc.coltran set docstored = l_uuid_32, docname1 = p_filnam where bilbatchno = l_bilbatchno;
  33.      INSERT into public.oxfiles
  34.       (id, data, name)
  35.    VALUES
  36.      (l_uuid_32, pg_read_binary_file(p_filnam), p_filnam);
  37.    end if;
  39.    if p_filnam1 is not Null then
  40.       l_uuid_32_long := gen_random_uuid();
  41.       l_oid := replace(l_uuid_32_long, '-', '');
  42.      l_uuid_32_long := gen_random_uuid();
  43.      l_uuid_32 := replace(l_uuid_32_long, '-', '');
  45.       select * into coltran_rec from acc.coltran where bilbatchno = l_bilbatchno; 
  47.       update acc.coltran set docstored1 = l_uuid_32, docname2 = p_filnam1 where bilbatchno = l_bilbatchno;
  48.       INSERT into public.oxfiles
  49.    (id, data, name)
  50.    VALUES
  51.    (l_uuid_32, pg_read_binary_file(p_filnam1), p_filnam1);
  53.     end if;
  56.    if p_filnam2 is not Null then
  57.       l_uuid_32_long := gen_random_uuid();
  58.    l_oid := replace(l_uuid_32_long, '-', '');
  59.       l_uuid_32_long := gen_random_uuid();
  60.    l_uuid_32 := replace(l_uuid_32_long, '-', '');
  61.      select * into coltran_rec from acc.coltran where bilbatchno = l_bilbatchno;
  63.    update acc.coltran set docstored2 = l_uuid_32,docname3 = p_filnam2 where bilbatchno = l_bilbatchno;
  65.     INSERT into public.oxfiles
  66.       (id, data, name)
  67.    VALUES
  68.       (l_uuid_32, pg_read_binary_file(p_filnam2), p_filnam2);  
  70.    end if;
  71.    return true;
  72. END
  73. $$;
Feb 17 '21 #1
0 1598

Sign in to post your reply or Sign up for a free account.

Similar topics

by: crispy | last post by:
On this page, you'll see that some PubID's are repeated several times: http://www.ihea.info/pages/website/test1.asp That's because some records have more than one attribute. For example, Title...
by: chris vettese | last post by:
I've been searching for a few days and have't found the solution I'm looking for. I want to create the following in my form's header...Material: 1 of 15. The first number will change as the user...
by: snOOp | last post by:
I am trying to combine the data from two similar tables into one query, but I need for all of the records from both tables to show up and I want the ones that have matching 'emplid' to be combined...
by: Tom Kaminski [MVP] | last post by:
I want to show a table of master records, with the right most column displayed as a comma (or space) delimited list of details. The practical application of this is a thesaurus, where the master...
by: Miguel Dias Moura | last post by:
Hello, i have a dataSet in an ASP.Net / VB page which connects to a database named "DB" with fields AuthorName, BookTitle, BookEditor. I want do display 4 records in my page as follows:...
by: William Buchanan | last post by:
Hi folks I want to show 2 records on a page side by side. Each record has an image which will be displayed and a bit of text. How can I do this? Thanks Will
by: Zeljko | last post by:
I'm creating Address book. Header of the main form (frmAddress) contains combo box (cboFilter) to filter records by Occupation on main Form(Ocupation1). That's working. Combo box also have "Show...
by: Otto | last post by:
Hi I'm migrating from Access til MySQL. Works fine so far - but one thing is nearly killing me: I got the count of total records in a variabel - (antalRecords) I got the count for the Field Q1...
by: kdubble | last post by:
Hi I am trying to get the results of a query to show only unique student records (not duplicates). Is there a simple way to make the criteria field do this? I am not too familiar with SQL. ...
by: ali3n8 | last post by:
I am using a search form that list records in my database. On the list that shows the records that have been found I have a field called First. When I double click on this field I would like to open...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.