473,385 Members | 1,553 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,385 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. )
  8.  
  9.    RETURNS BOOLEAN
  10.    LANGUAGE plpgsql
  11.    AS $$ 
  12.  
  13. DECLARE
  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;
  19.  
  20. BEGIN
  21.  
  22.   if p_filnam is not NUll then
  23.      l_uuid_32_long := gen_random_uuid();
  24.    l_oid := replace(l_uuid_32_long, '-', '');
  25.  
  26.    l_uuid_32_long := gen_random_uuid();
  27.    l_uuid_32 := replace(l_uuid_32_long, '-', '');
  28.  
  29.    select * into coltran_rec from acc.coltran where bilbatchno = l_bilbatchno; 
  30.  
  31.    update acc.coltran set docstored = l_uuid_32, docname1 = p_filnam where bilbatchno = l_bilbatchno;
  32.  
  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;
  38.  
  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, '-', '');
  44.  
  45.       select * into coltran_rec from acc.coltran where bilbatchno = l_bilbatchno; 
  46.  
  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);
  52.  
  53.     end if;
  54.  
  55.  
  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;
  62.  
  63.    update acc.coltran set docstored2 = l_uuid_32,docname3 = p_filnam2 where bilbatchno = l_bilbatchno;
  64.  
  65.     INSERT into public.oxfiles
  66.       (id, data, name)
  67.    VALUES
  68.       (l_uuid_32, pg_read_binary_file(p_filnam2), p_filnam2);  
  69.  
  70.    end if;
  71.    return true;
  72. END
  73. $$;
Feb 17 '21 #1
0 1602

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

Similar topics

5
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...
2
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...
1
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...
0
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...
5
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:...
16
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
2
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...
2
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...
4
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. ...
3
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.