Обсуждение: Beginner - Help for pgsql 8.0.3 win32 platform

Поиск
Список
Период
Сортировка

Beginner - Help for pgsql 8.0.3 win32 platform

От
Nugroho Laison
Дата:
Dear All,

My Name is Nugon, I am just a beginner in pgsql, now I
am using pgsql 8.0.3 win32 platform. There are several
problem or issue for me, any help/answer/advice very
helpfull for me :
= how to get raise notice messages at client database
API such as ODBC, ADO, DAO, RDO or client programming
such as PHP, JSP, C/C++, Java?
= how to get number of affected rows by last sql
statement/operation (using GET DIAGNOSTICS statement)?
= how to use PERFORM statement?
= how to use EXECUTE statement?
= is it true that must state/write
<EXCEPTION_CONDITION_NAME> (e.g. division_by_zero ,
error_in_assignment, etc) where we using EXCEPTION?
can we use custom logical error condition (e.g.
(my_Var = 0), (rec_count > 0), (gender = 'M'),
(sqlstate <> 0 --> error system variable), etc)
= is there any virtual object that we can access to
examine new inserted or old deleted record in  trigger
for statement (such as old and new in trigger for
row)?
= can we create disconnected cursor?
(e.g.

declare
    v_cursor1 refcursor;
    v_cursor2 refcursor;

...
...
 open v_cursor1;
 v_cursor2 := v_cursor1;
 close v_cursor1;
 fetch v_cursor2;
...
...

)

-----

Regards,


Nugon

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: Beginner - Help for pgsql 8.0.3 win32 platform

От
Michael Fuhr
Дата:
On Fri, Aug 19, 2005 at 03:01:38PM -0700, Nugroho Laison wrote:
> = how to get raise notice messages at client database
> API such as ODBC, ADO, DAO, RDO or client programming
> such as PHP, JSP, C/C++, Java?

You'll have to consult the interface's documentation.  For example,
for C see the "libpq - C Library" chapter in the PostgreSQL
documentation:

http://www.postgresql.org/docs/8.0/static/libpq.html
http://www.postgresql.org/docs/8.0/static/libpq-notice-processing.html

> = how to get number of affected rows by last sql
> statement/operation (using GET DIAGNOSTICS statement)?

For server-side PL/pgSQL programming see "Obtaining the Result
Status" in the PL/pgSQL documentation:

http://www.postgresql.org/docs/8.0/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS

For client-side C code, see "Retrieving Query Result Information"
and "Retrieving Result Information for Other Commands" in the libpq
documentation:

http://www.postgresql.org/docs/8.0/static/libpq-exec.html#LIBPQ-EXEC-SELECT-INFO
http://www.postgresql.org/docs/8.0/static/libpq-exec.html#LIBPQ-EXEC-NONSELECT

For other interfaces, see the relevant documentation.

> = how to use PERFORM statement?

See "Executing an Expression or Query With No Result" in the PL/pgSQL
documentation:

http://www.postgresql.org/docs/8.0/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-PERFORM

> = how to use EXECUTE statement?

EXECUTE means different things depending on whether you're using
PL/pgSQL or SQL.  See the documentation for examples:

http://www.postgresql.org/docs/8.0/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
http://www.postgresql.org/docs/8.0/static/sql-execute.html

> = is it true that must state/write
> <EXCEPTION_CONDITION_NAME> (e.g. division_by_zero ,
> error_in_assignment, etc) where we using EXCEPTION?
> can we use custom logical error condition (e.g.
> (my_Var = 0), (rec_count > 0), (gender = 'M'),
> (sqlstate <> 0 --> error system variable), etc)

See "Trapping Errors" in the PL/pgSQL documentation for the allowed
usage:

http://www.postgresql.org/docs/8.0/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

> = is there any virtual object that we can access to
> examine new inserted or old deleted record in  trigger
> for statement (such as old and new in trigger for
> row)?

See "Trigger Procedures" in the PL/pgSQL documentation or the
documentation for whatever server-side language you're using.

http://www.postgresql.org/docs/8.0/static/plpgsql-trigger.html

> = can we create disconnected cursor?
> (e.g.
>
> declare
>     v_cursor1 refcursor;
>     v_cursor2 refcursor;
>
> ...
> ...
>  open v_cursor1;
>  v_cursor2 := v_cursor1;
>  close v_cursor1;
>  fetch v_cursor2;

See "Cursors" in the PL/pgSQL documentation for the allowed usage:

http://www.postgresql.org/docs/8.0/static/plpgsql-cursors.html

If the documentation doesn't answer your questions, then please
post specific examples of what you're trying to do and describe the
difficulties you're having.

--
Michael Fuhr