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

Assigning Values to Arrays

Greetings All,

Running pg 7.3.4 and was reading: http://archives.postgresql.org/pgsql...9/msg00018.php . Basically want to assign values to an array and then a 2d array.

However I can't get this to run in properly I get a syntax error (at or near "[") with function listed below.

Any suggestions are greatly appreciated :-)

Thanks,
Z.

btw, is there an user-contributed notes section of the pg documentation I could post a working example too (yeah php developer in the house :-)).

Test procedure::

create table test_output(
output_num_arr numeric[][],
output_txt_arr TEXT[],
output_str text
);

CREATE OR REPLACE FUNCTION F_TEST(TEXT) RETURNS NUMERIC AS '
DECLARE
HeaderArray text[] = ''{}'';
BEGIN
HeaderArray[1] := \'hi\';
HeaderArray[2] := \'this\';
HeaderArray[3] := \'is\';
HeaderArray[4] := \'not\';
HeaderArray[5] := \'a\';
HeaderArray[6] := \'test\';

insert into test_output(output_txt_arr) values (HeaderArray);
insert into test_output(output_str) values (HeaderArray[1]);
insert into test_output(output_str) values (HeaderArray[2]);
insert into test_output(output_str) values (HeaderArray[3]);
insert into test_output(output_str) values (HeaderArray[4]);
insert into test_output(output_str) values (HeaderArray[5]);
insert into test_output(output_str) values (HeaderArray[6]);

END;
'LANGUAGE 'plpgsql';

select F_TEST('a');
select * from test_output;
drop function F_TEST(TEXT);
drop table test_output;

Nov 12 '05 #1
2 3362
On Wed, 2003-10-08 at 11:41, Zitan Broth wrote:
Greetings All,

Running pg 7.3.4 and was reading:
http://archives.postgresql.org/pgsql...9/msg00018.php . Basically want to assign values to an array and then a 2d array.

However I can't get this to run in properly I get a syntax error (at
or near "[") with function listed below.

Any suggestions are greatly appreciated :-)


Your function does not have a return statement.

--
Oliver Elphick Ol************@lfix.co.uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Let no man say when he is tempted, I am tempted of
God; for God cannot be tempted with evil, neither
tempteth he any man; But every man is tempted, when he
is drawn away of his own lust, and enticed."
James 1:13,14
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #2
But that isn't causing the syntax error .....

From rereading the Post I am certain that I need 7.4 rather than 7.3.4 for
this to work :-)

Thanks for the response.

Z.

On Wed, 2003-10-08 at 11:41, Zitan Broth wrote:
Greetings All,

Running pg 7.3.4 and was reading:
http://archives.postgresql.org/pgsql...9/msg00018.php . Basically want to assign values to an array and then a 2d array.
However I can't get this to run in properly I get a syntax error (at
or near "[") with function listed below.

Any suggestions are greatly appreciated :-)


Your function does not have a return statement.


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ched | last post by:
Hi, I am performing a MySQL SELECT (which returns multiple rows) to $result and then extracting the results with mysql_fetch_array($result). I then want to build a number of arrays using the...
4
by: Bill | last post by:
I have a catalog of books which need to be categorized into different groups. Some of the books can be listed under more than one category. I'm creating a page where I can assign a group of books...
14
by: Eric Bantock | last post by:
Very basic question I'm afraid. Once an array has been declared, is there a less tedious way of assigning values to its members than the following: myarray=8; myarray=3; myarray=4; myarray=0;...
17
by: I.M. !Knuth | last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until I started goofing around with this: ...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
3
by: mamun | last post by:
Hi all, I am trying to create variables dynamically. This is needed because the user interface can have ten different textboxes with name as txt1, txt2 and so on. I would like to get values of...
2
by: Ray D. | last post by:
I want to set matrix A with the values below, but it produced a syntax error when I try to compile the commented code. I was told to use a for loop to do this (as shown below), but that really...
43
by: emyl | last post by:
Hi all, here's an elementary question. Assume I have declared two variables, char *a, **b; I can then give a value to a like a="hello world";
6
by: sumuka | last post by:
Hello, I'm doing a project in java and im not able to assign the values which are got from for loop to the 2-dimensional array. Can anyone tell me how to assign the values and print them? the...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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.