473,287 Members | 3,240 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,287 software developers and data experts.

Unable to add Array of table data type to function as IN parameter!

I want some expert help, like you.

I want to add more than one row into table using function,
but unable to pass F1(thebook book[]) as.
Kindly assist if any solution.

Expand|Select|Wrap|Line Numbers
  1. ----------------
  2.  
  3. CREATE TABLE book
  4. (
  5.   id smallint NOT NULL DEFAULT 0,       
  6.   bname text,       
  7.   btype text,
  8.   bprices numeric(11,2)[],
  9.   CONSTRAINT key PRIMARY KEY (id )
  10. );
  11.  
  12. --------------
  13.  
  14. CREATE OR REPLACE FUNCTION save_book(thebook book)
  15.   RETURNS text AS
  16. $BODY$
  17. DECLARE 
  18. myoutput text :='Nothing has occured';
  19. BEGIN
  20.  
  21.     update book set 
  22.     bname=thebook.bname,
  23.     btype=thebook.btype,bprices=thebook.bprices  WHERE id=thebook.id;
  24.  
  25.     IF FOUND THEN
  26.         myoutput:= 'Record with PK[' || thebook.id || '] successfully updated';
  27.         RETURN myoutput;
  28.     END IF;
  29.  
  30.     BEGIN
  31.         INSERT INTO book values(thebook.id,thebook.bname,thebook.btype,
  32.         thebook.bprices);
  33.         myoutput:= 'Record successfully added';           
  34.     END;
  35.  RETURN myoutput;
  36.  
  37.     END;
  38. $BODY$
  39.   LANGUAGE plpgsql VOLATILE
  40.   COST 100;
  41.  
  42.   -----------------------
  43.  
  44.   SELECT save_book(row(179,'the art of war','fiction1', array[190,220])::book); 
  45.  
  46.  
Problem: Here I can add only one row at a time, but I want to pass multiple rows to functions, I couldn't.
May 10 '16 #1
0 2087

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

Similar topics

1
by: Lukelrc | last post by:
Hi all. I'm having trouble connecting to my sql server database correctly beacause of value type problems, specifically the date fields. When i try and run the page i get the follwoing error: ...
8
by: CAFxX | last post by:
i'm writing a program that executes some calculations on a bitmap loaded in memory. these calculation ends up with pixel wth values far over 255, but i need them to be between 0 and 255 since i...
1
by: Simon | last post by:
Hi, Can anybody tell me if it is possible to return a table data type (as opposed to a temporary table) from a stored procedure. I am currently studying for 70-229 using the Thomas Moore book...
2
by: Niraj | last post by:
Hi, I am trying to do bulk insert of binary data (array of bytes) in an Oracle table. The data type of the table is BLOB. I am using Oracle Objects for OLE (OO4O) in C++. The binary data that I...
16
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the...
3
by: jonniethecodeprince | last post by:
Hi all, I have trouble getting an array of data stored in a separate javascript file i.e. a file called books.js into a table of data for a .xhtml file. There are 50 Records in this file....
1
by: jschmidt | last post by:
I am linking a table in access 2000 back to a view in sql server 2000. When I create the linked table in Access the "Location" Field is defined as a number. The data in the Location field in sql 2000...
5
by: Fei Liu | last post by:
Hello, I just hit a strange problem regarding SFINAE. The following code causes compile error (void cannot be array element type), I thought SFINA should match test(...) version instead and not...
3
by: kiers | last post by:
Hi All, I have created 3 tables; tblProjectDirectorates (Fields = ID, Directorate) tblSubDirectorates (Fields = ID, DirectorateID, Sub-Directorates) tblProjects (Fields = ID, Project Number,...
2
by: Justin | last post by:
I am getting this error when running on my local instance of SQL server, but it is not an issue when running on our development SQL Server box. Code: --variable declarations declare...
2
isladogs
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...
0
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.